Class TreeCollection

Assembly: redb.Core.dll

Specialized collection for working with tree-structured objects
Automatically builds hierarchy when adding nodes
Supports polymorphic trees (objects of different schemes in one tree)

public class TreeCollection : IEnumerable<ITreeRedbObject>, IEnumerable

Inheritance

ObjectTreeCollection

Implements

Properties

Count

Gets count of nodes in collection

public int Count { get; }

Leaves

Gets all leaf nodes (without children)

public IEnumerable<ITreeRedbObject> Leaves { get; }

Orphans

Gets orphan nodes (whose parents haven't been added to collection)

public IEnumerable<ITreeRedbObject> Orphans { get; }

Roots

Gets all root nodes (without parents)

public IEnumerable<ITreeRedbObject> Roots { get; }

Methods

Add(ITreeRedbObject)

Adds node to collection and automatically builds hierarchy

public void Add(ITreeRedbObject node)

AddRange(IEnumerable<ITreeRedbObject>)

Adds range of nodes

public void AddRange(IEnumerable<ITreeRedbObject> nodes)

Clear()

Clears collection

public void Clear()

Contains(long)

Checks if node with specified ID is contained

public bool Contains(long id)

FindById(long)

Finds node by ID

public ITreeRedbObject? FindById(long id)

FindNodes(Func<ITreeRedbObject, bool>)

Finds nodes by predicate

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

GetEnumerator()

Returns an enumerator that iterates through the collection.

public IEnumerator<ITreeRedbObject> GetEnumerator()

GetFlattenedWithLevels()

Gets flattened list of all nodes with level indication

public IEnumerable<(ITreeRedbObject Node, int Level)> GetFlattenedWithLevels()

GetStats()

Gets collection statistics

public TreeCollectionStats GetStats()

Remove(long)

Removes node from collection

public bool Remove(long id)

ValidateIntegrity()

Validates tree integrity

public IEnumerable<string> ValidateIntegrity()