AbstractThe number of edges on the longest path from the root to a leaf: -1 for
an empty tree and 0 for a tree with a single value. O(1).
The number of values in the tree. O(1).
Same as SortedTree.values.
Removes all values.
Calls callback for every value in ascending order.
OptionalthisArg: unknownInserts value unless an equal value is already stored (that value is
kept as is).
true if the value was inserted.
Returns the largest value, or undefined if the tree is empty.
Returns the smallest value, or undefined if the tree is empty.
Removes and returns the largest value.
Removes and returns the smallest value.
Iterates over the values within the bounds, in ascending order unless
reverse is set. Modifications during the iteration follow the same rules
as for SortedTree.values.
Optionaloptions: RangeOptions<T>Returns the values in ascending order.
Iterates over the values in ascending order.
The tree may be modified during the iteration: removed values are
skipped, values inserted ahead of the iterator are visited and values
inserted behind it are not. Unlike with a Set, a value is never visited
twice, even if it is deleted and inserted again.
After the tree changes, the iterator finds its place again by comparing with the last value it returned. While you use the iterator, do not change the fields the comparator reads of that value, even after removing it from the tree.
Iterates over the values in descending order. Modifications during the iteration follow the same rules as for SortedTree.values.
A sorted collection of unique values, ordered by a Comparator. BSTree and AVLTree share this API; use this type to accept either of them.
Values are unique with respect to the comparator: inserting a value equal to a stored one keeps the stored one. Iteration yields values in ascending order.
Every method that takes a value passes it to the comparator, even when the tree is empty, so a value the comparator rejects (such as
NaNwith the default comparator) throws whether the tree is empty or not.The comparator must not modify the tree it orders: the mutating methods (
insert,getOrInsert,delete,clear,popMinandpopMax) throw aTypeErrorwhen the comparator calls them, and leave the tree unchanged.