项目作者: styiannis

项目描述 :
Javascript implementation of classic and advanced data structures
高级语言: JavaScript
项目地址: git://github.com/styiannis/data-structures-js.git
创建时间: 2020-10-30T05:06:22Z
项目社区:https://github.com/styiannis/data-structures-js

开源协议:MIT License

下载


@styiannis/data-structures

Build Status
Coverage Status
Known Vulnerabilities
Maintainability
@styiannis/data-structures"">npm (scoped)
GitHub

Javascript implementation of classic and advanced data structures.

Table of contents

Installation

Install via NPM:

  1. $ npm install @styiannis/data-structures

Usage

Print data structures list

  1. const ds = require('@styiannis/data-structures');
  2. console.log( ds );
  3. // Output:
  4. {
  5. 'BTree': [Function: BTree],
  6. 'BinarySearchTree': [Function: BinarySearchTree],
  7. 'LeftThreadedBinarySearchTree': [Function: LeftThreadedBinarySearchTree],
  8. 'RedBlackTree': [Function: RedBlackTree],
  9. 'RightThreadedBinarySearchTree': [Function: RightThreadedBinarySearchTree],
  10. 'ThreadedBinarySearchTree': [Function: ThreadedBinarySearchTree]
  11. }

Basic data structure usage

  1. const { RedBlackTree } = require('@styiannis/data-structures');
  2. // Create a Red-black tree
  3. const rbt = RedBlackTree();
  4. // Insert items into the tree
  5. rbt.set( 46, 'foo' );
  6. rbt.set( 13, 'baz' );
  7. rbt.set( 75, 'bar' );
  8. // Get tree item value specified by key
  9. console.log( rbt.get( 13 ) ); // Output: 'baz'
  10. // Check for key within the tree
  11. console.log( rbt.has( 46 ) ); // Output: true
  12. // Remove item from tree
  13. console.log( rbt.delete( 75 ) ); // Output: true

Documentation

B trees

Binary search trees

License

This project is licensed under the MIT License