@std/data-structures@0.215.0
Classes
A priority queue implemented with a binary heap. The heap is in descending order by default, using JavaScript's built-in comparison operators to sort the values.
- clear(): void
Removes all values from the binary heap.
- drain(): IterableIterator<T>
Returns an iterator for retrieving and removing values from the binary heap.
- from<T>(collection: ArrayLike<T> | Iterable<T> | BinaryHeap<T>): BinaryHeap<T>
Creates a new binary heap from an array like or iterable object.
- isEmpty(): boolean
Checks if the binary heap is empty.
- length(): number
The amount of values stored in the binary heap.
- peek(): T | undefined
Returns the greatest value in the binary heap, or undefined if it is empty.
- pop(): T | undefined
Removes the greatest value from the binary heap and returns it, or null if it is empty.
- push(...values: T[]): number
Adds values to the binary heap.
- toArray(): T[]
Returns the underlying cloned array in arbitrary order without sorting
An unbalanced binary search tree. The values are in ascending order by default, using JavaScript's built-in comparison operators to sort the values.
- _size: numberNo documentation available
- clear(): void
Removes all values from the binary search tree.
- find(value: T): T | null
Returns node value if found in the binary search tree.
- findNode(value: T): BinarySearchNode<T> | nullNo documentation available
- from<T>(collection: ArrayLike<T> | Iterable<T> | BinarySearchTree<T>): BinarySearchTree<T>
Creates a new binary search tree from an array like or iterable object.
- insert(value: T): boolean
Adds the value to the binary search tree if it does not already exist in it. Returns true if successful.
- insertNode(): BinarySearchNode<T> | nullNode: BinarySearchNode,value: TNo documentation available
- isEmpty(): boolean
Checks if the binary search tree is empty.
- lnrValues(): IterableIterator<T>
Returns an iterator that uses in-order (LNR) tree traversal for retrieving values from the binary search tree.
- lrnValues(): IterableIterator<T>
Returns an iterator that uses post-order (LRN) tree traversal for retrieving values from the binary search tree.
- lvlValues(): IterableIterator<T>
Returns an iterator that uses level order tree traversal for retrieving values from the binary search tree.
- max(): T | null
Returns the maximum value in the binary search tree or null if empty.
- min(): T | null
Returns the minimum value in the binary search tree or null if empty.
- nlrValues(): IterableIterator<T>
Returns an iterator that uses pre-order (NLR) tree traversal for retrieving values from the binary search tree.
- remove(value: T): boolean
Removes node value from the binary search tree if found. Returns true if found and removed.
- removeNode(node: BinarySearchNode<T>): BinarySearchNode<T> | null
Removes the given node, and returns the node that was physically removed from the tree.
- rnlValues(): IterableIterator<T>
Returns an iterator that uses reverse in-order (RNL) tree traversal for retrieving values from the binary search tree.
- root: BinarySearchNode<T> | nullNo documentation available
- rotateNode(): voidnode: BinarySearchNode<T>,direction: DirectionNo documentation available
- size(): number
The amount of values stored in the binary search tree.
A red-black tree. This is a kind of self-balancing binary search tree. The values are in ascending order by default, using JavaScript's built-in comparison operators to sort the values.
- from<T>(collection: ArrayLike<T> | Iterable<T> | RedBlackTree<T>): RedBlackTree<T>
Creates a new red-black tree from an array like or iterable object.
- insert(value: T): boolean
Adds the value to the binary search tree if it does not already exist in it. Returns true if successful.
- remove(value: T): boolean
Removes node value from the binary search tree if found. Returns true if found and removed.
- removeFixup(): voidparent: RedBlackNode<T> | null,current: RedBlackNode<T> | nullNo documentation available
- root: RedBlackNode<T> | nullNo documentation available
Functions
Classes
A priority queue implemented with a binary heap. The heap is in descending order by default, using JavaScript's built-in comparison operators to sort the values.
- clear(): void
Removes all values from the binary heap.
- drain(): IterableIterator<T>
Returns an iterator for retrieving and removing values from the binary heap.
- from<T>(collection: ArrayLike<T> | Iterable<T> | BinaryHeap<T>): BinaryHeap<T>
Creates a new binary heap from an array like or iterable object.
- isEmpty(): boolean
Checks if the binary heap is empty.
- length(): number
The amount of values stored in the binary heap.
- peek(): T | undefined
Returns the greatest value in the binary heap, or undefined if it is empty.
- pop(): T | undefined
Removes the greatest value from the binary heap and returns it, or null if it is empty.
- push(...values: T[]): number
Adds values to the binary heap.
- toArray(): T[]
Returns the underlying cloned array in arbitrary order without sorting
Classes
An unbalanced binary search tree. The values are in ascending order by default, using JavaScript's built-in comparison operators to sort the values.
- _size: numberNo documentation available
- clear(): void
Removes all values from the binary search tree.
- find(value: T): T | null
Returns node value if found in the binary search tree.
- findNode(value: T): BinarySearchNode<T> | nullNo documentation available
- from<T>(collection: ArrayLike<T> | Iterable<T> | BinarySearchTree<T>): BinarySearchTree<T>
Creates a new binary search tree from an array like or iterable object.
- insert(value: T): boolean
Adds the value to the binary search tree if it does not already exist in it. Returns true if successful.
- insertNode(): BinarySearchNode<T> | nullNode: BinarySearchNode,value: TNo documentation available
- isEmpty(): boolean
Checks if the binary search tree is empty.
- lnrValues(): IterableIterator<T>
Returns an iterator that uses in-order (LNR) tree traversal for retrieving values from the binary search tree.
- lrnValues(): IterableIterator<T>
Returns an iterator that uses post-order (LRN) tree traversal for retrieving values from the binary search tree.
- lvlValues(): IterableIterator<T>
Returns an iterator that uses level order tree traversal for retrieving values from the binary search tree.
- max(): T | null
Returns the maximum value in the binary search tree or null if empty.
- min(): T | null
Returns the minimum value in the binary search tree or null if empty.
- nlrValues(): IterableIterator<T>
Returns an iterator that uses pre-order (NLR) tree traversal for retrieving values from the binary search tree.
- remove(value: T): boolean
Removes node value from the binary search tree if found. Returns true if found and removed.
- removeNode(node: BinarySearchNode<T>): BinarySearchNode<T> | null
Removes the given node, and returns the node that was physically removed from the tree.
- rnlValues(): IterableIterator<T>
Returns an iterator that uses reverse in-order (RNL) tree traversal for retrieving values from the binary search tree.
- root: BinarySearchNode<T> | nullNo documentation available
- rotateNode(): voidnode: BinarySearchNode<T>,direction: DirectionNo documentation available
- size(): number
The amount of values stored in the binary search tree.
Type Aliases
Classes
A red-black tree. This is a kind of self-balancing binary search tree. The values are in ascending order by default, using JavaScript's built-in comparison operators to sort the values.
- from<T>(collection: ArrayLike<T> | Iterable<T> | RedBlackTree<T>): RedBlackTree<T>
Creates a new red-black tree from an array like or iterable object.
- insert(value: T): boolean
Adds the value to the binary search tree if it does not already exist in it. Returns true if successful.
- remove(value: T): boolean
Removes node value from the binary search tree if found. Returns true if found and removed.
- removeFixup(): voidparent: RedBlackNode<T> | null,current: RedBlackNode<T> | nullNo documentation available
- root: RedBlackNode<T> | nullNo documentation available