Table of Contents

Class UniqueNodesManager<T, TKey>

A dictionary-backed INodeManager<T> that groups nodes by a computed key of type TKey. Multiple nodes may share the same key.

public class UniqueNodesManager<T, TKey> : INodeManager<T>

Type Parameters

T

The node data type.

TKey

The grouping key type derived from each node's data.

Inheritance
UniqueNodesManager<T, TKey>
Implements
Inherited Members

Constructors

UniqueNodesManager(Func<T, TKey>)

public UniqueNodesManager(Func<T, TKey> keySelector)

Parameters

keySelector Func<T, TKey>

A delegate that extracts the grouping key from a node's data value.

Methods

AddNode(NodeController<T>)

Adds a node to the collection. Returns true on success.

public bool AddNode(NodeController<T> node)

Parameters

node NodeController<T>

Returns

bool

Clear()

Removes all nodes and disposes each one.

public void Clear()

FromJson(string)

Deserialises and replaces the collection from a JSON string.

public virtual void FromJson(string json)

Parameters

json string

GetAllNodes()

Returns an enumerable of all nodes currently in the collection.

public IEnumerable<NodeController<T>> GetAllNodes()

Returns

IEnumerable<NodeController<T>>

GetNode(Func<T, bool>)

Returns the first node value that satisfies predicate, or default.

public virtual T GetNode(Func<T, bool> predicate)

Parameters

predicate Func<T, bool>

Returns

T

RemoveNode(NodeController<T>)

Removes a node from the collection. Returns true on success.

public bool RemoveNode(NodeController<T> node)

Parameters

node NodeController<T>

Returns

bool

RemoveWhere(Func<T, bool>)

Removes all nodes whose data satisfies predicate.

public void RemoveWhere(Func<T, bool> predicate)

Parameters

predicate Func<T, bool>

ToJson()

Serialises the collection to a JSON string.

public virtual string ToJson()

Returns

string