replaceNodesWithParent<K> static method

List<TreeNode<K>> replaceNodesWithParent<K>(
  1. List<TreeNode<K>> nodes,
  2. TreeNodeUnaryOperatorWithParent<K> operator
)

Applies a transformation operator to all nodes with parent context.

Parameters:

  • nodes (List<TreeNode<K>>, required): Tree nodes.
  • operator (TreeNodeUnaryOperatorWithParent<K>, required): Transformation function.

Returns: List<TreeNode<K>> — transformed tree.

Implementation

static List<TreeNode<K>> replaceNodesWithParent<K>(
    List<TreeNode<K>> nodes, TreeNodeUnaryOperatorWithParent<K> operator) {
  return _replaceNodesWithParent(null, nodes, operator) ?? nodes;
}