@ende/data-structures
ende add jsr:@ende/data-structuresVersion 2026.10.15 on JSR.
Data structures for use in algorithms and other data manipulation.
import { BinarySearchTree } from "@ende/data-structures";
import { assertEquals } from "@ende/assert";
const values = [3, 10, 13, 4, 6, 7, 1, 14];
const tree = new BinarySearchTree<number>();
values.forEach((value) => tree.insert(value));
assertEquals([...tree], [1, 3, 4, 6, 7, 10, 13, 14]);
assertEquals(tree.min(), 1);
assertEquals(tree.max(), 14);
assertEquals(tree.find(42), null);
assertEquals(tree.find(7), 7);
assertEquals(tree.remove(42), false);
assertEquals(tree.remove(7), true);
assertEquals([...tree], [1, 3, 4, 6, 10, 13, 14]);
Modules
@ende/data-structures/binary-heap@ende/data-structures/binary-search-tree@ende/data-structures/comparators@ende/data-structures/deque@ende/data-structures/red-black-tree@ende/data-structures/unstable-2d-array@ende/data-structures/unstable-bidirectional-map@ende/data-structures/unstable-binary-search-tree@ende/data-structures/unstable-indexed-heap@ende/data-structures/unstable-multimap@ende/data-structures/unstable-rolling-counter
Exports
ascend— Compare two values in ascending order using JavaScript's built in comparison operators.BinaryHeap— 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.BinarySearchTree— An unbalanced binary search tree. The values are in ascending order by default, using JavaScript's built-in comparison operators to sort the values.Deque— A double-ended queue backed by a ring buffer. Pushing, popping, and indexed access stay fast as the deque grows.descend— Compare two values in descending order using JavaScript's built in comparison operators.ReadonlyDeque— Read-only view of a Deque. Strips all mutation methods, following the `ReadonlyArray` / `ReadonlyMap` / `ReadonlySet` pattern. A `Deque<T>` is directly assignable to `ReadonlyDeque<T>`.RedBlackTree— A red-black tree. This is a kind of self-balancing binary search tree, extending BinarySearchTree. The values are in ascending order by default, using JavaScript's built-in comparison operators to sort the values.