Optional
defaultComparator: Comparator<[string, T]>The value to check.
True if a node with the given value exists in the tree; otherwise, false.
Gives access to the Tree store directly for reference reasons; Warning: cannot be modified, lest something get messed up with three internal state.
the tree store
Gives access to the Tree Entry directly for reference reasons; Warning: cannot be modified, lest something get messed up with three internal state.
The key of the node to get the entry of.
the tree entry
returns the index of a given key using the searcher predicate, or -1 if not found
Returns the key of the first node that satisfies the given discriminator function.
The discriminator function.
The key of the first node that satisfies the discriminator function, or undefined if not found.
Returns the key associated with the given value in the tree.
The value to find the key for.
The key associated with the value, or undefined if not found.
Checks if any node in the tree satisfies the given discriminator function.
The discriminator function.
True if any node satisfies the discriminator function; otherwise, false.
Adds a new node to the tree with the given key, parent, and value. If a node with the given key already exists in the tree, this method does nothing.
The key of the new node to add.
The key of the parent node for the new node. Use null
if the node is a root node.
The value associated with the new node.
Adds a new node to the tree with the given key, parent, and value. If a node with the given key already exists in the tree, this method does nothing.
The key of the new node to add.
The key of the parent node for the new node.
The value associated with the new node.
Adds a new root to the tree with the given key, and value. If a node with the given key already exists in the tree, this method does nothing.
The key of the new node to add.
The value associated with the new node.
Condenses the tree by merging nodes with one child with that one child using the provided merger function. The merger function takes two adjacent nodes 'parent' and 'child', and if applicable, returns a new merged node 'r'. If the merger function returns void, no merge is performed between 'parent' and 'child'.
Adds a node to a given parent if it doesn't exist, otherweise will update an existing node and move the node to be a child of the designated parent
The key of the node to update.
If the node is to be inserted, it will become a child of this node, otherwise it is ignored
The new value to set for the node.
Removes the node with the given key from the tree. that node's childrens become detached within the original tree as additional roots.
The key of the node to be removed from the tree.
The value of the node that was removed, or undefined if the node does not exist.
Given a list of nodes, allocate them into the forest.
Given a list of nodes, allocate them into the forest, but asynchronously
Creates a new tree by pruning the subtree rooted at the node with the given key from the original tree. The pruned tree includes the node and its descendants as a new tree instance. Items are removed from the original tree.
The key of the node that serves as the root of the subtree to be pruned.
A new Tree instance representing the pruned subtree.
Sorts the tree in place.
Optional
comparator: Comparator<[string, T]>override the default comparator with this comparator
Truncates the subtree rooted at the node with the given key from the tree and returns a key-value collection of those removed. The original tree will no longer include the node and its descendants.
The key of the node that serves as the root of the subtree to be truncated.
An object representing the truncated subtree, where the keys are the keys of the nodes, and the values are the values associated with each node (or undefined if the node was not present)
Adds a node to a given parent if it doesn't exist, otherweise will update an existing node and ignore parent
The key of the node to update.
If the node is to be inserted, it will become a child of this node, otherwise it is ignored
The new value to set for the node.
Returns an object representing the ancestors nodes of the given node, with keys as node keys and values as node values, from closest to root.
The key of the node for which to find the ancestors.
An array of values representing the ancestor nodes.
Returns an array of objects representing the ancestor keys and nodes of the node with the given key, from closest to root.
The key of the node for which to find the ancestors.
An array of values representing the ancestor nodes.
Returns an array of tuples representing the ancestor keys and nodes of the node with the given key, from closest to root.
The key of the node for which to find the ancestors.
An array of values representing the ancestor nodes.
Maps a function to each ancestors of the target node, from closest to root.
The mapping function to be applied. It takes three arguments:
value
(type T
): The value associated with the current node being processed.key
(string): The key of the current node being processed.i
(number): The index of the current node in the ancestor line.the node from which to iterate the descendents from
Maps a function to each ancestors of the target node, from root to closest.
The mapping function to be applied. It takes three arguments:
value
(type T
): The value associated with the current node being processed.key
(string): The key of the current node being processed.i
(number): The index of the current node in the ancestor line.the node from which to iterate the descendents from
Applies a reducer function to each ancestors in the tree from the given node, from closest to root
The reducer function to be applied. It takes four arguments:
key
(string): The key of the current node being processed.value
(type T
): The value associated with the current node being processed.i
(number): The index of the current node in the ancestor list traversal.accumulation
(type R
): The accumulated result from previous reductions.The initial value of the accumulator for the reduction.
the node from which to traverse upward from
The final accumulated result after applying the reducer to all nodes.
Applies a reducer function to each ancestors in the tree from the given node, from root to closest
The reducer function to be applied. It takes four arguments:
key
(string): The key of the current node being processed.value
(type T
): The value associated with the current node being processed.i
(number): The index of the current node in the ancestor list traversal.accumulation
(type R
): The accumulated result from previous reductions.The initial value of the accumulator for the reduction.
the node from which to traverse upward from
The final accumulated result after applying the reducer to all nodes.
Returns an object representing the children nodes of the given node, with keys as node keys and values as node values.
The key of the node for which to find the children.
An array of values representing the child nodes.
Returns an array of objects representing the children keys and nodes of the node with the given key.
The key of the node for which to find the children.
An array of values representing the children nodes.
Maps a function to each child of the target node.
The mapping function to be applied. It takes three arguments:
value
(type T
): The value associated with the current node being processed.key
(string): The key of the current node being processed.i
(number): The index of the current node in the child.the node from which to get children from
Applies a reducer function to each child of the given node
The reducer function to be applied. It takes four arguments:
key
(string): The key of the current node being processed.value
(type T
): The value associated with the current node being processed.i
(number): The index of the current node in the child.accumulation
(type R
): The accumulated result from previous reductions.The initial value of the accumulator for the reduction.
the node from which to get children from
The final accumulated result after applying the reducer to all nodes.
Returns an object representing the descendent nodes of the given node, with keys as node keys and values as node values in depth-first order.
The key of the node for which to find the descendents.
An array of values representing the descendents nodes.
Returns an array of objects representing the descendent keys and nodes of the node with the given key in depth-first order.
The key of the node for which to find the descendents.
An array of values representing the descendent nodes.
Returns an array of tuples representing the descemdemt keys and nodes of the node with the given key in depth-first order.
The key of the node for which to find the descendents.
An array of values representing the descendent nodes.
Returns an array of values representing the descendant nodes of the node with the given key in depth-first order.
The key of the node for which to find the descendants.
An array of values representing the descendant nodes.
deepDescendentValues
Maps a function to each descendent of the target node in a depth-order traversal.
The mapping function to be applied. It takes three arguments:
value
(type T
): The value associated with the current node being processed.key
(string): The key of the current node being processed.i
(number): The index of the current node in the depth-order traversal.the node from which to iterate the descendents from
Maps a function to each descendent of the target node in a wide-order traversal.
The mapping function to be applied. It takes three arguments:
value
(type T
): The value associated with the current node being processed.key
(string): The key of the current node being processed.i
(number): The index of the current node in the wide-order traversal.the node from which to iterate the descendents from
Applies a reducer function to each descendent in the tree in a depth-first traversal.
The reducer function to be applied. It takes four arguments:
key
(string): The key of the current node being processed.value
(type T
): The value associated with the current node being processed.i
(number): The index of the current node in the depth-first traversal.accumulation
(type R
): The accumulated result from previous reductions.The initial value of the accumulator for the reduction.
the node from which to iterate the descendents from
The final accumulated result after applying the reducer to all nodes.
Applies a reducer function to each descendent in the tree in a width-first traversal.
The reducer function to be applied. It takes four arguments:
key
(string): The key of the current node being processed.value
(type T
): The value associated with the current node being processed.i
(number): The index of the current node in the width-first traversal.accumulation
(type R
): The accumulated result from previous reductions.The initial value of the accumulator for the reduction.
the node from which to iterate the descendents from
The final accumulated result after applying the reducer to all nodes.
Returns an object representing the descendent nodes of the given node, with keys as node keys and values as node values in width-first order.
The key of the node for which to find the descendents.
An array of values representing the descendents nodes.
Returns an array of objects representing the descendent keys and nodes of the node with the given key in width-first order.
The key of the node for which to find the descendents.
An array of values representing the descendent nodes.
Returns an array of tuples representing the descemdemt keys and nodes of the node with the given key in width-first order.
The key of the node for which to find the descendents.
An array of values representing the descendent nodes.
Returns an object representing the leaf nodes of the tree, with keys as node keys and values as node values.
Optional
origin: string | string[]where the traversal begins. If unspecified, will be all root nodes, thus traversal the whole forest.
Optional
Rest
...moreOrigins: string[]An object representing the leaf nodes.
Returns an array of objects object representing the leaf keys and value of the tree.
Optional
origin: string | string[]where the traversal begins. If unspecified, will be all root nodes, thus traversal the whole forest.
Optional
Rest
...moreOrigins: string[]An object representing the leaf nodes.
Returns an array of key-value pairs representing the leaf nodes of the tree.
Optional
origin: string | string[]where the traversal begins. If unspecified, will be all root nodes, thus traversal the whole forest.
Optional
Rest
...moreOrigins: string[]An array of key-value pairs representing the leaf nodes.
Returns an array of values representing the leaf nodes of the tree.
Optional
origin: string | string[]where the traversal begins. If unspecified, will be all root nodes, thus traversal the whole forest.
Optional
Rest
...moreOrigins: string[]An array of values representing the leaf nodes.
Returns an array of values representing the leaf nodes of the tree.
Optional
origin: string | string[]where the traversal begins. If unspecified, will be all root nodes, thus traversal the whole forest.
Optional
Rest
...moreOrigins: string[]An array of values representing the leaf nodes.
leafValues
Maps a function to each sibling of the target node.
The mapping function to be applied. It takes three arguments:
value
(type T
): The value associated with the current node being processed.key
(string): The key of the current node being processed.i
(number): The index of the current node in the sibling.Optional
origin: string | string[]where the traversal begins. If unspecified, will be all root nodes, thus traversal the whole forest.
Optional
Rest
...moreOrigins: string[]Applies a reducer function to each sibling of the given node
The reducer function to be applied. It takes four arguments:
key
(string): The key of the current node being processed.value
(type T
): The value associated with the current node being processed.i
(number): The index of the current node in the sibling.accumulation
(type R
): The accumulated result from previous reductions.The initial value of the accumulator for the reduction.
Optional
origin: string | string[]where the traversal begins. If unspecified, will be all root nodes, thus traversal the whole forest.
Optional
Rest
...moreOrigins: string[]The final accumulated result after applying the reducer to all nodes.
Returns the key of the parent node of the node with the given key.
The key of the node for which to find the parent.
The key of the parent node as a string, or null if the node has no parent, or undefined if the node was not in the key
Returns an objects representing the pareent key and node of the given node.
The key of the node for which to find the parent.
An object representing the parent node.
Returns a tuples representing this nodes parent key and value.
The key of the node for which to find the parent.
A tuple consistent of the parent key and value, if applicable.
Maps a function to each root of the tree.
The mapping function to be applied. It takes three arguments:
value
(type T
): The value associated with the current node being processed.key
(string): The key of the current node being processed.i
(number): The index of the current node in the root list.Applies a reducer function to each root of the tree
The reducer function to be applied. It takes four arguments:
key
(string): The key of the current node being processed.value
(type T
): The value associated with the current node being processed.i
(number): The index of the current node in the root list.accumulation
(type R
): The accumulated result from previous reductions.The initial value of the accumulator for the reduction.
The final accumulated result after applying the reducer to all root nodes.
gives the index of a given key amongst it's siblings using a predicate
Maps a function to each sibling of the target node.
The mapping function to be applied. It takes three arguments:
value
(type T
): The value associated with the current node being processed.key
(string): The key of the current node being processed.i
(number): The index of the current node in the sibling.the node from which to get siblings from
Applies a reducer function to each sibling of the given node
The reducer function to be applied. It takes four arguments:
key
(string): The key of the current node being processed.value
(type T
): The value associated with the current node being processed.i
(number): The index of the current node in the sibling.accumulation
(type R
): The accumulated result from previous reductions.The initial value of the accumulator for the reduction.
the node from which to get siblings from
The final accumulated result after applying the reducer to all nodes.
Returns an object representing the sibling nodes of the given node, with keys as node keys and values as node values.
The key of the node for which to find the sibling.
An array of values representing the sibling nodes.
Returns an array of objects representing the sibling keys and nodes of the node with the given key.
The key of the node for which to find the sibling.
An array of values representing the sibling nodes.
Protected
_comparatorProtected
_keysProtected
_storeReturns an array of keys representing all nodes in the tree in a depth-first traversal.
Optional
origin: string | string[] = ...where the traversal begins. If unspecified, will be all root nodes, thus traversal the whole forest.
Optional
Rest
...moreOrigins: string[]An array of keys representing all nodes in the tree in a depth-first traversal.
Returns an array of key-value pairs representing the nodes of the tree in a depth-first traversal.
Optional
origin: string | string[]where the traversal begins. If unspecified, will be all root nodes, thus traversal the whole forest.
Optional
Rest
...moreOrigins: string[]An array of objects representing the key-value pairs of the nodes in depth-first.
Each object in the array has two properties: key
(string) representing the key of the node and value
(type T
) representing the value associated with the node.
Returns an array of key-value tuples representing all nodes in the tree in a depth-first traversal.
Optional
origin: string | string[]where the traversal begins. If unspecified, will be all root nodes, thus traversal the whole forest.
Optional
Rest
...moreOrigins: string[]An array of key-value tuples representing all nodes in the tree in a depth-first traversal.
Returns an array of keys representing all nodes in the tree in a depth-first traversal.
Optional
origin: string | string[]where the traversal begins. If unspecified, will be all root nodes, thus traversal the whole forest.
Optional
Rest
...moreOrigins: string[]An array of keys representing all nodes in the tree in a depth-first traversal.
Returns an array of key-value pairs representing all nodes in the tree in a depth-first traversal.
Optional
origin: string | string[]where the traversal begins. If unspecified, will be all root nodes, thus traversal the whole forest.
Optional
Rest
...moreOrigins: string[]An array of key-value pairs representing all nodes in the tree in a depth-first traversal.
Returns an array of key-value tuples representing all nodes in the tree in a depth-first traversal.
Optional
origin: string | string[]where the traversal begins. If unspecified, will be all root nodes, thus traversal the whole forest.
Optional
Rest
...moreOrigins: string[]An array of key-value tuples representing all nodes in the tree in a depth-first traversal.
Returns an array of values associated with all nodes in the tree in a depth-first traversal.
Optional
origin: string | string[]where the traversal begins. If unspecified, will be all root nodes, thus traversal the whole forest.
Optional
Rest
...moreOrigins: string[]An array of values associated with all nodes in the tree in a depth-first traversal.
Returns an array of values associated with all nodes in the tree in a depth-first traversal.
Optional
origin: string | string[]where the traversal begins. If unspecified, will be all root nodes, thus traversal the whole forest.
Optional
Rest
...moreOrigins: string[]An array of values associated with all nodes in the tree in a depth-first traversal.
Maps a function to each node in the tree in a deep-order traversal.
The mapping function to be applied. It takes three arguments:
value
(type T
): The value associated with the current node being processed.key
(string): The key of the current node being processed.i
(number): The index of the current node in the deep-order traversal.Optional
origin: string | string[]where the traversal begins. If unspecified, will be all root nodes, thus traversal the whole forest.
Optional
Rest
...moreOrigins: string[]Maps a function to each node in the tree in a deep-order traversal, starting at leaves and going upwards towards roots.
The mapping function to be applied. It takes three arguments:
value
(type T
): The value associated with the current node being processed.key
(string): The key of the current node being processed.i
(number): The index of the current node in the deep-order traversal.Optional
origin: string | string[]where the traversal begins. If unspecified, will be all root nodes, thus traversal the whole forest.
Optional
Rest
...moreOrigins: string[]Applies a reducer function to each node in the tree in a depth-first traversal.
The reducer function to be applied. It takes four arguments:
key
(string): The key of the current node being processed.value
(type T
): The value associated with the current node being processed.i
(number): The index of the current node in the depth-first traversal.accumulation
(type R
): The accumulated result from previous reductions.The initial value of the accumulator for the reduction.
Optional
origin: string | string[]where the traversal begins. If unspecified, will be all root nodes, thus traversal the whole forest.
Optional
Rest
...moreOrigins: string[]The final accumulated result after applying the reducer to all nodes.
Applies a reducer function to each node in the tree in a depth-first traversal.
The reducer function to be applied. It takes four arguments:
key
(string): The key of the current node being processed.value
(type T
): The value associated with the current node being processed.i
(number): The index of the current node in the depth-first traversal.accumulation
(type R
): The accumulated result from previous reductions.The initial value of the accumulator for the reduction.
Optional
origin: string | string[]where the traversal begins. If unspecified, will be all root nodes, thus traversal the whole forest.
Optional
Rest
...moreOrigins: string[]The final accumulated result after applying the reducer to all nodes.
returns the key of the next node that satisifes the selector relative to the given key in the flattened tree.
returns the value of the next node that satisifes the selector relative to the given key in the flattened tree.
returns the value of the previous node that satisifes the selector relative to the given key in the flattened tree.
Maps a function to each node in the a path starting at 'from' node and ending at 'to' node.
The key of the starting node.
The key of the ending node.
The mapping function to be applied. It takes three arguments:
value
(type T
): The value associated with the current node being processed.key
(string): The key of the current node being processed.i
(number): The index of the current node in the wide-order traversal.Finds the keys representing the path from one node to another in the tree, if it exists. If no such path is viable, the array will be empty.
The key of the starting node.
The key of the ending node.
An array of keys representing the path from the starting node to the ending node, if it exists. If no such path is viable, the array will be empty.
Returns an array of key-value representing the nodes along the path from one node to another in the tree, if it exists.
The key of the starting node.
The key of the ending node.
An array of objects representing the key-value pairs of the nodes in depth-first.
Each object in the array has two properties: key
(string) representing the key of the node and value
(type T
) representing the value associated with the node.
Finds the key-value tuples representing the nodes along the path from one node to another in the tree, if it exists.
The key of the starting node.
The key of the ending node.
An array of key-value tuples representing the nodes along the path from the starting node to the ending node, if it exists.
Finds the values associated with the nodes along the path from one node to another in the tree, if it exists.
The key of the starting node.
The key of the ending node.
An array of values associated with the nodes along the path from the starting node to the ending node, if it exists.
Applies a reducer function to each node along the path from one node to another in the tree, if it exists.
The key of the starting node.
The key of the ending node.
The reducer function to be applied. It takes four arguments:
key
(string): The key of the current node being processed.value
(type T
): The value associated with the current node being processed.i
(number): The index of the current node along the path.accumulation
(type R
): The accumulated result from previous reductions.The initial value of the accumulator for the reduction.
The final accumulated result after applying the reducer to all nodes along the path.
Maps a function to each node in the tree in a wide-order traversal, starting at leaves and going upwards towards roots.
The mapping function to be applied. It takes three arguments:
value
(type T
): The value associated with the current node being processed.key
(string): The key of the current node being processed.i
(number): The index of the current node in the wide-order traversal.Optional
origin: string | string[]where the traversal begins. If unspecified, will be all root nodes, thus traversal the whole forest.
Optional
Rest
...moreOrigins: string[]Maps a function to each node in the tree in a wide-order traversal.
The mapping function to be applied. It takes three arguments:
value
(type T
): The value associated with the current node being processed.key
(string): The key of the current node being processed.i
(number): The index of the current node in the wide-order traversal.Optional
origin: string | string[]where the traversal begins. If unspecified, will be all root nodes, thus traversal the whole forest.
Optional
Rest
...moreOrigins: string[]Applies a reducer function to each node in the tree in a width-first traversal.
The reducer function to be applied. It takes four arguments:
key
(string): The key of the current node being processed.value
(type T
): The value associated with the current node being processed.i
(number): The index of the current node in the width-first traversal.accumulation
(type R
): The accumulated result from previous reductions.The initial value of the accumulator for the reduction.
Optional
origin: string | string[]where the traversal begins. If unspecified, will be all root nodes, thus traversal the whole forest.
Optional
Rest
...moreOrigins: string[]The final accumulated result after applying the reducer to all nodes.
Applies a reducer function to each node in the tree in a width-first traversal.
The reducer function to be applied. It takes four arguments:
key
(string): The key of the current node being processed.value
(type T
): The value associated with the current node being processed.i
(number): The index of the current node in the width-first traversal.accumulation
(type R
): The accumulated result from previous reductions.The initial value of the accumulator for the reduction.
Optional
origin: string | string[]where the traversal begins. If unspecified, will be all root nodes, thus traversal the whole forest.
Optional
Rest
...moreOrigins: string[]The final accumulated result after applying the reducer to all nodes.
Returns an array of keys representing the nodes of the tree in a width-first traversal.
Optional
origin: string | string[] = ...where the traversal begins. If unspecified, will be all root nodes, thus traversal the whole forest.
Optional
Rest
...moreOrigins: string[]An array of keys representing the nodes in width-first.
Returns an array of key-value pairs representing the nodes of the tree in a width-first traversal.
Optional
origin: string | string[]where the traversal begins. If unspecified, will be all root nodes, thus traversal the whole forest.
Optional
Rest
...moreOrigins: string[]An array of objects representing the key-value pairs of the nodes in width-first.
Each object in the array has two properties: key
(string) representing the key of the node and value
(type T
) representing the value associated with the node.
Returns an array of key-value tuples representing the nodes of the tree in a width-first traversal.
Optional
origin: string | string[]where the traversal begins. If unspecified, will be all root nodes, thus traversal the whole forest.
Optional
Rest
...moreOrigins: string[]An array of key-value tuples representing the nodes in width-first.
Returns an array of keys representing the nodes of the tree in a width-first traversal starting from leaf nodes.
Optional
origin: string | string[]where the traversal begins. If unspecified, will be all root nodes, thus traversal the whole forest.
Optional
Rest
...moreOrigins: string[]An array of keys representing the nodes in width-first starting from leaf nodes.
Returns an array of key-value pairs representing the nodes of the tree in a width-first traversal starting from leaf nodes.
Optional
origin: string | string[]where the traversal begins. If unspecified, will be all root nodes, thus traversal the whole forest.
Optional
Rest
...moreOrigins: string[]An array of objects representing the key-value pairs of the nodes in width-first.
Each object in the array has two properties: key
(string) representing the key of the node and value
(type T
) representing the value associated with the node.
Returns an array of key-value pairs representing the nodes of the tree in a width-first traversal starting from leaf nodes.
Optional
origin: string | string[]where the traversal begins. If unspecified, will be all root nodes, thus traversal the whole forest.
Optional
Rest
...moreOrigins: string[]An array of key-value pairs representing the nodes in width-first starting from leaf nodes.
Returns an array of values representing the nodes of the tree in a width-first traversal starting from leaf nodes.
Optional
origin: string | string[]where the traversal begins. If unspecified, will be all root nodes, thus traversal the whole forest.
Optional
Rest
...moreOrigins: string[]An array of values representing the nodes in width-first starting from leaf nodes.
Returns an array of values representing the nodes of the tree in a width-first traversal.
Optional
origin: string | string[]where the traversal begins. If unspecified, will be all root nodes, thus traversal the whole forest.
Optional
Rest
...moreOrigins: string[]An array of values representing the nodes in width-first.
set the default comparator of the SortedTree to a new comparator.
the comparator to replace the default comprator with
Static
DEFAULT_Static
fromCreates a new tree from a raw store. This does not do any validation checks for completeness.
Checks if the tree contains a node with the given value.