Collections Module

Generic collections, immutable collections, concurrent collections, and ObjectModel.

Generic Collections (System::Collections::Generic)

ClassBacked byNotes
List<T>std::vector<T>Dynamic array with .NET API; Add, Remove, Insert, IndexOf, Contains, Sort
Dictionary<K,V>std::unordered_map<K,V>Hash table; Add, Remove, ContainsKey, TryGetValue
HashSet<T>std::unordered_set<T>Add, Remove, Contains, ExceptWith, IntersectWith
Queue<T>std::queue<T>Enqueue, Dequeue, Peek
Stack<T>std::stack<T>Push, Pop, Peek
SortedDictionary<K,V>std::map<K,V>Ordered key-value pairs
SortedList<K,V>std::map<K,V>Sorted by key
SortedSet<T>std::set<T>Sorted, no duplicates
LinkedList<T>std::list<T>Doubly-linked list
PriorityQueue<T,P>std::priority_queueMin-heap by priority
KeyValuePair<K,V>StructKey/Value pair

List<T> Example

#include "System/Collections/Generic/List.hpp"
using namespace System::Collections::Generic;

List<int> list;
list.Add(1);
list.Add(2);
list.Add(3);
int count = list.getCountProperty();  // 3
bool has = list.Contains(2);          // true
list.Remove(2);
for (auto& item : list) { /* range-for works */ }

Dictionary<K,V> Example

#include "System/Collections/Generic/Dictionary.hpp"
using namespace System::Collections::Generic;

Dictionary<std::string, int> dict;
dict.Add("one", 1);
dict.Add("two", 2);
int val;
if (dict.TryGetValue("one", val)) { /* val = 1 */ }
bool has = dict.ContainsKey("two");  // true
dict.Remove("two");

Immutable Collections (System::Collections::Immutable)

Backed by shared_ptr<const std::container<T>>. Provides value-copy semantics with efficient sharing.

ClassHeader
ImmutableArray<T>System/Collections/Immutable/ImmutableArray.hpp
ImmutableList<T>System/Collections/Immutable/ImmutableList.hpp
ImmutableDictionary<K,V>System/Collections/Immutable/ImmutableDictionary.hpp
ImmutableHashSet<T>System/Collections/Immutable/ImmutableHashSet.hpp
ImmutableQueue<T>System/Collections/Immutable/ImmutableQueue.hpp
ImmutableStack<T>System/Collections/Immutable/ImmutableStack.hpp
ImmutableSortedDictionary<K,V>System/Collections/Immutable/ImmutableSortedDictionary.hpp
ImmutableSortedSet<T>System/Collections/Immutable/ImmutableSortedSet.hpp

Concurrent Collections (System::Collections::Concurrent)

ClassHeaderDescription
ConcurrentDictionary<K,V>System/Collections/Concurrent/ConcurrentDictionary.hppThread-safe dictionary
ConcurrentQueue<T>System/Collections/Concurrent/ConcurrentQueue.hppThread-safe FIFO queue
ConcurrentStack<T>System/Collections/Concurrent/ConcurrentStack.hppThread-safe LIFO stack

ObjectModel (System::Collections::ObjectModel)

ClassHeader
Collection<T>System/Collections/ObjectModel/Collection.hpp
ObservableCollection<T>System/Collections/ObjectModel/ObservableCollection.hpp
ReadOnlyCollection<T>System/Collections/ObjectModel/ReadOnlyCollection.hpp
KeyedCollection<K,T>System/Collections/ObjectModel/KeyedCollection.hpp

Non-Generic Collections (System::Collections)

ClassHeader
ArrayListSystem/Collections/ArrayList.hpp
HashtableSystem/Collections/Hashtable.hpp
BitArraySystem/Collections/BitArray.hpp
QueueSystem/Collections/Queue.hpp
StackSystem/Collections/Stack.hpp

Interfaces

All generic collection interfaces have C++ abstract base class equivalents: