IndexTable<T>

public sealed class IndexTable<T>
Maintains a set of values with unique integer indices (both negative and positive). Each index may be associated with one, and only one, value. This collection has O(1) lookup but expensive addition. Also, it will reserve memory for all potential entries between min(0, minimum index) and max(0, maximum index), so to conserve memory you should keep the used indices as small as possible. This collection is not threadsafe.
T

Constructors

IndexTable

#
Create a new empty table.
public IndexTable()

IndexTable

#
Create a new table initialised for a specific size.
public IndexTable(
initialLowest,
Expected minimum index.
initialHighest
Expected maximum index.
)

Properties

All

#
Enumerate over all values, starting with the most negative index.
public IEnumerable<T> All { get; }

AllPairs

#
Enumerate over all values and index pairs, starting with the most negative index.
public IEnumerable<KeyValuePair<int, T>> AllPairs { get; }

Count

#
Gets the number of defined values.
public int Count { get; }

HighestNegativeUnusedIndex

#
Gets the highest negative index which hasn't been assigned yet.
public int HighestNegativeUnusedIndex { get; }

LowestPositiveUnusedIndex

#
Gets the lowest positive index which hasn't been assigned yet.
public int LowestPositiveUnusedIndex { get; }

Indexers

this[]

#
Gets the value at the given index. If the index doesn't exist, default(T) is returned.
public T this[
index
] { get; }

Methods

Contains

#
Gets whether the specific index has been set.
public bool Contains(
index
)

Restore

#
Restore a collection from an archive.
public void Restore(
reader,
Reader object.
restoreT
Deserialisation delegate. Not required for most primitive types such as IndexTable{bool}, IndexTable{int}, IndexTable{string} etc. Also if T is an IStorable type, a method is not required.
)

Set

#
Set the value at the given index. If the index is already taken, an exception will be thrown.
public void Set(
index,
T
value
)

SetIfBlank

#
Set the value at the given index. If the index is already taken, the new value will not be assigned.
public void SetIfBlank(
index,
T
value
)

SetOrOverwrite

#
Set the value at the given index. If the index is already taken, the old value will be overwritten.
public void SetOrOverwrite(
index,
T
value
)

Store

#
Store this collection.
public void Store(
writer,
Writer object.
storeT
Serialisation delegate. Not required for most primitive types such as IndexTable{bool}, IndexTable{int}, IndexTable{string} etc. Also if T is an IStorable type, a method is not required.
)

TrimExcess

#
Remove the unneccessary memory allocations of this collection.
public void TrimExcess()

Wipe

#
Wipe a given index and value pair.
public void Wipe(
index
)

WipeAll

#
Wipe all index and value pairs.
public void WipeAll()