eachBefore method
ε εΊιε
Implementation
T eachBefore(TreeFun<T> callback) {
List<T> nodes = [this as T];
List<T> children;
int index = -1;
while (nodes.isNotEmpty) {
T node = nodes.removeLast();
if (callback.call(node, ++index, this as T)) {
break;
}
children = node._childrenList;
if (children.isNotEmpty) {
for (int i = children.length - 1; i >= 0; --i) {
nodes.add(children[i]);
}
}
}
return this as T;
}