@styiannis/data-structures

1.0.0 • Public • Published

@styiannis/data-structures

Build Status Coverage Status Libraries.io depndency status for GitHub repoMaintainability GitHub package.json version (branch) GitHub tag (latest by date) npm (scoped) GitHub

Javascript implementation of classic and advanced data structures.

Table of contents

Installation

Install via NPM:

$ npm install @styiannis/data-structures

Usage

Print data structures list

const ds = require('@styiannis/data-structures');

console.log( ds );

// Output:

{
  'BTree': [Function: BTree],
  'BinarySearchTree': [Function: BinarySearchTree],
  'LeftThreadedBinarySearchTree': [Function: LeftThreadedBinarySearchTree],
  'RedBlackTree': [Function: RedBlackTree],
  'RightThreadedBinarySearchTree': [Function: RightThreadedBinarySearchTree],
  'ThreadedBinarySearchTree': [Function: ThreadedBinarySearchTree]
}

Basic data structure usage

const { RedBlackTree } = require('@styiannis/data-structures');

// Create a Red-black tree
const rbt = RedBlackTree();

// Insert items into the tree
rbt.set( 46, 'foo' );
rbt.set( 13, 'baz' );
rbt.set( 75, 'bar' );

// Get tree item value specified by key
console.log( rbt.get( 13 ) );  // Output: 'baz'

// Check for key within the tree
console.log( rbt.has( 46 ) );  // Output: true

// Remove item from tree
console.log( rbt.delete( 75 ) );  // Output: true

Documentation

B trees

Binary search trees

License

This project is licensed under the MIT License

Package Sidebar

Install

npm i @styiannis/data-structures

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

151 kB

Total Files

82

Last publish

Collaborators

  • styiannis01