SkillAgentSearch skills...

Redblack.js

Red-black tree for Node.js and the browser

Install / Use

/learn @scttnlsn/Redblack.js
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

redblack.js

redblack.js is a red-black tree implementation for Node.js and the browser.

Usage

var tree = redblack.tree();

tree.insert('foo', 'bar');
tree.get('foo'); // -> 'bar'

tree.delete('foo');
tree.get('foo'); // -> null

tree.forEach(function(value, key) {
    console.log(key + '=' + value);
});

Download

Releases are available on GitHub or via NPM.

npm install redblack

Development: redblack.js

Production: redblack.min.js

Tree API

insert(key, value)

Insert the given key/value pair into the tree.

Arguments:

  • key
  • value

get(key)

Get the value mapped to the given key or null if no such value exists.

Arguments:

  • key

delete(key)

Remove the given key from the tree

Arguments:

  • key

range(start, end)

Returns a Cursor (see below) for traversing the tree in the given range (inclusive).

Arguments:

  • start - the lower bound of the range, if undefined then assumed to be the minimum value in the tree
  • end - the upper bound of the range, if undefined the assumed to be the maximum value in the tree

forEach(iterator)

Cursor shortcut for iterating over the entire tree (see forEach below).

map(iterator)

Cursor shortcut for mapping over the entire tree (see map below).

<a name="cursor" /> Cursor API ---------- <a name="forEach" /> ### forEach(iterator)

Iterate over a set of nodes in order.

Arguments:

  • iterator(value, key, tree)
<a name="map" /> ### map(iterator)

Map over a set of nodes in order.

Arguments:

  • iterator(value, key, tree) - should return a result
View on GitHub
GitHub Stars19
CategoryDevelopment
Updated5y ago
Forks6

Languages

JavaScript

Security Score

75/100

Audited on Aug 4, 2020

No findings