NamedList<T>

[DebuggerDisplay("items:{Count}")] public class NamedList<T>
An immutable list of values which have names. Note that eventhrough the collection itself is immutable, the values it contains may not be.
T

Constructors

NamedList

#
public NamedList(Func<T, Name> getName)
Create a new, empty keyed list.
getName (Func<T, Name>)T -> Name method.

Properties

Count

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

Items

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

Indexers

this[]

#
public T this[int index] { get; }
Gets the instance at the given index.
index (int)Index of item to retrieve.
Instance at index.

this[]

#
public T this[Name name] { get; }
Gets the instance (if any) with the given name.
name (Name)Name to search for.
Instance with name or default(T).

Methods

Add

#
public void Add(T instance)
Add a new instance to this collection. This method will throw in case of a name collision.
instance (T)Instance to add.

AddRange

#
public void AddRange(List<T> instances)
Add new instances to this collection. This method will throw in case of a name collision.
instances (List<T>)Instances to add.

Contains

#
public bool Contains(Name name)
Test whether a specific name has already been defined.
name (Name)Name.
True if the name has been defined.

Remove

#
public bool Remove(T instance)
Remove a specific instance from this collection. Note, the instance must be part of this collection, it is not enough for the instance key to be present.
instance (T)Instance to remove.

RemoveName

#
public bool RemoveName(Name name)
Remove a specific Name+T pair from this collection.
name (Name)

Replace

#
public void Replace(T instance)
Replace an item.
instance (T)New value.

TryFind

#
public bool TryFind(Name name, out T instance)
Try and find the item with the given name.
name (Name)Name to search for.
instance (out T)Found instance.
True if item was found.