https://github.com/yaxingson/es-containers
Implementation of various data structures and algorithms in javascript
https://github.com/yaxingson/es-containers
algorithm datastructures list map set sort
Last synced: 8 months ago
JSON representation
Implementation of various data structures and algorithms in javascript
- Host: GitHub
- URL: https://github.com/yaxingson/es-containers
- Owner: yaxingson
- License: other
- Created: 2024-11-25T10:26:37.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-12-16T11:27:39.000Z (12 months ago)
- Last Synced: 2025-04-13T04:43:07.177Z (8 months ago)
- Topics: algorithm, datastructures, list, map, set, sort
- Language: TypeScript
- Homepage:
- Size: 91.8 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# es-containers





## Get started
### Install
Use package manager:
```shell
$ npm i es-containers --save
```
CDN:
```html
```
### Usage
```js
// commonjs
const { Stack, HashMap, BinaryTree } = require('es-containers')
const { ArrayList, Queue } = require('es-containers/list')
// esm
import { Stack, HashMap, BinaryTree } from 'es-containers'
import { ArrayList, Queue } from 'es-containers/list'
```
## Containers
- lists
- `ArrayList`: A list backed by a dynamic array that grows and shrinks implicitly.
- `LinkedList`: A list where each element points to the next element in the list.
- `DoublyLinkedList`: A list where each element points to the next and previous elements in the list.
- `LinkedListStack`
- `ArrayStack`
- `LinkedListQueue`
- `ArrayQueue`
- `PriorityQueue`
- Sets
- `HashSet`: A set backed by a hash table. It makes no guarantees as to the iteration order of the set.
- `TreeSet`: A set backed by a red-black tree to keep the elements ordered with respect to the comparator.
- `LinkedHashSet`: A set that preserves insertion-order. Data structure is backed by a hash table to store values an`d doubly-linked list to store insertion ordering.
- Maps
- `HashMap`: A map based on hash tables. Keys are unordered.
- `TreeMap`: A map based on red-black tree. Keys are ordered with respect to the comparator.
- `LinkedHashMap`: A map that preserves insertion-order. It is backed by a hash table to store values and doubly-linked list to store ordering.
- `HashBidiMap`: A map based on two hashmaps. Keys are unordered.
- `TreeBidiMap`: A map based on red-black tree
- Trees
- `RedBlackTree`
- `BinaryTree`
- `BTree`
- `AVLTree`
- Graphs
- `DirectedGraph`
## Examples
### Lists
```js
import { LinkedList, ArrayStack } from 'es-containers/list'
import { StringComparator } from 'es-containers/util'
```
### Sets
```js
import { HashSet } from 'es-containers/set'
````
### Maps
```js
import { HashMap } from 'es-containers/map'
```
### Trees
```js
import { BinaryTree } from 'es-containers/tree'
```
### Graphs
```js
import { DirectedGraph } from 'es-containers/graph'
```
## Test & Benchmark