IdList<T>

public sealed class IdList<T>
A fast dictionary for objects with GUID keys. This type differs from Dictionary(Guid, T) by sacrificing memory for lookup performance. Adding entries may be slower and require more allocations, however finding entries ought to be slightly faster. This collection is not thread-safe and any modifying calls must be made from within a lock statement.
T

Constructors

IdList

#
Create a new, empty collection.
public IdList(
Func<T, Guid>
keyGenerator
)

Properties

Count

#
Gets the number of objects stored in this collection.
public int Count { get; }

Values

#
Enumerate over all instances of T stored in this collection
public IEnumerable<T> Values { get; }

Methods

Add

#
Add a new instance to this collection. If another instance with the same ID is already part of this collection, nothing will happen.
public void Add(
T
instance
Instance to add.
)

Clear

#
Clear all values.
public void Clear()

Contains

#
Test whether a given key exists within this collection.
public bool Contains(
id
)

Contains

#
Test whether an instance with the same GUID as the argument exists within this collection.
public bool Contains(
T
instance
)

Find

#
Retrieve the instance which matches the ID.
public bool Find(
id,
ID key to search for.
out T
instance
Instance associated with id, if any.
)
True if an instance was found.

Remove

#
Remove the instance which is associated with the given ID.
public bool Remove(
id
)

Remove

#
Remove the instance with an ID which matches the supplied instance.
public bool Remove(
T
instance
)

Set

#
Add a new instance to this collection. Any existing instance with a matching key will be overwritten.
public void Set(
T
instance
Instance to add.
)

ToArray

#
Convert this list into an array.
public T[] ToArray()

Update

#
Update a value at an old ID. This may be necessary if a value stored inside this collection has mutated and now resolves to a different ID.
public bool Update(
oldId
Old id to look at.
)