#getParent
and #getChildren
in a subclass. All other getters
will automatically work.
goog.structs.Node | |
goog.structs.TreeNode | goog.structs.Node |
key
: KEY
Key.
|
value
: VALUE
Value.
|
![]()
Appends a child node to this node.
Arguments:
|
code » | |||
![]()
Inserts a child node at the given index.
Arguments:
|
code » | |||
No description.
Returns: !goog.structs.TreeNode
Clone of the tree node without its parent
and child nodes. The key and the value are copied by reference.
|
code » | |||
Tells whether this node is the ancestor of the given node.
Arguments:
Returns: boolean
Whether this node is the ancestor of
node .
|
code » | |||
No description.
Returns: !goog.structs.TreeNode
Clone of the subtree with this node as root.
|
code » | |||
![]()
Traverses all child nodes.
Arguments:
|
code » | |||
![]()
Traverses all child nodes recursively in preorder.
Arguments:
|
code » | |||
No description.
|
code » | |||
Gets the child node of this node at the given index.
Arguments:
|
code » | |||
No description.
Returns: number
The number of children.
|
code » | |||
No description.
|
code » | |||
No description.
Returns: number
The number of ancestors of the node.
|
code » | |||
Returns a node whose key matches the given one in the hierarchy rooted at
this node. The hierarchy is searched using an in-order traversal.
Arguments:
Returns: goog.structs.TreeNode.<KEY, VALUE>
The node with the given key, or
null if no node with the given key exists in the hierarchy.
|
code » | |||
No description.
|
code » | |||
No description.
Returns: !goog.structs.TreeNode.<KEY, VALUE>
The root of the tree structure,
i.e. the farthest ancestor of the node or the node itself if it has no
parents.
|
code » | |||
Builds a nested array structure from the node keys in this node's subtree to
facilitate testing tree operations that change the hierarchy.
Returns: !Array.<KEY>
The structure of this node's descendants as nested
array of node keys. The number of unclosed opening brackets up to a
particular node is proportional to the indentation of that node in the
graphical representation of the tree. Example:
this |- child1 | L- grandchild L- child2is represented as ['child1', ['grandchild'], 'child2']. |
code » | |||
Tells if the node is the last child of its parent. This method helps how to
connect the tree nodes with lines: L shapes should be used before the last
children and |- shapes before the rest. Schematic tree visualization:
Node1 |-Node2 | L-Node3 | |-Node4 | L-Node5 L-Node6
Returns: boolean
Whether the node has parent and is the last child of it.
|
code » | |||
No description.
Returns: boolean
Whether the node is a leaf node.
|
code » | |||
Removes the given child node of this node.
Arguments:
|
code » | |||
Removes the child node at the given index.
Arguments:
|
code » | |||
![]()
Removes all child nodes of this node.
|
code » | |||
Replaces the given child node.
Arguments:
|
code » | |||
Replaces a child node at the given index.
Arguments:
|
code » | |||
![]()
Sets the parent node of this node. The callers must ensure that the parent
node and only that has this node among its children.
Arguments:
|
code » | |||
![]()
Traverses the subtree with the possibility to skip branches. Starts with
this node, and visits the descendant nodes depth-first, in preorder.
Arguments:
|
code » |
Finds the deepest common ancestor of the given nodes. The concept of
ancestor is not strict in this case, it includes the node itself.
Arguments:
Returns: goog.structs.TreeNode.<KEY, VALUE>
The common ancestor of the nodes
or null if they are from different trees.
|
code » |
![]()
Constant for empty array to avoid unnecessary allocations.
|
Code » | |
![]()
No description.
|
Code » |