Skip to main content
Module

x/collections/mod.ts

Collection data structures that are not standard built-in objects in JavaScript. This includes a vector (double-ended queue), binary heap (priority queue), binary search tree, and a red black tree.
Very Popular
Go to Latest
import * as collections from "https://deno.land/x/collections@v0.10.1/mod.ts";

Classes

A priority queue implemented with a binary heap. The heap is in decending order by default, using JavaScript's built in comparison operators to sort the values.

A 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. The values are in ascending order by default, using JavaScript's built in comparison operators to sort the values.

A double-ended queue implemented with a growable ring buffer. Vector is faster than JavaScript's built in Array class for shifting and unshifting because it only requires reallocation when increasing the capacity.

Functions

Compares its two arguments for ascending order using JavaScript's built in comparison operators. All undefined elements are sorted to the end.

Compares its two arguments for descending order using JavaScript's built in comparison operators. All undefined elements are sorted to the end.

Returns a random integer within a range.

Generates an array of integers within a range.

Shuffles an array in-place using the Fisher-Yates shuffle algorithm then returns it.

Swaps the values at two indexes in an array.

Type Aliases

This module is browser compatible.