KeyedLists<TKey, T>

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

Constructors

KeyedLists

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

KeyedLists

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

Properties

DataCount

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

Items

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

KeyCount

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

Keys

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

KeysCached

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

Lists

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

Indexers

this[]

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

this[]

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

Methods

Add

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

AddRange

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

ContainsItem

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

ContainsKey

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

IndexOf

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

Indices

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

Indices

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

Insert

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

InsertRange

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

Reassign

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

Remove

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

RemoveAt

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

RemoveEmptyLists

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

RemoveRange

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

RemoveShortLists

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

TrimExcess

#
public void TrimExcess()
Shrink all lists.