System.Collections.Immutable by Microsoft

<PackageReference Include="System.Collections.Immutable" Version="7.0.0-preview.6.22324.4" />

.NET API 197,248 bytes

 ImmutableArray<T>

Represents an array that is immutable; meaning it cannot be changed once it is created. NuGet package: System.Collections.Immutable (about immutable collections and how to install)
public sealed class Builder<T> : IList<T>, ICollection<T>, IEnumerable<T>, IEnumerable, IReadOnlyList<T>, IReadOnlyCollection<T>

A writable array accessor that can be converted into an ImmutableArray<T> instance without allocating extra memory. NuGet package: System.Collections.Immutable (about immutable collections and how to install)

public struct Enumerator<T>

An array enumerator. NuGet package: System.Collections.Immutable (about immutable collections and how to install)

public static readonly ImmutableArray<T> Empty

Gets an empty immutable array.

public bool IsDefault { get; }

Gets a value indicating whether this array was declared but not initialized.

public bool IsDefaultOrEmpty { get; }

Gets a value indicating whether this ImmutableArray<T> is empty or is not initialized.

public bool IsEmpty { get; }

Gets a value indicating whether this ImmutableArray<T> is empty.

public T this[int index] { get; }

Gets the element at the specified index in the immutable array.

public int Length { get; }

Gets the number of elements in the array.

public static ImmutableArray<T> CastUp<TDerived>(ImmutableArray<TDerived> items) where TDerived : T

Initializes a new instance of the ImmutableArray<T> struct based on the contents of an existing instance, allowing a covariant static cast to efficiently reuse the existing array.

public static bool op_Equality(ImmutableArray<T> left, ImmutableArray<T> right)

Returns a value that indicates if two arrays are equal.

public static bool op_Equality(ImmutableArray<T>? left, ImmutableArray<T>? right)

Returns a value that indicates if two arrays are equal.

public static bool op_Inequality(ImmutableArray<T> left, ImmutableArray<T> right)

Returns a value that indicates whether two arrays are not equal.

public static bool op_Inequality(ImmutableArray<T>? left, ImmutableArray<T>? right)

Checks for inequality between two array.

public ImmutableArray<T> Add(T item)

Returns a copy of the original array with the specified item added to the end.

public ImmutableArray<T> AddRange(IEnumerable<T> items)

Returns a copy of the original array with the specified elements added to the end of the array.

public ImmutableArray<T> AddRange(T[] items, int length)

public ImmutableArray<T> AddRange<TDerived>(TDerived[] items) where TDerived : T

public ImmutableArray<T> AddRange(ImmutableArray<T> items, int length)

public ImmutableArray<T> AddRange<TDerived>(ImmutableArray<TDerived> items) where TDerived : T

Returns a copy of the original array with the specified elements added to the end of the array.

public ImmutableArray<T> AddRange(ReadOnlySpan<T> items)

Adds the specified values to this list.

public ImmutableArray<T> AddRange(T[] items)

Adds the specified values to this list.

public ImmutableArray<TOther> As<TOther>()

Returns a new immutable array that contains the elements of this array cast to a different type.

Creates a new read-only memory region over this immutable array.

public ReadOnlySpan<T> AsSpan()

Creates a new read-only span over this immutable array.

public ReadOnlySpan<T> AsSpan(int start, int length)

Creates a ReadOnlySpan<T> over the portion of the current ImmutableArray<T>, beginning at a specified position for a specified length.

public ReadOnlySpan<T> AsSpan(Range range)

Creates a span over the portion of the current ImmutableArray<T> based on the specified range.

public ImmutableArray<TOther> CastArray<TOther>()

Initializes a new instance of the ImmutableArray<T> struct by casting the underlying array to an array of type TOther.

public ImmutableArray<T> Clear()

Returns an array with all the elements removed.

public bool Contains(T item)

Determines whether the specified item exists in the array.

public void CopyTo(Span<T> destination)

Copies the elements of current ImmutableArray<T> to a Span<T>.

public void CopyTo(T[] destination)

Copies the contents of this array to the specified array.

public void CopyTo(T[] destination, int destinationIndex)

Copies the contents of this array to the specified array starting at the specified destination index.

public void CopyTo(int sourceIndex, T[] destination, int destinationIndex, int length)

Copies the specified items in this array to the specified array at the specified starting index.

public bool Equals(ImmutableArray<T> other)

Indicates whether specified array is equal to this array.

Returns an enumerator that iterates through the contents of the array.

public int IndexOf(T item)

Searches the array for the specified item.

public int IndexOf(T item, int startIndex, IEqualityComparer<T> equalityComparer)

Searches the array for the specified item.

public int IndexOf(T item, int startIndex)

Searches the array for the specified item.

public int IndexOf(T item, int startIndex, int count)

Searches the array for the specified item.

public int IndexOf(T item, int startIndex, int count, IEqualityComparer<T> equalityComparer)

Searches the array for the specified item.

public ImmutableArray<T> Insert(int index, T item)

Returns a new array with the specified value inserted at the specified position.

public ImmutableArray<T> InsertRange(int index, IEnumerable<T> items)

Inserts the specified values at the specified index.

public ImmutableArray<T> InsertRange(int index, ImmutableArray<T> items)

Inserts the specified values at the specified index.

public ImmutableArray<T> InsertRange(int index, T[] items)

Inserts the specified values at the specified index.

public ImmutableArray<T> InsertRange(int index, ReadOnlySpan<T> items)

Inserts the specified values at the specified index.

public T& modreq(System.Runtime.InteropServices.InAttribute) ItemRef(int index)

Gets a read-only reference to the element at the specified index in the read-only list.

public int LastIndexOf(T item)

Searches the array for the specified item; starting at the end of the array.

public int LastIndexOf(T item, int startIndex)

Searches the array for the specified item; starting at the end of the array.

public int LastIndexOf(T item, int startIndex, int count)

Searches the array for the specified item; starting at the end of the array.

public int LastIndexOf(T item, int startIndex, int count, IEqualityComparer<T> equalityComparer)

Searches the array for the specified item; starting at the end of the array.

public IEnumerable<TResult> OfType<TResult>()

Filters the elements of this array to those assignable to the specified type.

public ImmutableArray<T> Remove(T item)

Returns an array with the first occurrence of the specified element removed from the array. If no match is found, the current array is returned.

public ImmutableArray<T> Remove(T item, IEqualityComparer<T> equalityComparer)

Returns an array with the first occurrence of the specified element removed from the array. If no match is found, the current array is returned.

public ImmutableArray<T> RemoveAll(Predicate<T> match)

Removes all the items from the array that meet the specified condition.

public ImmutableArray<T> RemoveAt(int index)

Returns an array with the element at the specified position removed.

public ImmutableArray<T> RemoveRange(int index, int length)

Returns an array with the elements at the specified position removed.

Removes the specified items from this array.

public ImmutableArray<T> RemoveRange(IEnumerable<T> items, IEqualityComparer<T> equalityComparer)

Removes the specified items from this array.

Removes the specified values from this list.

public ImmutableArray<T> RemoveRange(ImmutableArray<T> items, IEqualityComparer<T> equalityComparer)

Removes the specified items from this list.

public ImmutableArray<T> RemoveRange(ReadOnlySpan<T> items, IEqualityComparer<T> equalityComparer = null)

Removes the specified values from this list.

public ImmutableArray<T> RemoveRange(T[] items, IEqualityComparer<T> equalityComparer = null)

Removes the specified values from this list.

public ImmutableArray<T> Replace(T oldValue, T newValue)

Finds the first element in the array equal to the specified value and replaces the value with the specified new value.

public ImmutableArray<T> Replace(T oldValue, T newValue, IEqualityComparer<T> equalityComparer)

Finds the first element in the array equal to the specified value and replaces the value with the specified new value.

public ImmutableArray<T> SetItem(int index, T item)

Replaces the item at the specified index with the specified item.

public ImmutableArray<T> Slice(int start, int length)

Forms a slice out of the current ImmutableArray<T> starting at a specified index for a specified length.

public ImmutableArray<T> Sort()

Sorts the elements in the immutable array using the default comparer.

public ImmutableArray<T> Sort(Comparison<T> comparison)

Sorts the elements in the entire ImmutableArray<T> using the specified Comparison<T>.

public ImmutableArray<T> Sort(IComparer<T> comparer)

Sorts the elements in the immutable array using the specified comparer.

public ImmutableArray<T> Sort(int index, int count, IComparer<T> comparer)

Sorts the specified elements in the immutable array using the specified comparer.

public Builder<T> ToBuilder()

Creates a mutable array that has the same contents as this array and can be efficiently mutated across multiple operations using standard mutable interfaces.