Miss any of our Open RFC calls?Watch the recordings here! »

datastructures-js

8.1.0 • Public • Published

build:? npm npm npm

consolidates all data structures of @datastructures-js into a single repository. Data structures are distributed into their own repositories for easier maintenance and usability so that they can be installed and imported individually in the code.

Table of Contents

install

npm install --save datastructures-js

API

require

// import your required classes
const {
  Queue,
  Stack,
  Set: EnhancedSet, // renamed to avoid conflict with es6 Set 
  LinkedList,
  DoublyLinkedList,
  MinHeap,
  MaxHeap,
  MinPriorityQueue,
  MaxPriorityQueue,
  Graph,
  DirectedGraph,
  BinarySearchTree,
  AvlTree,
  Trie
= require('datastructures-js');

import

// import your required classes
import {
  Queue,
  PriorityQueue,
  Stack,
  Set as EnhancedSet, // renamed to avoid conflict with es6 Set
  LinkedList,
  DoublyLinkedList,
  MinHeap,
  MaxHeap,
  MinPriorityQueue,
  MaxPriorityQueue,
  Graph,
  DirectedGraph,
  BinarySearchTree,
  AvlTree,
  Trie
} from 'datastructures-js';

extend

There are sometimes domain-specific use cases for data structures that require either a tweak or additional functionality. Data structures here are implemented as a base general purpose classes in ES6. You can always use any of these classes to override or extend the functionality in your own code.

Example

const { Graph } = require('datastructures-js'); // OR require('@datastructures-js/graph')
 
class BusStationsGraph extends Graph {
  findShortestPath(srcStationId, destStationId) {
    // benefit from Graph to implement your own code 
  }
}

Data Structures

Queue

https://github.com/datastructures-js/queue

Stack

https://github.com/datastructures-js/stack

Set

https://github.com/datastructures-js/set

Linked List

https://github.com/datastructures-js/linked-list

Doubly Linked List

https://github.com/datastructures-js/linked-list

Min Heap

https://github.com/datastructures-js/heap

Max Heap

https://github.com/datastructures-js/heap

Min Priority Queue

https://github.com/datastructures-js/priority-queue

Max Priority Queue

https://github.com/datastructures-js/priority-queue

Graph

https://github.com/datastructures-js/graph

Directed Graph

https://github.com/datastructures-js/graph

Binary Search Tree

https://github.com/datastructures-js/binary-search-tree

AVL Tree

https://github.com/datastructures-js/binary-search-tree

Trie

https://github.com/datastructures-js/trie

Build

grunt build

Contribution

If you'd like to contribute to the project to improve the implemented data structures or add new ones, feel free to fork the corresponding data structure repo in your github or get in touch to create a new data structure repo to work on! The code just needs to be consistent with the existing structure and style, as well as tests and README. Once done, please open a PR from development branch of the repo. Thanks 🌠

License

The MIT License. Full License is here

Install

npm i datastructures-js

DownloadsWeekly Downloads

181

Version

8.1.0

License

MIT

Unpacked Size

9.04 kB

Total Files

5

Last publish

Collaborators

  • avatar