Subset<T>

public sealed class Subset<T> : IEnumerable<T>
Create a subset indexer for arrays.
T

Constructors

Subset

#
public Subset(T[] array, int[] indices)
Create a new subset.
array (T[])Base array.
indices (int[])Indices in subset. This array will be sorted, so do not expect it to be in the same state after calling this constructor.

Properties

Array

#
public T[] Array { get; }
Gets the underlying array.

Indices

#
public IReadOnlyList<int> Indices { get; }
Gets the subset indices.

Length

#
public int Length { get; }
Gets the length of the subset.

SubsetItems

#
public IEnumerable<T> SubsetItems { get; }
Enumerate over all items in the array subset.

Indexers

this[]

#
public T this[int index] { get; }
Gets the array item at the given subset index.
index (int)Subset index.
Array item at Subset[index].

Methods

ArrayIndex

#
public int ArrayIndex(int subsetIndex)
Gets the array index associated with the given subset index.
subsetIndex (int)

GetEnumerator

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

IsPartOfSubset

#
public bool IsPartOfSubset(int arrayIndex)
Test whether the array index is covered by the subset map.
arrayIndex (int)Array index to test.
True if index is included in the subset.

SubsetIndex

#
public int SubsetIndex(int arrayIndex)
Gets the subset index associated with the given array index.
arrayIndex (int)
Explicit

IEnumerable.GetEnumerator

#
IEnumerator IEnumerable.GetEnumerator()