Skip to main content
Home

Built and signed on GitHub Actions

Common data structures like red-black trees and binary heaps

This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
This package works with Browsers
JSR Score
100%
Published
5 months ago (1.0.9)

Data structures for use in algorithms and other data manipulation.

import { BinarySearchTree } from "@std/data-structures";
import { assertEquals } from "@std/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]);
Built and signed on
GitHub Actions

New Ticket: Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@std/data-structures

Import symbol

import * as data_structures from "@std/data-structures";
or

Import directly with a jsr specifier

import * as data_structures from "jsr:@std/data-structures";

Add Package

pnpm i jsr:@std/data-structures
or (using pnpm 10.8 or older)
pnpm dlx jsr add @std/data-structures

Import symbol

import * as data_structures from "@std/data-structures";

Add Package

yarn add jsr:@std/data-structures
or (using Yarn 4.8 or older)
yarn dlx jsr add @std/data-structures

Import symbol

import * as data_structures from "@std/data-structures";

Add Package

vlt install jsr:@std/data-structures

Import symbol

import * as data_structures from "@std/data-structures";

Add Package

npx jsr add @std/data-structures

Import symbol

import * as data_structures from "@std/data-structures";

Add Package

bunx jsr add @std/data-structures

Import symbol

import * as data_structures from "@std/data-structures";