Class TreeExtensions

Namespace: redb.Core.Utils
Assembly: redb.Core.dll

Extensions for working with tree structures.

public static class TreeExtensions

Inheritance

ObjectTreeExtensions

Methods

BreadthFirstTraversal(ITreeRedbObject)

Breadth-First Search tree traversal for polymorphic trees.

public static IEnumerable<ITreeRedbObject> BreadthFirstTraversal(this ITreeRedbObject root)

BreadthFirstTraversal<TProps>(ITreeRedbObject<TProps>)

Breadth-First Search tree traversal for typed trees.

public static IEnumerable<ITreeRedbObject<TProps>> BreadthFirstTraversal<TProps>(this ITreeRedbObject<TProps> root) where TProps : class, new()

DepthFirstTraversal(ITreeRedbObject)

Depth-First Search tree traversal - pre-order for polymorphic trees.

public static IEnumerable<ITreeRedbObject> DepthFirstTraversal(this ITreeRedbObject root)

DepthFirstTraversal<TProps>(ITreeRedbObject<TProps>)

Depth-First Search tree traversal - pre-order for typed trees.

public static IEnumerable<ITreeRedbObject<TProps>> DepthFirstTraversal<TProps>(this ITreeRedbObject<TProps> root) where TProps : class, new()

FindById(ITreeRedbObject, long)

Find node by ID in polymorphic tree.

public static ITreeRedbObject? FindById(this ITreeRedbObject root, long id)

FindById<TProps>(ITreeRedbObject<TProps>, long)

Find node by ID in typed tree.

public static ITreeRedbObject<TProps>? FindById<TProps>(this ITreeRedbObject<TProps> root, long id) where TProps : class, new()

FindNodes(ITreeRedbObject, Func<ITreeRedbObject, bool>)

Find nodes by predicate in polymorphic tree.

public static IEnumerable<ITreeRedbObject> FindNodes(this ITreeRedbObject root, Func<ITreeRedbObject, bool> predicate)

FindNodes<TProps>(ITreeRedbObject<TProps>, Func<ITreeRedbObject<TProps>, bool>)

Find nodes by predicate in typed tree.

public static IEnumerable<ITreeRedbObject<TProps>> FindNodes<TProps>(this ITreeRedbObject<TProps> root, Func<ITreeRedbObject<TProps>, bool> predicate) where TProps : class, new()

FlattenWithLevels(ITreeRedbObject)

Flattens polymorphic tree to list with level indicators.

public static IEnumerable<(ITreeRedbObject Node, int Level)> FlattenWithLevels(this ITreeRedbObject root)

FlattenWithLevels<TProps>(ITreeRedbObject<TProps>)

Flattens typed tree to list with level indicators.

public static IEnumerable<(ITreeRedbObject<TProps> Node, int Level)> FlattenWithLevels<TProps>(this ITreeRedbObject<TProps> root) where TProps : class, new()

GetLeaves(ITreeRedbObject)

Gets all leaf nodes of polymorphic tree.

public static IEnumerable<ITreeRedbObject> GetLeaves(this ITreeRedbObject root)

GetLeaves<TProps>(ITreeRedbObject<TProps>)

Gets all leaf nodes of typed tree.

public static IEnumerable<ITreeRedbObject<TProps>> GetLeaves<TProps>(this ITreeRedbObject<TProps> root) where TProps : class, new()

GetMaterializedPath(ITreeRedbObject, string)

Builds materialized path for polymorphic node.

public static string GetMaterializedPath(this ITreeRedbObject node, string separator = "/")

GetMaterializedPath<TProps>(ITreeRedbObject<TProps>, string)

Builds materialized path for typed node.

public static string GetMaterializedPath<TProps>(this ITreeRedbObject<TProps> node, string separator = "/") where TProps : class, new()

GetNodesAtLevel(ITreeRedbObject, int)

Gets all nodes at specific level in polymorphic tree.

public static IEnumerable<ITreeRedbObject> GetNodesAtLevel(this ITreeRedbObject root, int level)

GetNodesAtLevel<TProps>(ITreeRedbObject<TProps>, int)

Gets all nodes at specific level in typed tree.

public static IEnumerable<ITreeRedbObject<TProps>> GetNodesAtLevel<TProps>(this ITreeRedbObject<TProps> root, int level) where TProps : class, new()

IsBalanced(ITreeRedbObject)

Checks if polymorphic tree is balanced (subtree depth difference does not exceed 1).

public static bool IsBalanced(this ITreeRedbObject root)

IsBalanced<TProps>(ITreeRedbObject<TProps>)

Checks if typed tree is balanced (subtree depth difference does not exceed 1).

public static bool IsBalanced<TProps>(this ITreeRedbObject<TProps> root) where TProps : class, new()

PostOrderTraversal(ITreeRedbObject)

Depth-First Search tree traversal - post-order for polymorphic trees.

public static IEnumerable<ITreeRedbObject> PostOrderTraversal(this ITreeRedbObject root)

PostOrderTraversal<TProps>(ITreeRedbObject<TProps>)

Depth-First Search tree traversal - post-order for typed trees.

public static IEnumerable<ITreeRedbObject<TProps>> PostOrderTraversal<TProps>(this ITreeRedbObject<TProps> root) where TProps : class, new()