Table of Contents

Class EquatableArray<T>

Namespace
Backdash.Data
Assembly
Backdash.dll

An IEquatable<T> array with O(1) indexable lookup time

public sealed class EquatableArray<T> : IReadOnlyList<T>, IReadOnlyCollection<T>, IEnumerable<T>, IEnumerable, IEquatable<EquatableArray<T>>, IEqualityOperators<EquatableArray<T>, EquatableArray<T>, bool> where T : IEquatable<T>

Type Parameters

T

The type of element that implements IEquatable<T> stored by the array.

Inheritance
EquatableArray<T>
Implements
Inherited Members

Constructors

EquatableArray()

Initializes an empty new instance of the EquatableArray<T>.

public EquatableArray()

EquatableArray(int)

Initializes a new instance of the EquatableArray<T> class of size size.

public EquatableArray(int size)

Parameters

size int

Array capacity

EquatableArray(T[])

An IEquatable<T> array with O(1) indexable lookup time

public EquatableArray(T[] values)

Parameters

values T[]

Fields

Empty

Returns an empty EquatableArray<T>.

public static readonly EquatableArray<T> Empty

Field Value

EquatableArray<T>

Properties

IsEmpty

Returns a value that indicates whether the current EquatableArray<T> is empty.

public bool IsEmpty { get; }

Property Value

bool

this[Index]

Returns a reference to specified element at index of the EquatableArray<T>.

public ref T this[Index index] { get; }

Parameters

index Index

array index

Property Value

T

this[int]

Returns a reference to specified element of the EquatableArray<T>.

public ref T this[int index] { get; }

Parameters

index int

array index

Property Value

T

this[Range]

Returns a rage slice as a copy of the current EquatableArray<T>

public EquatableArray<T> this[Range range] { get; }

Parameters

range Range

Property Value

EquatableArray<T>

Length

Gets the total number of elements in all the dimensions of the EquatableArray<T>.

public int Length { get; }

Property Value

int

Methods

AsArray()

Returns the internal array of the current EquatableArray<T>.

public T[] AsArray()

Returns

T[]

AsMemory()

public Memory<T> AsMemory()

Returns

Memory<T>

AsReadOnly()

Returns a read-only IReadOnlyList<T> wrapper for the current EquatableArray<T>.

public IReadOnlyList<T> AsReadOnly()

Returns

IReadOnlyList<T>

AsSpan()

public Span<T> AsSpan()

Returns

Span<T>

Clear()

Sets all elements in an array to the default value of each element type.

public void Clear()

Clear(int, int)

public void Clear(int index, int length)

Parameters

index int
length int

Clear(Range)

Sets a range of elements in an array to the default value of each element type.

public void Clear(Range range)

Parameters

range Range

Slice to be clean

Clone()

Create new array with same values

public EquatableArray<T> Clone()

Returns

EquatableArray<T>

CopyTo(EquatableArray<T>)

Copies the contents of the EquatableArray<T> into another EquatableArray<T>.

public void CopyTo(EquatableArray<T> destination)

Parameters

destination EquatableArray<T>

CopyTo(Memory<T>)

public void CopyTo(Memory<T> destination)

Parameters

destination Memory<T>

CopyTo(Span<T>)

public void CopyTo(Span<T> destination)

Parameters

destination Span<T>

Equals(EquatableArray<T>?)

public bool Equals(EquatableArray<T>? other)

Parameters

other EquatableArray<T>

Returns

bool

Equals(object?)

public override bool Equals(object? obj)

Parameters

obj object

Returns

bool

Exist(Predicate<T>)

Determines whether the specified array contains elements that match the conditions defined by the specified predicate.

public bool Exist(Predicate<T> predicate)

Parameters

predicate Predicate<T>

Returns

bool

Fill(Func<T>)

Assigns the given return value from delegate of type T to each element of the specified array.

public void Fill(Func<T> value)

Parameters

value Func<T>

Fill(T)

Assigns the given value of type T to each element of the specified array.

public void Fill(T value)

Parameters

value T

Find(Predicate<T>)

Searches for an element that matches the conditions defined by the specified predicate, and returns the first occurrence within the entire Array.

public T? Find(Predicate<T> predicate)

Parameters

predicate Predicate<T>

Returns

T

FindAll(Predicate<T>)

Filters an array of values based on a predicate.

public EquatableArray<T> FindAll(Predicate<T> predicate)

Parameters

predicate Predicate<T>

Returns

EquatableArray<T>

FindIndex(Predicate<T>)

Searches for an element that matches the conditions defined by the specified predicate, and returns the zero-based index of the first occurrence within the entire Array.

public int FindIndex(Predicate<T> predicate)

Parameters

predicate Predicate<T>

Returns

int

FindLast(Predicate<T>)

Searches for an element that matches the conditions defined by the specified predicate, and returns the last occurrence within the entire Array.

public T? FindLast(Predicate<T> predicate)

Parameters

predicate Predicate<T>

Returns

T

FindLastIndex(Predicate<T>)

Searches for an element that matches the conditions defined by the specified predicate, and returns the zero-based index of the last occurrence within the entire Array.

public int FindLastIndex(Predicate<T> predicate)

Parameters

predicate Predicate<T>

Returns

int

GetEnumerator()

public EquatableArray<T>.Enumerator GetEnumerator()

Returns

EquatableArray<T>.Enumerator

GetHashCode()

public override int GetHashCode()

Returns

int

Map<TOutput>(Func<T, TOutput>)

Projects each element of the array on a new array

public EquatableArray<TOutput> Map<TOutput>(Func<T, TOutput> projection) where TOutput : IEquatable<TOutput>

Parameters

projection Func<T, TOutput>

Returns

EquatableArray<TOutput>

Type Parameters

TOutput

Resize(int)

Changes the number of elements of a one-dimensional array to the specified new size.

public void Resize(int newSize)

Parameters

newSize int

Reverse()

Reverses the sequence of the elements in the one-dimensional generic array.

public void Reverse()

Reverse(int, int)

Reverses the sequence of a subset of the elements in the one-dimensional generic array.

public void Reverse(int index, int length)

Parameters

index int
length int

Reverse(Range)

Reverses the sequence of a subset of the elements in the one-dimensional generic array.

public void Reverse(Range range)

Parameters

range Range

Slice(int, int)

Forms a new Array for the slice out of the current span starting at a specified index for a specified length.

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

Parameters

start int
length int

Returns

EquatableArray<T>

Sort(IComparer<T>?)

Sorts the elements of an array in ascending order.

public void Sort(IComparer<T>? comparer = null)

Parameters

comparer IComparer<T>

Sort(int, int, IComparer<T>?)

Sorts the elements in a range of elements in an Array

public void Sort(int index, int length, IComparer<T>? comparer = null)

Parameters

index int
length int
comparer IComparer<T>

Sort(Range, IComparer<T>?)

Sorts the elements in a range of elements in an Array

public void Sort(Range range, IComparer<T>? comparer = null)

Parameters

range Range
comparer IComparer<T>

SortBy<TKey>(Func<T, TKey>, IComparer<TKey>?)

Sorts the elements of an array in ascending order according to a key.

public void SortBy<TKey>(Func<T, TKey> selector, IComparer<TKey>? comparer = null) where TKey : IComparable<TKey>

Parameters

selector Func<T, TKey>
comparer IComparer<TKey>

Type Parameters

TKey

ToResized(int)

Crates new array with new size copying elements from source

public EquatableArray<T> ToResized(int newSize)

Parameters

newSize int

Returns

EquatableArray<T>

ToSorted(IComparer<T>?)

Sorts the elements of an array in ascending order into a new array.

public EquatableArray<T> ToSorted(IComparer<T>? comparer = null)

Parameters

comparer IComparer<T>

Returns

EquatableArray<T>

ToSorted(int, int, IComparer<T>?)

Sorts the elements in a range of elements in an Array into a new array

public EquatableArray<T> ToSorted(int index, int length, IComparer<T>? comparer = null)

Parameters

index int
length int
comparer IComparer<T>

Returns

EquatableArray<T>

ToSorted(Range, IComparer<T>?)

Sorts the elements in a range of elements in an Array into a new array

public EquatableArray<T> ToSorted(Range range, IComparer<T>? comparer = null)

Parameters

range Range
comparer IComparer<T>

Returns

EquatableArray<T>

ToSortedBy<TKey>(Func<T, TKey>, IComparer<TKey>?)

Sorts the elements of an array in ascending order according to a key.

public EquatableArray<T> ToSortedBy<TKey>(Func<T, TKey> selector, IComparer<TKey>? comparer = null) where TKey : IComparable<TKey>

Parameters

selector Func<T, TKey>
comparer IComparer<TKey>

Returns

EquatableArray<T>

Type Parameters

TKey

ToString()

public override string ToString()

Returns

string

Operators

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

public static implicit operator Memory<T>(EquatableArray<T> equatableArray)

Parameters

equatableArray EquatableArray<T>

Returns

Memory<T>

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

Returns a read-only IReadOnlyList<T> wrapper for the current EquatableArray<T>.

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

Parameters

equatableArray EquatableArray<T>

Returns

ReadOnlySpan<T>

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

public static implicit operator Span<T>(EquatableArray<T> equatableArray)

Parameters

equatableArray EquatableArray<T>

Returns

Span<T>

implicit operator T[](EquatableArray<T>)

Returns the internal array of the current EquatableArray<T>.

public static implicit operator T[](EquatableArray<T> equatableArray)

Parameters

equatableArray EquatableArray<T>

Returns

T[]

Explicit Interface Implementations

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

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

Parameters

left EquatableArray<T>
right EquatableArray<T>

Returns

bool

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

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

Parameters

left EquatableArray<T>
right EquatableArray<T>

Returns

bool