TreeOps class

Static helpers shared by the controller and the view. Each is generic over the node value type T; the type argument is normally inferred from the List<TreeNode<T>> you pass in.

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() TreeNodeId
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

ancestorsOf<T>(List<TreeNode<T>> roots, TreeNodeId id) List<TreeNodeId>
Ancestor ids of id, outermost-first (empty if root or missing).
count<T>(List<TreeNode<T>> roots) int
Total node count.
find<T>(List<TreeNode<T>> roots, TreeNodeId id) TreeNode<T>?
Find a node by id, or null.
insertAfter<T>(List<TreeNode<T>> nodes, TreeNodeId afterId, TreeNode<T> toAdd) List<TreeNode<T>>
Rebuild nodes, inserting toAdd immediately after the node afterId at whatever depth it lives.
leafIds<T>(TreeNode<T> node) List<TreeNodeId>
All leaf ids beneath (and including, if leaf) node.
mapNode<T>(List<TreeNode<T>> nodes, TreeNodeId id, TreeNode<T> transform(TreeNode<T>)) List<TreeNode<T>>
Rebuild nodes, replacing the node matching id with transform(node).
removeNode<T>(List<TreeNode<T>> nodes, TreeNodeId id) List<TreeNode<T>>
Rebuild nodes with id (and its subtree) removed.
subtreeIds<T>(TreeNode<T> node) List<TreeNodeId>
All ids beneath (and including) node.
walk<T>(List<TreeNode<T>> roots, void visit(TreeNode<T> node, List<TreeNode<T>> ancestors)) → void
Depth-first walk; visit receives each node and its ancestor path.