Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

js-redblacktree

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

js-redblacktree

Package implements left leaning red black balanced search tree for symbol table key-sorted map

  • 1.0.6
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

js-redblacktree

Package provides javascript implementation of red black tree. The api of the red black tree is designed so that it matches with the api of the Java counterpart SortedMap api.

Build Status Coverage Status

Install

Run the following npm command to install

npm install js-redblacktree

Usage

To sort an array "a" using any of the sorting algorithms:

var jsrbtree = require("js-redblacktree");

var bst = new jsrbtree.RedBlackTree();
      
bst.put(2, 2.4);
bst.put(4, 3.2);
bst.put(5, 3.4);
bst.put(6, 3.4);
bst.put(6, 5.4);

console.log(bst.get(2)); // display 2.4
console.log(bst.get(6)); // display 5.4
console.log(bst.containsKey(6)); // display true

console.log(bst.size()); // display 4;
console.log(bst.isEmpty()); // display false

bst.delete(6); 
console.log(bst.size()); // display 3
console.log(bst.containsKey(6)); // display false;
console.log(bst.get(6)); // display undefined

// print out sorted keys

var keys = bst.keySet();
for(var i = 1; i < keys.length; ++i) {
    console.log(keys[i]);
}

Keywords

FAQs

Package last updated on 26 May 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc