Feature Matrix

A quick comparison of the four collections. Declaration-level detail lives in the API Overview and the generated Cheat Sheet; behaviour lives in the collection guides.

FeatureListDequeDictionaryHash Set
Element typeone (T)one (T)key + valueone (T, unique)
Required configurationcomparernonenone (custom hash for other keys)equality + hash
ConstructorCreate(Comparer)Create / Create(Capacity)Create / Create(Capacity) / Create(Hash, Equals)Create(Equality, Hash) or specialized
Indexed accessItems[I], defaultnoItems[Key]no
Order guaranteeinsertion order retainedpositional (front/back)none (hash order)none (hash order)
Random accessO(1)O(1) to an endO(1) average by keymembership only
Sorting / searchingyes, comparer-drivennoyes for keysmembership / set ops
Iteration modellock-holdinglock-holdingsnapshotlock-holding
Bulk add/removeAddRange, InsertRange, DeleteRangePushRangeFront/BackAddRange (dict/array)AddRange, RemoveRange
Set algebra———IntersectWith, UnionWith, ExceptWith, Overlaps, SetEquals
Try* variantsnoTryPopFront/Back, TryPeekFront/BackTryGetValue, TryAddTryGetValue
Capacity controlCapacity, TrimExcessinitial capacityTrimExcessTrimExcess
Array conversionToArray, FromArrayToArray, CopyToToArray (pairs), GetKeys, GetValuesToArray
Specialized classes———Integer, String, Boolean, Real
Interface formIThreadSafeList<T>IThreadSafeDeque<T>IThreadSafeDictionary<TKey, TValue>IThreadSafeHashSet<T>

Shared behaviour across all collections#

  • One TCriticalSection per instance; each public method synchronizes.
  • Count in O(1); IsEmpty; Clear; Lock returning an ILockToken.
  • No automatic freeing of object/interface elements.
  • Manual lock tokens must not be combined with public method calls on the same

instance (see Lock Tokens).

Iteration model by collection#

CollectionEnumerator holds lockSnapshotNotes
Listyesnokeep loop bodies short
Dequeyesno
Hash setyesno
Dictionarynoyessnapshot of pairs at iteration start

Choosing a collection#

  • Need indexed access, sorting, or binary search? List.
  • Producer/consumer queue or stack on both ends? Deque.
  • Key/value lookup with custom keys? Dictionary.
  • Uniqueness, membership, and set operations? Hash set.
  • Compound operations that must be atomic together at the call site? Combine

methods while holding a Lock token.

Examples mapping#

ExampleCollections used
SimpleNumberListList
SimpleDequeDeque
SimpleHashSet, HashSetClientDemoHash set
DictionaryIterator, DictionaryIteratorRecordDictionary
DictionaryWithCustomTypeDictionary with custom key
SimpleShoppingCart, SimpleToDoListList with custom types
ChatMessageQueueDeque in threads
ListIterate, HashSetIterate, HashSetIterateRecordenumeration
InterfaceTestinterface forms and lock tokens
Benchmarkperformance measurement