System.Collections.Immutable Namespace
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Contains interfaces and classes that define immutable collections.
Classes
| Name | Description |
|---|---|
| ImmutableArray |
Provides methods for creating an array that is immutable, meaning it can't be changed once it's created. |
| ImmutableArray<T>.Builder |
Represents a writable array accessor that can be converted into an ImmutableArray<T> instance without allocating extra memory. |
| ImmutableDictionary |
Provides a set of initialization methods for instances of the ImmutableDictionary<TKey,TValue> class. |
| ImmutableDictionary<TKey,TValue>.Builder |
Represents a hash map that mutates with little or no memory allocations and that can produce or build on immutable hash map instances efficiently. |
| ImmutableDictionary<TKey,TValue> |
Represents an immutable, unordered collection of keys and values. |
| ImmutableHashSet |
Provides a set of initialization methods for instances of the ImmutableHashSet<T> class. |
| ImmutableHashSet<T>.Builder |
Represents a hash set that mutates with little or no memory allocations and that can produce or build on immutable hash set instances efficiently. |
| ImmutableHashSet<T> |
Represents an immutable, unordered hash set. |
| ImmutableInterlocked |
Contains interlocked exchange mechanisms for immutable collections. |
| ImmutableList |
Provides a set of initialization methods for instances of the ImmutableList<T> class. |
| ImmutableList<T>.Builder |
Represents a list that mutates with little or no memory allocations and that can produce or build on immutable list instances efficiently. |
| ImmutableList<T> |
Represents an immutable list, which is a strongly typed list of objects that can be accessed by index. |
| ImmutableQueue |
Provides a set of initialization methods for instances of the ImmutableQueue<T> class. |
| ImmutableQueue<T> |
Represents an immutable queue. |
| ImmutableSortedDictionary |
Provides a set of initialization methods for instances of the ImmutableSortedDictionary<TKey,TValue> class. |
| ImmutableSortedDictionary<TKey,TValue>.Builder |
Represents a sorted dictionary that mutates with little or no memory allocations and that can produce or build on immutable sorted dictionary instances efficiently. |
| ImmutableSortedDictionary<TKey,TValue> |
Represents an immutable sorted dictionary. |
| ImmutableSortedSet |
Provides a set of initialization methods for instances of the ImmutableSortedSet<T> class. |
| ImmutableSortedSet<T>.Builder |
Represents a sorted set that enables changes with little or no memory allocations, and efficiently manipulates or builds immutable sorted sets. |
| ImmutableSortedSet<T> |
Represents an immutable sorted set implementation. |
| ImmutableStack |
Provides a set of initialization methods for instances of the ImmutableStack<T> class. |
| ImmutableStack<T> |
Represents an immutable stack. |
Structs
| Name | Description |
|---|---|
| ImmutableArray<T>.Enumerator |
Represents an array enumerator. |
| ImmutableArray<T> |
Represents an array that is immutable, meaning it can't be changed once it's created. |
| ImmutableDictionary<TKey,TValue>.Enumerator |
Enumerates the contents of the immutable dictionary without allocating any memory. |
| ImmutableHashSet<T>.Enumerator |
Enumerates the contents of the immutable hash set without allocating any memory. |
| ImmutableList<T>.Enumerator |
Enumerates the contents of a binary tree. |
| ImmutableQueue<T>.Enumerator |
Enumerates the contents of an immutable queue without allocating any memory. |
| ImmutableSortedDictionary<TKey,TValue>.Enumerator |
Enumerates the contents of a binary tree. |
| ImmutableSortedSet<T>.Enumerator |
Enumerates the contents of a binary tree. |
| ImmutableStack<T>.Enumerator |
Enumerates the contents of an immutable stack without allocating any memory. |
Interfaces
| Name | Description |
|---|---|
| IImmutableDictionary<TKey,TValue> |
Represents an immutable collection of key/value pairs. |
| IImmutableList<T> |
Represents a list of elements that cannot be modified. |
| IImmutableQueue<T> |
Represents an immutable first-in, first-out collection of objects. |
| IImmutableSet<T> |
Represents a set of elements that can only be modified by creating a new instance of the set. |
| IImmutableStack<T> |
Represents an immutable last-in-first-out (LIFO) collection. |
Remarks
With immutable collections, you can:
- Share a collection in a way that its consumer can be assured that the collection never changes.
- Provide implicit thread safety in multi-threaded applications (no locks required to access collections).
- Follow functional programming practices.
- Modify a collection during enumeration, while ensuring that the original collection does not change.