ImmutableSortedSet(T) Class
Represents an immutable sorted set implementation.
NuGet package: System.Collections.Immutable (about immutable collections and how to install)
Namespace: System.Collections.Immutable
Assembly: System.Collections.Immutable (in System.Collections.Immutable.dll)
[<Sealed>] type ImmutableSortedSet<'T> = class interface IImmutableSet<'T> interface IReadOnlyList<'T> interface IReadOnlyCollection<'T> interface IList<'T> interface ISet<'T> interface ICollection<'T> interface IEnumerable<'T> interface IList interface ICollection interface IEnumerable end
Type Parameters
- T
The type of elements in the set.
The ImmutableSortedSet(T) type exposes the following members.
| Name | Description | |
|---|---|---|
![]() | Count | Gets the number of elements in the immutable sorted set. |
![]() | IsEmpty | Gets a value that indicates whether this immutable sorted set is empty. |
![]() | Item | Gets the element of the immutable sorted set at the given index. |
![]() | KeyComparer | Gets the comparer used to sort keys in the immutable sorted set. |
![]() | Max | Gets the maximum value in the immutable sorted set, as defined by the comparer. |
![]() | Min | Gets the minimum value in the immutable sorted set, as defined by the comparer. |
| Name | Description | |
|---|---|---|
![]() | Add | Adds the specified value to this immutable sorted set. |
![]() | Clear | Removes all elements from the immutable sorted set. |
![]() | Contains | Determines whether this immutable sorted set contains the specified value. |
![]() | Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) |
![]() | Except | Removes a specified set of items from this immutable sorted set. |
![]() | GetEnumerator | Returns an enumerator that iterates through the immutable sorted set. |
![]() | GetHashCode | Serves as the default hash function. (Inherited from Object.) |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | IndexOf | Gets the position within this immutable sorted set that the specified value appears in. |
![]() | Intersect | Creates an immutable sorted set that contains elements that exist both in this set and in the specified set. |
![]() | IsProperSubsetOf | Determines whether the current immutable sorted set is a proper (strict) subset of the specified collection. |
![]() | IsProperSupersetOf | Determines whether the current immutable sorted set is a proper superset of a specified collection. |
![]() | IsSubsetOf | Determines whether the current immutable sorted set is a subset of a specified collection. |
![]() | IsSupersetOf | Determines whether the current immutable sorted set is a superset of a specified collection. |
![]() | Overlaps | Determines whether the current immutable sorted set and a specified collection share common elements. |
![]() | Remove | Removes the specified value from this immutable sorted set. |
![]() | Reverse | Returns an IEnumerable(T) that iterates over this immutable sorted set in reverse order. |
![]() | SetEquals | Determines whether the current immutable sorted set and the specified collection contain the same elements. |
![]() | SymmetricExcept | Creates an immutable sorted set that contains elements that exist either in this set or in a given sequence, but not both. |
![]() | ToBuilder | Creates a collection that has the same contents as this immutable sorted set that can be efficiently manipulated by using standard mutable interfaces. |
![]() | ToString | Returns a string that represents the current object. (Inherited from Object.) |
![]() | TryGetValue | Searches the set for a given value and returns the equal value it finds, if any. |
![]() | Union | Adds a given set of items to this immutable sorted set. |
![]() | WithComparer | Returns the immutable sorted set that has the specified key comparer. |
| Name | Description | |
|---|---|---|
![]() | ToImmutableArray(T) | [This topic is preliminary and is subject to change.] Creates an immutable array from the specified collection. (Defined by ImmutableArray.) |
![]() | ToImmutableDictionary(T, TKey)(Func(T, TKey)) | Overloaded. Constructs an immutable dictionary from an existing collection of elements, applying a transformation function to the source keys. (Defined by ImmutableDictionary.) |
![]() | ToImmutableDictionary(T, TKey)(Func(T, TKey), IEqualityComparer(TKey)) | Overloaded. Constructs an immutable dictionary based on some transformation of a sequence. (Defined by ImmutableDictionary.) |
![]() | ToImmutableDictionary(T, TKey, TValue)(Func(T, TKey), Func(T, TValue)) | Overloaded. Enumerates and transforms a sequence, and produces an immutable dictionary of its contents. (Defined by ImmutableDictionary.) |
![]() | ToImmutableDictionary(T, TKey, TValue)(Func(T, TKey), Func(T, TValue), IEqualityComparer(TKey)) | Overloaded. Enumerates and transforms a sequence, and produces an immutable dictionary of its contents by using the specified key comparer. (Defined by ImmutableDictionary.) |
![]() | ToImmutableDictionary(T, TKey, TValue)(Func(T, TKey), Func(T, TValue), IEqualityComparer(TKey), IEqualityComparer(TValue)) | Overloaded. Enumerates and transforms a sequence, and produces an immutable dictionary of its contents by using the specified key and value comparers. (Defined by ImmutableDictionary.) |
![]() | ToImmutableHashSet(T)() | Overloaded. Enumerates a sequence and produces an immutable hash set of its contents. (Defined by ImmutableHashSet.) |
![]() | ToImmutableHashSet(T)(IEqualityComparer(T)) | Overloaded. Enumerates a sequence, produces an immutable hash set of its contents, and uses the specified equality comparer for the set type. (Defined by ImmutableHashSet.) |
![]() | ToImmutableList(T) | Enumerates a sequence and produces an immutable list of its contents. (Defined by ImmutableList.) |
![]() | ToImmutableSortedDictionary(T, TKey, TValue)(Func(T, TKey), Func(T, TValue)) | Overloaded. Enumerates and transforms a sequence, and produces an immutable sorted dictionary of its contents. (Defined by ImmutableSortedDictionary.) |
![]() | ToImmutableSortedDictionary(T, TKey, TValue)(Func(T, TKey), Func(T, TValue), IComparer(TKey)) | Overloaded. Enumerates and transforms a sequence, and produces an immutable sorted dictionary of its contents by using the specified key comparer. (Defined by ImmutableSortedDictionary.) |
![]() | ToImmutableSortedDictionary(T, TKey, TValue)(Func(T, TKey), Func(T, TValue), IComparer(TKey), IEqualityComparer(TValue)) | Overloaded. Enumerates and transforms a sequence, and produces an immutable sorted dictionary of its contents by using the specified key and value comparers. (Defined by ImmutableSortedDictionary.) |
![]() | ToImmutableSortedSet(T)() | Overloaded. Enumerates a sequence and produces an immutable sorted set of its contents. (Defined by ImmutableSortedSet.) |
![]() | ToImmutableSortedSet(T)(IComparer(T)) | Overloaded. Enumerates a sequence, produces an immutable sorted set of its contents, and uses the specified comparer. (Defined by ImmutableSortedSet.) |
| Name | Description | |
|---|---|---|
![]() ![]() | ICollection(T).Add | Adds the specified value to the collection. |
![]() ![]() | ISet(T).Add | Adds an element to the current set and returns a value to indicate if the element was successfully added. |
![]() ![]() | IList.Add | Adds an item to the set. |
![]() ![]() | ICollection(T).Clear | Removes all the items from the collection. |
![]() ![]() | IList.Clear | Removes all items from the set. |
![]() ![]() | IList.Contains | Determines whether the set contains a specific value. |
![]() ![]() | ICollection(T).CopyTo | Copies the elements of the collection to an array, starting at a particular array index. |
![]() ![]() | ICollection.CopyTo | Copies the elements of the set to an array, starting at a particular array index. |
![]() ![]() | ISet(T).ExceptWith | Removes all elements in the specified collection from the current set. |
![]() ![]() | IEnumerable(T).GetEnumerator | Returns an enumerator that iterates through the collection. |
![]() ![]() | IEnumerable.GetEnumerator | Returns an enumerator that iterates through a collection. |
![]() ![]() | IList.IndexOf | Determines the index of a specific item in the set. |
![]() ![]() | IList(T).Insert | Inserts an item in the set at the specified index.. |
![]() ![]() | IList.Insert | Inserts an item into the set at the specified index. |
![]() ![]() | ISet(T).IntersectWith | Modifies the current set so that it contains only elements that are also in a specified collection |
![]() ![]() | IList.IsFixedSize | Gets a value indicating whether the immutable sorted set has a fixed size. |
![]() ![]() | ICollection(T).IsReadOnly | Gets a value indicating whether the immutable sorted set is read-only. |
![]() ![]() | IList.IsReadOnly | Gets a value indicating whether the immutable sorted set is read-only. |
![]() ![]() | ICollection.IsSynchronized | Gets a value indicating whether access to the immutable sorted set is synchronized. |
![]() ![]() | IList(T).Item | Gets or sets the element at the specified index. |
![]() ![]() | IList.Item | Gets or sets the element at the specified index. |
![]() ![]() | ICollection(T).Remove | Removes the first occurrence of a specific object from the collection. |
![]() ![]() | IList.Remove | Removes the first occurrence of a specific object from the set. |
![]() ![]() | IList(T).RemoveAt | Removes the item at the specified index. |
![]() ![]() | IList.RemoveAt | Removes the item at the specified index of the set. |
![]() ![]() | ISet(T).SymmetricExceptWith | Modifies the current set so that it contains only elements that are present either in the current set or in the specified collection, but not both. |
![]() ![]() | ICollection.SyncRoot | Gets an object that can be used to synchronize access to the immutable sorted set. |
![]() ![]() | ISet(T).UnionWith | Modifies the current set so that it contains all elements that are present in either the current set or the specified collection. |
![]() ![]() | IImmutableSet(T).Add | Adds the specified element to this immutable set. |
![]() ![]() | IImmutableSet(T).Clear | Retrieves an empty immutable set that has the same sorting and ordering semantics as this instance. |
![]() ![]() | IImmutableSet(T).Except | Removes the elements in the specified collection from the current immutable set. |
![]() ![]() | IImmutableSet(T).Intersect | Creates an immutable set that contains elements that exist in both this set and the specified set. |
![]() ![]() | IImmutableSet(T).Remove | Removes the specified element from this immutable set. |
![]() ![]() | IImmutableSet(T).SymmetricExcept | Creates an immutable set that contains only elements that are present either in the current set or in the specified collection, but not both. |
![]() ![]() | IImmutableSet(T).Union | Creates a new immutable set that contains all elements that are present in either the current set or in the specified collection. |
Create a new immutable sorted set that is prepopulated with items by using the CreateRange method. When you manipulate an immutable set with methods such as Add, Reverse or Remove, a copy of the original sorted set is made, manipulations applied and a new immutable sorted set is returned.
If you need to perform multiple operations on an immutable collection, to increase efficiency you can copy the ImmutableSortedSet(T) to a ImmutableSortedSet(T).Builder, using the ToBuildermethod, manipulate the set and make it immutable again using the ToImmutable method. This will not change the original immutable sorted set.

