Struct EquatableArray<T>
Wraps an ImmutableArray<T> with element-wise content equality so records that contain it auto-generate correct equality. The default struct value normalizes to Empty for read operations.
public readonly struct EquatableArray<T> : IEquatable<EquatableArray<T>>, IReadOnlyList<T>, IReadOnlyCollection<T>, IEnumerable<T>, IEnumerable
Type Parameters
T
- Implements
-
IEnumerable<T>
- Inherited Members
Constructors
EquatableArray(ImmutableArray<T>)
Wrap an existing ImmutableArray<T>; default arrays normalize to Empty.
public EquatableArray(ImmutableArray<T> items)
Parameters
itemsImmutableArray<T>
Properties
Count
Gets the number of elements in the collection.
public int Count { get; }
Property Value
- int
The number of elements in the collection.
Empty
Empty array singleton.
public static EquatableArray<T> Empty { get; }
Property Value
this[int]
Gets the element at the specified index in the read-only list.
public T this[int index] { get; }
Parameters
indexintThe zero-based index of the element to get.
Property Value
- T
The element at the specified index in the read-only list.
Methods
AsImmutableArray()
Underlying ImmutableArray<T> (interop for callers expecting it).
public ImmutableArray<T> AsImmutableArray()
Returns
AsSpan()
Read-only span over the underlying buffer.
public ReadOnlySpan<T> AsSpan()
Returns
- ReadOnlySpan<T>
Equals(EquatableArray<T>)
Indicates whether the current object is equal to another object of the same type.
public bool Equals(EquatableArray<T> other)
Parameters
otherEquatableArray<T>An object to compare with this object.
Returns
Equals(object?)
Indicates whether this instance and a specified object are equal.
public override bool Equals(object? obj)
Parameters
objobjectThe object to compare with the current instance.
Returns
- bool
true if
objand this instance are the same type and represent the same value; otherwise, false.
GetEnumerator()
Struct enumerator (zero-allocation foreach).
public ImmutableArray<T>.Enumerator GetEnumerator()
Returns
GetHashCode()
Returns the hash code for this instance.
public override int GetHashCode()
Returns
- int
A 32-bit signed integer that is the hash code for this instance.
Operators
operator ==(EquatableArray<T>, EquatableArray<T>)
Equality operator.
public static bool operator ==(EquatableArray<T> left, EquatableArray<T> right)
Parameters
leftEquatableArray<T>rightEquatableArray<T>
Returns
implicit operator ReadOnlySpan<T>(EquatableArray<T>)
Implicit conversion to ReadOnlySpan<T>.
public static implicit operator ReadOnlySpan<T>(EquatableArray<T> items)
Parameters
itemsEquatableArray<T>
Returns
- ReadOnlySpan<T>
implicit operator EquatableArray<T>(ImmutableArray<T>)
Implicit conversion from ImmutableArray<T>.
public static implicit operator EquatableArray<T>(ImmutableArray<T> items)
Parameters
itemsImmutableArray<T>
Returns
operator !=(EquatableArray<T>, EquatableArray<T>)
Inequality operator.
public static bool operator !=(EquatableArray<T> left, EquatableArray<T> right)
Parameters
leftEquatableArray<T>rightEquatableArray<T>