Table of Contents

Struct EquatableArray<T>

Namespace
ModernLrc.Model
Assembly
ModernLrc.dll

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
Inherited Members

Constructors

EquatableArray(ImmutableArray<T>)

Wrap an existing ImmutableArray<T>; default arrays normalize to Empty.

public EquatableArray(ImmutableArray<T> items)

Parameters

items ImmutableArray<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

EquatableArray<T>

this[int]

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

public T this[int index] { get; }

Parameters

index int

The 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

ImmutableArray<T>

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

other EquatableArray<T>

An object to compare with this object.

Returns

bool

true if the current object is equal to the other parameter; otherwise, false.

Equals(object?)

Indicates whether this instance and a specified object are equal.

public override bool Equals(object? obj)

Parameters

obj object

The object to compare with the current instance.

Returns

bool

true if obj and 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

ImmutableArray<T>.Enumerator

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

left EquatableArray<T>
right EquatableArray<T>

Returns

bool

implicit operator ReadOnlySpan<T>(EquatableArray<T>)

Implicit conversion to ReadOnlySpan<T>.

public static implicit operator ReadOnlySpan<T>(EquatableArray<T> items)

Parameters

items EquatableArray<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

items ImmutableArray<T>

Returns

EquatableArray<T>

operator !=(EquatableArray<T>, EquatableArray<T>)

Inequality operator.

public static bool operator !=(EquatableArray<T> left, EquatableArray<T> right)

Parameters

left EquatableArray<T>
right EquatableArray<T>

Returns

bool