StackedArray<T>

public sealed class StackedArray<T> : IEnumerable<T>
Provides an immutable array-like collection optimised for frequent identical consecutive elements.
T

Constructors

StackedArray

#
public StackedArray()
Create a new, empty stacked array.

StackedArray

#
public StackedArray(IEnumerable<T> values, Func<T, T, bool> comparer)
Create a new stacked array from a collection of values, using a custom comparer.
values (IEnumerable<T>)Value.
comparer (Func<T, T, bool>)Comparison delegate.

StackedArray

#
public StackedArray(IEnumerable<T> values, IComparer<T> comparer)
Create a new stacked array from a collection of values, using a custom comparer.
values (IEnumerable<T>)Value.
comparer (IComparer<T>)Comparer to use.

StackedArray

#
public StackedArray(IEnumerable<T> values, IEnumerable<int> valence)
Create a new stacked array from pre-existing value and valence collections.
values (IEnumerable<T>)Collection of values. Consecutive duplicates will not be filtered.
valence (IEnumerable<int>)Collection of valences. Must be the same size as the values collection.

StackedArray

#
public StackedArray(IEnumerable<T> values)
Create a new stacked array from a collection of values, using the default comparer.
values (IEnumerable<T>)

Properties

Count

#
public int Count { get; }
Gets the number of actual distinct values stored in this stacked array.

ImpliedCount

#
public long ImpliedCount { get; }
Gets the total length of all implied items in this stacked array.

Indexers

this[]

#
public T this[long index] { get; }
Gets the implied value (adjusted for accumulated valence) at the given index.
index (long)Implied index.
Value at implied index.

Methods

GetEnumerator

#
public IEnumerator<T> GetEnumerator()
Returns an enumerator that iterates through the collection of implied values.
An enumerator that can be used to iterate through the collection.

ImpliedValue

#
public T ImpliedValue(long index)
Gets the implied value (adjusted for accumulated valence) at the given index.
index (long)Implied index.
Value at implied index.
Explicit

IEnumerable.GetEnumerator

#
IEnumerator IEnumerable.GetEnumerator()
Returns an enumerator that iterates through the collection of implied values.
An IEnumerator object that can be used to iterate through the collection.

Valence

#
public int Valence(int index)
Gets the valence of the value at the given index.
index (int)Index of value to retrieve.
Valence of value at index.

Value

#
public T Value(int index)
Gets the value at the given index.
index (int)Index of value to retrieve.
Value at index.