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

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

Properties

Count

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

Items

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

Indexers

this[]

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

this[]

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

Methods

Add

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

AddRange

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

Contains

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

Remove

#
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.
public bool Remove(
T
instance
Instance to remove.
)

RemoveName

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

Replace

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

TryFind

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