Options
All
  • Public
  • Public/Protected
  • All
Menu

Class TopDownTreeIterator

This tree iterator visits all nodes from top to bottom considering the following rules.

Let assume the following tree:

  R
|
+---1
| |
| +---1.1
| |
| +---1.2
| |
| +---1.3
| | |
| | +---1.3.1
| | |
| | +---1.3.2
| |
| +---1.4
|
+---2
|
+---2.1

When selecting 1.2 as the root, the normal DepthFirstTreeIterator would stop on 1.2 as it does not have children, but this iterator will visit the next sibling (1.3 and 1.4 but not 1.1) nodes. So the expected traversal order will be 1.2, 1.3, 1.3.1, 1.3.2, and 1.4 then jumps to 2 and continues with 2.1.

Hierarchy

Index

Constructors

Properties

delegate: IterableIterator<TreeNode>
root: TreeNode

Methods

  • [iterator](): IterableIterator<TreeNode>
  • isEmpty(nodes: undefined | TreeNode[]): boolean