System.Collections.Immutable Namespace

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.Builder

Represents a writable array accessor that can be converted into an ImmutableArray instance without allocating extra memory.

ImmutableDictionary

Provides a set of initialization methods for instances of the ImmutableDictionary class.

ImmutableDictionary.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

Represents an immutable, unordered collection of keys and values.

ImmutableHashSet

Provides a set of initialization methods for instances of the ImmutableHashSet class.

ImmutableHashSet.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

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 class.

ImmutableList.Builder

Represents a list that mutates with little or no memory allocations and that can produce or build on immutable list instances efficiently.

ImmutableList

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 class.

ImmutableQueue

Represents an immutable queue.

ImmutableSortedDictionary

Provides a set of initialization methods for instances of the ImmutableSortedDictionary class.

ImmutableSortedDictionary.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

Represents an immutable sorted dictionary.

ImmutableSortedSet

Provides a set of initialization methods for instances of the ImmutableSortedSet class.

ImmutableSortedSet.Builder

Represents a sorted set that enables changes with little or no memory allocations, and efficiently manipulates or builds immutable sorted sets.

ImmutableSortedSet

Represents an immutable sorted set implementation.

ImmutableStack

Provides a set of initialization methods for instances of the ImmutableStack class.

ImmutableStack

Represents an immutable stack.

Structs

Name Description
ImmutableArray.Enumerator

Represents an array enumerator.

ImmutableArray

Represents an array that is immutable, meaning it can't be changed once it's created.

ImmutableDictionary.Enumerator

Enumerates the contents of the immutable dictionary without allocating any memory.

ImmutableHashSet.Enumerator

Enumerates the contents of the immutable hash set without allocating any memory.

ImmutableList.Enumerator

Enumerates the contents of a binary tree.

ImmutableQueue.Enumerator

Enumerates the contents of an immutable queue without allocating any memory.

ImmutableSortedDictionary.Enumerator

Enumerates the contents of a binary tree.

ImmutableSortedSet.Enumerator

Enumerates the contents of a binary tree.

ImmutableStack.Enumerator

Enumerates the contents of an immutable stack without allocating any memory.

Interfaces

Name Description
IImmutableDictionary

Represents an immutable collection of key/value pairs.

IImmutableList

Represents a list of elements that cannot be modified.

IImmutableQueue

Represents an immutable first-in, first-out collection of objects.

IImmutableSet

Represents a set of elements that can only be modified by creating a new instance of the set.

IImmutableStack

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.