Module

std/data_structures/mod.ts

The Deno Standard Library
Go to Latest
import * as mod from "https://dotland.deno.dev/std@0.223.0/data_structures/mod.ts";

Data structures for use in algorithms and other data manipulation.

import { BinarySearchTree } from "https://deno.land/std@0.223.0/data_structures/mod.ts";

const values = [3, 10, 13, 4, 6, 7, 1, 14];
const tree = new BinarySearchTree<number>();
values.forEach((value) => tree.insert(value));

[...tree]; // [ 1, 3, 4, 6, 7, 10, 13, 14 ]
tree.min(); // 1
tree.max(); // 14
tree.find(42); // null
tree.find(7); // 7
tree.remove(42); // false
tree.remove(7); // true
[...tree]; // [ 1, 3, 4, 6, 10, 13, 14 ]

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.

An unbalanced binary search tree. The values are in ascending order by default, using JavaScript's built-in comparison operators to sort the values.

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.

Functions

Compares its two arguments for ascending order using JavaScript's built in comparison operators.

Compares its two arguments for descending order using JavaScript's built in comparison operators.