Class TreeDictionaryNodeExtensions
- Namespace
- LfrlAnvil.Collections.Extensions
- Assembly
- LfrlAnvil.Collections.dll
Contains ITreeDictionaryNode<TKey, TValue> extension methods.
public static class TreeDictionaryNodeExtensions
- Inheritance
-
TreeDictionaryNodeExtensions
- Inherited Members
Methods
CreateTree<TKey, TValue>(TreeDictionaryNode<TKey, TValue>)
Creates a new TreeDictionary<TKey, TValue> instance equivalent to the sub-tree
with the provided node
as its root node.
[Pure]
public static TreeDictionary<TKey, TValue> CreateTree<TKey, TValue>(this TreeDictionaryNode<TKey, TValue> node) where TKey : notnull
Parameters
node
TreeDictionaryNode<TKey, TValue>Root node.
Returns
- TreeDictionary<TKey, TValue>
New TreeDictionary<TKey, TValue> instance.
Type Parameters
TKey
Key type.
TValue
Value type.
GetRoot<TKey, TValue>(ITreeDictionaryNode<TKey, TValue>)
Finds the root node.
[Pure]
public static ITreeDictionaryNode<TKey, TValue> GetRoot<TKey, TValue>(this ITreeDictionaryNode<TKey, TValue> node)
Parameters
node
ITreeDictionaryNode<TKey, TValue>Source node.
Returns
- ITreeDictionaryNode<TKey, TValue>
Root node or the provided
node
if it is a root node.
Type Parameters
TKey
Key type.
TValue
Value type.
GetRoot<TKey, TValue>(TreeDictionaryNode<TKey, TValue>)
Finds the root node.
[Pure]
public static TreeDictionaryNode<TKey, TValue> GetRoot<TKey, TValue>(this TreeDictionaryNode<TKey, TValue> node) where TKey : notnull
Parameters
node
TreeDictionaryNode<TKey, TValue>Source node.
Returns
- TreeDictionaryNode<TKey, TValue>
Root node or the provided
node
if it is a root node.
Type Parameters
TKey
Key type.
TValue
Value type.
VisitAncestors<TKey, TValue>(ITreeDictionaryNode<TKey, TValue>)
Creates a new IEnumerable<T> instance that contains all ancestors of the provided node
.
[Pure]
public static IEnumerable<ITreeDictionaryNode<TKey, TValue>> VisitAncestors<TKey, TValue>(this ITreeDictionaryNode<TKey, TValue> node)
Parameters
node
ITreeDictionaryNode<TKey, TValue>Source node.
Returns
- IEnumerable<ITreeDictionaryNode<TKey, TValue>>
New IEnumerable<T> instance.
Type Parameters
TKey
Key type.
TValue
Value type.
VisitAncestors<TKey, TValue>(TreeDictionaryNode<TKey, TValue>)
Creates a new IEnumerable<T> instance that contains all ancestors of the provided node
.
[Pure]
public static IEnumerable<TreeDictionaryNode<TKey, TValue>> VisitAncestors<TKey, TValue>(this TreeDictionaryNode<TKey, TValue> node) where TKey : notnull
Parameters
node
TreeDictionaryNode<TKey, TValue>Source node.
Returns
- IEnumerable<TreeDictionaryNode<TKey, TValue>>
New IEnumerable<T> instance.
Type Parameters
TKey
Key type.
TValue
Value type.
VisitDescendants<TKey, TValue>(ITreeDictionaryNode<TKey, TValue>)
Creates a new IEnumerable<T> instance that contains all descendants of the provided node
.
[Pure]
public static IEnumerable<ITreeDictionaryNode<TKey, TValue>> VisitDescendants<TKey, TValue>(this ITreeDictionaryNode<TKey, TValue> node)
Parameters
node
ITreeDictionaryNode<TKey, TValue>Source node.
Returns
- IEnumerable<ITreeDictionaryNode<TKey, TValue>>
New IEnumerable<T> instance.
Type Parameters
TKey
Key type.
TValue
Value type.
VisitDescendants<TKey, TValue>(ITreeDictionaryNode<TKey, TValue>, Func<ITreeDictionaryNode<TKey, TValue>, bool>)
Creates a new IEnumerable<T> instance that contains all descendants of the provided node
with a stopPredicate
.
[Pure]
public static IEnumerable<ITreeDictionaryNode<TKey, TValue>> VisitDescendants<TKey, TValue>(this ITreeDictionaryNode<TKey, TValue> node, Func<ITreeDictionaryNode<TKey, TValue>, bool> stopPredicate)
Parameters
node
ITreeDictionaryNode<TKey, TValue>Source node.
stopPredicate
Func<ITreeDictionaryNode<TKey, TValue>, bool>Predicate that stops the traversal for the given sub-tree, when it returns true.
Returns
- IEnumerable<ITreeDictionaryNode<TKey, TValue>>
New IEnumerable<T> instance.
Type Parameters
TKey
Key type.
TValue
Value type.
VisitDescendants<TKey, TValue>(TreeDictionaryNode<TKey, TValue>)
Creates a new IEnumerable<T> instance that contains all descendants of the provided node
.
[Pure]
public static IEnumerable<TreeDictionaryNode<TKey, TValue>> VisitDescendants<TKey, TValue>(this TreeDictionaryNode<TKey, TValue> node) where TKey : notnull
Parameters
node
TreeDictionaryNode<TKey, TValue>Source node.
Returns
- IEnumerable<TreeDictionaryNode<TKey, TValue>>
New IEnumerable<T> instance.
Type Parameters
TKey
Key type.
TValue
Value type.
VisitDescendants<TKey, TValue>(TreeDictionaryNode<TKey, TValue>, Func<TreeDictionaryNode<TKey, TValue>, bool>)
Creates a new IEnumerable<T> instance that contains all descendants of the provided node
with a stopPredicate
.
[Pure]
public static IEnumerable<TreeDictionaryNode<TKey, TValue>> VisitDescendants<TKey, TValue>(this TreeDictionaryNode<TKey, TValue> node, Func<TreeDictionaryNode<TKey, TValue>, bool> stopPredicate) where TKey : notnull
Parameters
node
TreeDictionaryNode<TKey, TValue>Source node.
stopPredicate
Func<TreeDictionaryNode<TKey, TValue>, bool>Predicate that stops the traversal for the given sub-tree, when it returns true.
Returns
- IEnumerable<TreeDictionaryNode<TKey, TValue>>
New IEnumerable<T> instance.
Type Parameters
TKey
Key type.
TValue
Value type.