KeyedLists<TKey, T>

public sealed class KeyedLists<TKey, T>
Represents a palette of keyed lists.
TKeyKey type.
TList type.

Constructors

KeyedLists

#
Create a new instance of this class with a default comparer.
public KeyedLists()

KeyedLists

#
Create a new instance of this class with a custom comparer.
public KeyedLists(
comparer
)

Properties

DataCount

#
Gets the total number of items stored in all lists.
public int DataCount { get; }

Items

#
Iterate over all items in all lists.
public IEnumerable<T> Items { get; }

KeyCount

#
Gets the number of keyed lists stored in this structure.
public int KeyCount { get; }

Keys

#
Iterate over all keys.
public IEnumerable<TKey> Keys { get; }
An iterator for all keys.

KeysCached

#
Iterate over all keys. Use this iterator if you wish to add or remove keys to or from this collection while iterating.
public IEnumerable<TKey> KeysCached { get; }

Lists

#
Iterate over all lists.
public IEnumerable<List<T>> Lists { get; }
An iterator for all lists.

Indexers

this[]

#
Gets the list associated with the given key.
public List<T> this[
TKey
key
Key of list to access.
] { get; }
List at given key.

this[]

#
Gets the item associated with the given key and index.
public T this[
TKey
key,
Key of list to access.
index
Index within list to access.
] { get; }
Item at given index or key.

Methods

Add

#
Add an item to the correct list.
public void Add(
TKey
key,
Associated key.
T
item
Item to add.
)

AddRange

#
Add an item to the correct list.
public void AddRange(
TKey
key,
Associated key.
items
Items to add.
)

ContainsItem

#
Gets whether a given key + index is defined within this structure.
public bool ContainsItem(
TKey
key,
Key to test for.
index
Index to test for.
)
True if key and index exists.

ContainsKey

#
Gets whether a given key is defined within this structure.
public bool ContainsKey(
TKey
key
Key to test for.
)
True if key exists.

IndexOf

#
Finds the first occurance of a specific value.
public bool IndexOf(
T
value,
Value to search for.
out TKey
key,
Key at which value is found.
out int
index
Index at which value is found.
)
True on success, false on failure.

Indices

#
Iterates over all items which match a given predicate.
public IEnumerable<Tuple<TKey, int>> Indices(
match
Matching delegate.
)

Indices

#
Iterates over all items which are equal to the given value.
public IEnumerable<Tuple<TKey, int>> Indices(
T
value
Value to search for.
)

Insert

#
Add an item to the correct list.
public void Insert(
TKey
key,
Associated key.
index,
Index for insertion.
T
item
Item to add.
)

InsertRange

#
Add an item to the correct list.
public void InsertRange(
TKey
key,
Associated key.
index,
Index for insertion.
items
Items to add.
)

Reassign

#
Reassign a key. If the new key is already part of the palette, the lists will be merged.
public void Reassign(
TKey
oldKey,
Key to replace.
TKey
newKey
Key to replace with.
)

Remove

#
Remove a key and list pair from this collection.
public void Remove(
TKey
key
Key to remove.
)

RemoveAt

#
Remove an item from the correct list.
public void RemoveAt(
TKey
key,
Associated key.
index
Index for removal.
)

RemoveEmptyLists

#
Remove all empty list and key pairs.
public void RemoveEmptyLists()

RemoveRange

#
Remove items from the correct list.
public void RemoveRange(
TKey
key,
Associated key.
index,
Index for removal.
count
Number of items to remove.
)

RemoveShortLists

#
Remove all list which are shorter than some given threshold.
public void RemoveShortLists(
threshold
Threshold. Lists shorter than or equal to the threshold will be removed.
)

TrimExcess

#
Shrink all lists.
public void TrimExcess()