Class EquatableArray<T>
Represents an immutable array with 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
The values in the array are assumed to be immutable and interchangeable. Equal values must stay equal and keep the same hash code indefinitely, and a value read from the array is only guaranteed to be equal to the one that was passed in, not to be the same instance.
Constructors
| Name | Description |
|---|---|
| EquatableArray(ImmutableArray<T>) | Initializes a new instance of the EquatableArray<T> class that wraps the specified 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 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 range 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 a range of elements of the equatable array to the specified destination array. |
| 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 array. |
| CopyTo(T[], int) | Copies the elements of the equatable array to the specified destination array starting at the specified index of the destination. |
| 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?) | Returns a string representation of the array using the specified format provider to format its elements. |
| ToString(string?) | Returns a string representation of the array using the specified format to format its elements. |
| ToString(string?, IFormatProvider?) | Returns a string representation of the array using the specified format and format provider to format its elements. |
Operators
| Name | Description |
|---|---|
| operator ==(EquatableArray<T>?, EquatableArray<T>?) | Determines whether two arrays are equal. |
| operator !=(EquatableArray<T>?, EquatableArray<T>?) | Determines whether two arrays are not equal. |
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. |