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

#
public IndexTable()
Create a new empty table.

IndexTable

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

Properties

All

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

AllPairs

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

Count

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

HighestNegativeUnusedIndex

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

LowestPositiveUnusedIndex

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

Indexers

this[]

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

Methods

Contains

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

Restore

#
public void Restore(IReader reader, Func<IReader, T> restoreT)
Restore a collection from an archive.
reader (IReader)Reader object.
restoreT (Func<IReader, T>)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

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

SetIfBlank

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

SetOrOverwrite

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

Store

#
public void Store(IWriter writer, Action<IWriter, T> storeT)
Store this collection.
writer (IWriter)Writer object.
storeT (Action<IWriter, T>)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

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

Wipe

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

WipeAll

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