Class EquatableArray<T>
An immutable array wrapper that provides value-based equality semantics.
Namespace: Singulink.Collections
Assembly: Singulink.Collections.dll
Syntax
public sealed class EquatableArray<T> : IReadOnlyList<T>, IReadOnlyCollection<T>, IList<T>, ICollection<T>, IEnumerable<T>, IEnumerable, IEquatable<EquatableArray<T>>, IFormattable
Type Parameters
| Name | Description |
|---|---|
| T |
Remarks
Note: values of the array are assumed to be immutable and interchangeable (that is, the standard equality and hash code contracts must be held, but also must be consistent indefinitely, and the value you read out of the array is only guaranteed to be equal to the one passed in, not necessarily the same instance or bits).
Constructors
| Name | Description |
|---|---|
| EquatableArray(ImmutableArray<T>) | Initializes a new instance of the EquatableArray<T> class from the given immutable array. |
Properties
| Name | Description |
|---|---|
| Empty | Gets the shared empty instance of the EquatableArray<T> class. |
| IsEmpty | Gets a value indicating whether the array is empty. |
| this[int] | Gets the element at the specified index in the equatable array. |
| Length | Gets a value indicating the number of elements in the array. |
| UnderlyingArray | Gets the underlying immutable array (note: the underlying array is not guaranteed to be the same instance, nor the values have the same instance or bits as what was originally passed in). |
Methods
| Name | Description |
|---|---|
| AsMemory() | Creates a new read-only memory region over this equatable array. |
| AsSpan() | Creates a new read-only span over this equatable array. |
| AsSpan(int, int) | Creates a new read-only span over the specified portion of this equatable array. |
| AsSpan(Range) | Creates a new read-only span over the specified portion of this equatable array. |
| Contains(T) | Determines whether the equatable array contains the specified item. |
| Contains(T, IEqualityComparer<T>?) | Determines whether the equatable array contains the specified item. |
| CopyTo(int, T[], int, int) | Copies the elements of the equatable array to the specified destination span. |
| CopyTo(Span<T>) | Copies the elements of the equatable array to the specified destination span. |
| CopyTo(T[]) | Copies the elements of the equatable array to the specified destination span. |
| CopyTo(T[], int) | Copies the elements of the equatable array to the specified destination span. |
| Equals(EquatableArray<T>?) | Determines whether the specified object is equal to the current object. |
| Equals(object?) | Determines whether the specified object is equal to the current object. |
| GetEnumerator() | Gets an enumerator for the equatable array. |
| GetHashCode() | Gets a hash code for the equatable array, which is based on value equality, and is cached. |
| IndexOf(T) | Returns the first index of the specified item in the equatable array, or -1 if not found. |
| IndexOf(T, IEqualityComparer<T>?) | Returns the first index of the specified item in the equatable array, or -1 if not found. |
| IndexOf(T, int) | Returns the first index of the specified item in the equatable array, or -1 if not found. |
| IndexOf(T, int, IEqualityComparer<T>?) | Returns the first index of the specified item in the equatable array, or -1 if not found. |
| IndexOf(T, int, int) | Returns the first index of the specified item in the equatable array, or -1 if not found. |
| IndexOf(T, int, int, IEqualityComparer<T>?) | Returns the first index of the specified item in the equatable array, or -1 if not found. |
| LastIndexOf(T) | Returns the last index of the specified item in the equatable array, or -1 if not found. |
| LastIndexOf(T, IEqualityComparer<T>?) | Returns the last index of the specified item in the equatable array, or -1 if not found. |
| LastIndexOf(T, int) | Returns the last index of the specified item in the equatable array, or -1 if not found. |
| LastIndexOf(T, int, IEqualityComparer<T>?) | Returns the last index of the specified item in the equatable array, or -1 if not found. |
| LastIndexOf(T, int, int) | Returns the last index of the specified item in the equatable array, or -1 if not found. |
| LastIndexOf(T, int, int, IEqualityComparer<T>?) | Returns the last index of the specified item in the equatable array, or -1 if not found. |
| Slice(int, int) | Creates a slice of the equatable array from the specified start index with the specified length. |
| ToString() | Returns a string that represents the current object. |
| ToString(IFormatProvider?) | Formats the value of the current instance using the specified format. |
| ToString(string?) | Formats the value of the current instance using the specified format. |
| ToString(string?, IFormatProvider?) | Formats the value of the current instance using the specified format. |
Operators
| Name | Description |
|---|---|
| operator ==(EquatableArray<T>?, EquatableArray<T>?) | Value-based equality operator. |
| operator !=(EquatableArray<T>?, EquatableArray<T>?) | Value-based inequality operator. |
Explicit Interface Implementations
| Name | Description |
|---|---|
| ICollection<T>.Add(T) | Adds an item to the ICollection<T>. |
| ICollection<T>.Clear() | Removes all items from the ICollection<T>. |
| ICollection<T>.CopyTo(T[], int) | Copies the elements of the ICollection<T> to an Array, starting at a particular Array index. |
| ICollection<T>.Count | Gets the number of elements contained in the ICollection<T>. |
| ICollection<T>.IsReadOnly | Gets a value indicating whether the ICollection<T> is read-only. |
| ICollection<T>.Remove(T) | Removes the first occurrence of a specific object from the ICollection<T>. |
| IEnumerable<T>.GetEnumerator() | Returns an enumerator that iterates through the collection. |
| IList<T>.Insert(int, T) | Inserts an item to the IList<T> at the specified index. |
| IList<T>.this[int] | Gets or sets the element at the specified index. |
| IList<T>.RemoveAt(int) | Removes the IList<T> item at the specified index. |
| IReadOnlyCollection<T>.Count | Gets the number of elements in the collection. |
| IReadOnlyList<T>.this[int] | Gets the element at the specified index in the read-only list. |
| IEnumerable.GetEnumerator() | Returns an enumerator that iterates through a collection. |
| IFormattable.ToString(string?, IFormatProvider?) | Formats the value of the current instance using the specified format. |