Development · Native API migration preview · Coverage validation in progress Published release →

API Browser

Module

System.Collections

module System.Collections

Collections and iteration

Collection capabilities separate iteration, indexed reads, mutation and map lookup. Iterable and Iterator support traversal; Sequence and MutableSequence describe indexed access. ArrayList and HashMap provide concrete list and map storage, with explicit equality and comparison policies where supported.

Use System.Linq for query operators over these collections. The collections guide explains the current generic and execution-mode limits.

Map indexing uses map[key]. Map<K,V> exposes the getter; MutableMap<K,V> also exposes an insert-or-replace setter. HashMap<K,V> uses the same comparer as Find and Set, retaining the originally stored equivalent key when replacing a value. A getter for an absent key causes a terminal Fault: prefer Find for lookup when the key may be absent. Indexing adds no concurrent or atomic update guarantee.

Fluent helpers extend MutableMap with Entry(key) and MutableSet with GetOrInsert(value). MapEntry is a reusable live locator, with Find, Value, Set, OrInsert, OrInsertWith and AndModify. MutableSet.Find returns the stored equivalent value. See the full contracts, including callback reentry, failures, allocation and the lack of atomicity.

Development KeyValuePair records now have generated equality and hashing. See the pair reference for the supported component contracts and current generic allocation costs. HashMap still uses its explicit comparer.

Development PriorityArrayQueue<TElement, TPriority> adds min-priority removal with an explicit Comparer policy and Optional results. It is an array-backed heap, not an indexed sorted list.

Types

26 items
ArrayList<T> A growable array-backed list with indexed access, shallow copying and predicate searches.
ArrayQueue<T> Unsynchronized array-backed FIFO queue. Iteration captures a shallow snapshot.
ArrayStack<T> Unsynchronized array-backed LIFO stack. Iteration captures a shallow snapshot.
AsyncIterable<T> A pull-based asynchronous source. Each iterator has an independent lifetime.
AsyncIterator<T> A single-consumer asynchronous cursor. Do not overlap advancement or disposal.
Collection<T> An iterable collection with an element count.
Comparer<T> Orders values by the sign of Compare's result.
EqualityComparer<T> Defines a stable equality relation and matching hash codes.
FunctionComparer<T> Adapts an ordering callback into a reusable policy.
FunctionEqualityComparer<T> Adapts equality and hash callbacks into one reusable policy.
HashMap<K, V> A mutable hash table using an explicit key equality/hash policy or callbacks.
HashSet<T> An unsynchronized hash set with an explicit equality policy and snapshot iteration.
Iterable<T> A source of typed iterators.
Iterator<T> A disposable cursor over typed elements.
KeyValuePair<K, V> A key and value transported together as a deconstructable value.
List<T> An indexed mutable sequence that supports appending elements.
Map<K, V> Read-only key lookup, key/value pair iteration, key enumeration and entry count capabilities.
MapEntry<K, V> A reusable live key locator, not a borrowed storage reference or snapshot.
MutableMap<K, V> A map that supports inserting entries and replacing values.
MutableSequence<T> An indexed sequence whose existing elements can be replaced.
MutableSet<T> A set supporting insertion, removal and clearing.
PriorityArrayQueue<TElement, TPriority> An unsynchronized binary min-heap with an explicit priority comparer.
Queue<T> A mutable FIFO collection. Thread safety is an implementation contract.
Sequence<T> A counted collection with read-only indexed access.
Set<T> A collection of distinct elements under its implementation's equality policy.
Stack<T> A mutable LIFO collection. Thread safety is an implementation contract.

Type extensions

3 items
MutableMapExtensions for MutableMap<K, V> Fluent operations using the public mutable map contract.
MutableSetExtensions for MutableSet<T> Convenience operations using the public mutable set contract.
SequenceAccess for Sequence<T> Indexing, slicing and validated access to counted, ordered sequences. Import System.Collections.* to use these extensions.