Interface IReadOnlyTreeDictionary<TKey, TValue>
- Namespace
- LfrlAnvil.Collections
- Assembly
- LfrlAnvil.Collections.dll
Represents a generic read-only tree data structure with the ability to identify nodes by keys.
public interface IReadOnlyTreeDictionary<TKey, TValue> : IReadOnlyDictionary<TKey, TValue>, IReadOnlyCollection<KeyValuePair<TKey, TValue>>, IEnumerable<KeyValuePair<TKey, TValue>>, IEnumerable where TKey : notnull
Type Parameters
TKey
Key type.
TValue
Value type.
- Inherited Members
- Extension Methods
Properties
Comparer
Key equality comparer.
IEqualityComparer<TKey> Comparer { get; }
Property Value
- IEqualityComparer<TKey>
Nodes
Returns a new IEnumerable<T> instance that contains all nodes of this tree.
IEnumerable<ITreeDictionaryNode<TKey, TValue>> Nodes { get; }
Property Value
- IEnumerable<ITreeDictionaryNode<TKey, TValue>>
Root
Represents this tree's root node. Equal to null when the tree is empty.
ITreeDictionaryNode<TKey, TValue>? Root { get; }
Property Value
- ITreeDictionaryNode<TKey, TValue>
Methods
CreateSubtree(TKey)
Creates a new TreeDictionary<TKey, TValue> instance equivalent to the sub-tree
with a node associated with the provided key
as its root node.
[Pure]
ITreeDictionary<TKey, TValue> CreateSubtree(TKey key)
Parameters
key
TKeyRoot node's key.
Returns
- ITreeDictionary<TKey, TValue>
New TreeDictionary<TKey, TValue> instance. Result will be empty if the provided
key
does not exist.
GetNode(TKey)
Attempts to return an ITreeDictionaryNode<TKey, TValue> associated with the provided key
.
[Pure]
ITreeDictionaryNode<TKey, TValue>? GetNode(TKey key)
Parameters
key
TKeyKey to check.
Returns
- ITreeDictionaryNode<TKey, TValue>
An ITreeDictionaryNode<TKey, TValue> instance associated with the provided
key
or null if key does not exist.