Create a TreeMultiMap and optionally bulk-insert items.
OptionalkeysNodesEntriesOrRaws: Iterable<Iterable of keys/nodes/entries/raw items to insert.
Optionaloptions: TreeMultiMapOptions<K, V[], R>Options for TreeMultiMap (comparator, reverse, map mode).
New TreeMultiMap instance.
Gets whether the tree allows duplicate keys.
True if duplicates are allowed, false otherwise.
Gets whether the tree is in Map mode.
True if in Map mode, false otherwise.
Gets whether the tree's comparison logic is reversed.
True if the tree is reversed (e.g., a max-heap logic).
Gets the sentinel NIL node (used in self-balancing trees like Red-Black Tree).
The NIL node.
Get the current root node.
Root node, or undefined.
Gets the number of nodes in the tree.
The size of the tree.
Protected_clearProtected_clearProtected_clone(Protected) Helper for cloning. Performs a BFS and adds all nodes to the new tree.
The new, empty tree instance to populate.
Protected_compareProtected_createProtected_createCreate a red-black node for the given key/value (value ignored in map mode).
A new RedBlackTreeNode instance.
Protected_DEFAULT_(Protected) Default callback function, returns the node's key.
The node.
The node's key or undefined.
Protected_delete(Protected) Restore red-black properties after deletion (recolor/rotate).
Child that replaced the deleted node (may be undefined).
void
Protected_dfsCallback type.
Function to call on nodes.
Optionalpattern: DFSOrderPatternTraversal order.
OptionalonlyOne: booleanStop after first match.
OptionalstartNode: Starting node.
OptionaliterationType: IterationTypeTraversal method.
OptionalincludeNull: booleanInclude nulls.
OptionalshouldVisitLeft: ((node: undefined | null | BinaryTreeNode<K, V[]>) => boolean)Predicate to traverse left.
OptionalshouldVisitRight: ((node: undefined | null | BinaryTreeNode<K, V[]>) => boolean)Predicate to traverse right.
OptionalshouldVisitRoot: ((node: undefined | null | BinaryTreeNode<K, V[]>) => boolean)Predicate to visit root.
OptionalshouldProcessRoot: ((node: undefined | null | BinaryTreeNode<K, V[]>) => boolean)Predicate to process root.
Array of callback results.
Protected_display(Protected) Recursive helper for toVisual.
The current node.
Print options.
Layout information for this subtree.
Protected_ensure(Protected) Converts a key, node, entry, or predicate into a standardized predicate function.
The item to convert.
A predicate function.
Protected_extractProtected_get(Protected) Gets the iterator for the tree (default in-order).
Optionalnode: null | BinaryTreeNode<K, V[]> = ...The node to start iteration from.
An iterator for [key, value] pairs.
Protected_insert(Protected) Standard BST insert followed by red-black fix-up.
Node to insert.
Status string: 'CREATED' or 'UPDATED'.
Protected_insert(Protected) Restore red-black properties after insertion (recolor/rotate).
Recently inserted node.
void
Protected_is(Protected) Checks if an item is a predicate function.
The item to check.
True if it's a function.
Protected_keyProtected_left(Protected) Perform a left rotation around x.
Pivot node to rotate around.
void
Protected_replace(Protected) Replaces a node in the tree with a new node, maintaining children and parent links.
The node to be replaced.
The node to insert.
The newNode.
Protected_right(Protected) Perform a right rotation around y.
Pivot node to rotate around.
void
Protected_set(Protected) Sets the root node and clears its parent reference.
The node to set as root.
Protected_setProtected_snapshotProtected_swap(Protected) Swaps the key/value properties of two nodes.
The destNode (now holding srcNode's properties).
Protected_transplant(Protected) Transplant a subtree in place of another during deletion.
Node to replace.
Replacement subtree root (may be undefined).
void
Adds multiple items to the tree.
An iterable of items to add.
Optionalvalues: Iterable<undefined | V[], any, any>An optional parallel iterable of values.
OptionalisBalanceAdd: boolean = trueIf true, builds a balanced tree from the items.
OptionaliterationType: IterationType = ...The traversal method for balanced add (recursive or iterative).
An array of booleans indicating the success of each individual add operation.
Delete a node by key/node/entry and rebalance as needed.
Array with deletion metadata (removed node, rebalancing hint if any).
Performs a Depth-First Search (DFS) traversal.
Optionalcallback: C = ...Function to call on each node.
Optionalpattern: DFSOrderPattern = 'IN'The traversal order ('IN', 'PRE', 'POST').
OptionalonlyOne: boolean = falseIf true, stops after the first callback.
OptionalstartNode: The node to start from.
OptionaliterationType: IterationType = ...The traversal method.
An array of callback results.
Gets the value associated with a key.
The key, node, or entry to get the value for.
OptionalstartNode: The node to start searching from (if not in Map mode).
OptionaliterationType: IterationType = ...The traversal method (if not in Map mode).
The associated value, or undefined.
Finds the leftmost node in a subtree (the node with the smallest key in a BST).
The type of the callback function.
The callback result for the leftmost node.
Gets the first node matching a predicate.
The key, node, entry, or predicate function to search for.
OptionalstartNode: BSTNOptKeyOrNode<K, BSTNode<K, V[]>> = ...The node to start the search from.
OptionaliterationType: IterationType = ...The traversal method.
The first matching node, or undefined if not found.
Gets all nodes matching a predicate.
The key, node, entry, or predicate function to search for.
OptionalonlyOne: booleanIf true, stops after finding the first match.
OptionalstartNode: The node to start the search from.
OptionaliterationType: IterationTypeThe traversal method.
An array of matching nodes.
Gets the Morris traversal predecessor (rightmost node in the left subtree, or node itself).
The node to find the predecessor for.
The Morris predecessor.
Finds the rightmost node in a subtree (the node with the largest key in a BST).
The type of the callback function.
The callback result for the rightmost node.
Gets the in-order successor of a node in a BST.
Optionalx: null | K | BinaryTreeNode<K, V[]>The node to find the successor of.
The successor node, or null/undefined if none exists.
Checks if a node matching the predicate exists in the tree.
OptionalkeyNodeEntryOrPredicate: The key, node, entry, or predicate to check for.
OptionalstartNode: The node to start the search from.
OptionaliterationType: IterationTypeThe traversal method.
True if a matching node exists, false otherwise.
Whether there exists an entry with the given value.
Value to test.
true if found; otherwise false.
Type guard: check whether the input is a RedBlackTreeNode.
True if the value is a RedBlackTreeNode.
Checks if the given item is a Range object.
The item to check.
True if it's a Range, false otherwise.
Checks if the given item is a "real" node (i.e., not null, undefined, or NIL).
True if it's a real node, false otherwise.
Checks if the given item is either a "real" node or null.
True if it's a real node or null, false otherwise.
Traverses the tree and returns nodes that are lesser or greater than a target node.
Optionalcallback: C = ...Function to call on matching nodes.
OptionallesserOrGreater: CP = -11 for lesser, 1 for greater, 0 for equal.
OptionaltargetNode: The node to compare against.
OptionaliterationType: IterationType = ...The traversal method.
An array of callback results.
Transform entries into a like-kind red-black tree with possibly different key/value types.
A new RedBlackTree with mapped entries.
Merges another tree into this one by adding all its nodes.
The tree to merge.
Performs an optimized search for nodes within a given key range.
A Range object or a [low, high] tuple.
Optionalcallback: C = ...A function to call on matching nodes.
OptionalstartNode: The node to start the search from.
OptionaliterationType: IterationType = ...The traversal method.
An array of callback results.
Searches the tree for nodes matching a predicate, key, or range.
The key, node, entry, predicate, or range to search for.
OptionalonlyOne: boolean = falseIf true, stops after finding the first match.
Optionalcallback: C = ...A function to call on matching nodes.
OptionalstartNode: The node to start the search from.
OptionaliterationType: IterationType = ...Whether to use 'RECURSIVE' or 'ITERATIVE' search.
An array of results from the callback function for each matching node.
Red-Black Tree–based multimap (key → array of values). Preserves O(log N) updates and supports map-like mode.
Remarks
Time O(1), Space O(1)
Example