2023-08-11 11:21:34 +00:00
|
|
|
# data-structure-typed
|
|
|
|
|
2023-08-12 15:23:09 +00:00
|
|
|
Javascript Data Structure, TypeScript Data Structure Library
|
|
|
|
|
2023-08-11 11:21:34 +00:00
|
|
|
## install
|
|
|
|
|
|
|
|
### yarn
|
|
|
|
|
|
|
|
```bash
|
|
|
|
yarn add data-structure-typed
|
|
|
|
```
|
|
|
|
|
|
|
|
### npm
|
|
|
|
|
|
|
|
```bash
|
|
|
|
npm install data-structure-typed
|
|
|
|
```
|
2023-08-11 04:02:16 +00:00
|
|
|
|
2023-08-14 00:47:26 +00:00
|
|
|
## api docs
|
|
|
|
|
|
|
|
[api docs](https://data-structure-typed-docs.vercel.app/)
|
|
|
|
|
2023-08-14 00:59:00 +00:00
|
|
|
<nav class="tsd-navigation"><a href="modules.html" class="current"><span>data-<wbr/>structure-<wbr/>typed</span></a>
|
|
|
|
<ul class="tsd-small-nested-navigation">
|
|
|
|
<li><a href="https://data-structure-typed-docs.vercel.app/enums/CP.html"><span>CP</span></a></li>
|
|
|
|
<li><a href="https://data-structure-typed-docs.vercel.app/enums/FamilyPosition.html"><span>Family<wbr/>Position</span></a></li>
|
|
|
|
<li><a href="https://data-structure-typed-docs.vercel.app/enums/LoopType.html"><span>Loop<wbr/>Type</span></a></li>
|
|
|
|
<li><a href="https://data-structure-typed-docs.vercel.app/classes/AVLTree.html"><span>AVLTree</span></a></li>
|
|
|
|
<li><a href="https://data-structure-typed-docs.vercel.app/classes/AVLTreeNode.html"><span>AVLTree<wbr/>Node</span></a></li>
|
|
|
|
<li><a href="https://data-structure-typed-docs.vercel.app/classes/AaTree.html"><span>Aa<wbr/>Tree</span></a></li>
|
|
|
|
<li><a href="https://data-structure-typed-docs.vercel.app/classes/AbstractEdge.html"><span>Abstract<wbr/>Edge</span></a></li>
|
|
|
|
<li><a href="https://data-structure-typed-docs.vercel.app/classes/AbstractGraph.html"><span>Abstract<wbr/>Graph</span></a></li>
|
|
|
|
<li><a href="https://data-structure-typed-docs.vercel.app/classes/AbstractVertex.html"><span>Abstract<wbr/>Vertex</span></a></li>
|
|
|
|
<li><a href="https://data-structure-typed-docs.vercel.app/classes/ArrayDeque.html"><span>Array<wbr/>Deque</span></a></li>
|
|
|
|
<li><a href="https://data-structure-typed-docs.vercel.app/classes/BST.html"><span>BST</span></a></li>
|
|
|
|
<li><a href="https://data-structure-typed-docs.vercel.app/classes/BSTNode.html"><span>BSTNode</span></a></li>
|
|
|
|
<li><a href="https://data-structure-typed-docs.vercel.app/classes/BTree.html"><span>BTree</span></a></li>
|
|
|
|
<li><a href="https://data-structure-typed-docs.vercel.app/classes/BinaryIndexedTree.html"><span>Binary<wbr/>Indexed<wbr/>Tree</span></a></li>
|
|
|
|
<li><a href="https://data-structure-typed-docs.vercel.app/classes/BinaryTree.html"><span>Binary<wbr/>Tree</span></a></li>
|
|
|
|
<li><a href="https://data-structure-typed-docs.vercel.app/classes/BinaryTreeNode.html"><span>Binary<wbr/>Tree<wbr/>Node</span></a></li>
|
|
|
|
<li><a href="https://data-structure-typed-docs.vercel.app/classes/Character.html"><span>Character</span></a></li>
|
|
|
|
<li><a href="https://data-structure-typed-docs.vercel.app/classes/CoordinateMap.html"><span>Coordinate<wbr/>Map</span></a></li>
|
|
|
|
<li><a href="https://data-structure-typed-docs.vercel.app/classes/CoordinateSet.html"><span>Coordinate<wbr/>Set</span></a></li>
|
|
|
|
<li><a href="https://data-structure-typed-docs.vercel.app/classes/Deque.html"><span>Deque</span></a></li>
|
|
|
|
<li><a href="https://data-structure-typed-docs.vercel.app/classes/DirectedEdge.html"><span>Directed<wbr/>Edge</span></a></li>
|
|
|
|
<li><a href="https://data-structure-typed-docs.vercel.app/classes/DirectedGraph.html"><span>Directed<wbr/>Graph</span></a></li>
|
|
|
|
<li><a href="https://data-structure-typed-docs.vercel.app/classes/DirectedVertex.html"><span>Directed<wbr/>Vertex</span></a></li>
|
|
|
|
<li><a href="https://data-structure-typed-docs.vercel.app/classes/DoublyLinkedList.html"><span>Doubly<wbr/>Linked<wbr/>List</span></a></li>
|
|
|
|
<li><a href="https://data-structure-typed-docs.vercel.app/classes/DoublyLinkedListNode.html"><span>Doubly<wbr/>Linked<wbr/>List<wbr/>Node</span></a></li>
|
|
|
|
<li><a href="https://data-structure-typed-docs.vercel.app/classes/Heap.html"><span>Heap</span></a></li>
|
|
|
|
<li><a href="https://data-structure-typed-docs.vercel.app/classes/Matrix2D.html"><span>Matrix2D</span></a></li>
|
|
|
|
<li><a href="https://data-structure-typed-docs.vercel.app/classes/MatrixNTI2D.html"><span>MatrixNTI2D</span></a></li>
|
|
|
|
<li><a href="https://data-structure-typed-docs.vercel.app/classes/MaxHeap.html"><span>Max<wbr/>Heap</span></a></li>
|
|
|
|
<li><a href="https://data-structure-typed-docs.vercel.app/classes/MaxPriorityQueue.html"><span>Max<wbr/>Priority<wbr/>Queue</span></a></li>
|
|
|
|
<li><a href="https://data-structure-typed-docs.vercel.app/classes/MinHeap.html"><span>Min<wbr/>Heap</span></a></li>
|
|
|
|
<li><a href="https://data-structure-typed-docs.vercel.app/classes/MinPriorityQueue.html"><span>Min<wbr/>Priority<wbr/>Queue</span></a></li>
|
|
|
|
<li><a href="https://data-structure-typed-docs.vercel.app/classes/Navigator.html"><span>Navigator</span></a></li>
|
|
|
|
<li><a href="https://data-structure-typed-docs.vercel.app/classes/ObjectDeque.html"><span>Object<wbr/>Deque</span></a></li>
|
|
|
|
<li><a href="https://data-structure-typed-docs.vercel.app/classes/PriorityQueue.html"><span>Priority<wbr/>Queue</span></a></li>
|
|
|
|
<li><a href="https://data-structure-typed-docs.vercel.app/classes/Queue.html"><span>Queue</span></a></li>
|
|
|
|
<li><a href="https://data-structure-typed-docs.vercel.app/classes/RBTree.html"><span>RBTree</span></a></li>
|
|
|
|
<li><a href="https://data-structure-typed-docs.vercel.app/classes/SegmentTree.html"><span>Segment<wbr/>Tree</span></a></li>
|
|
|
|
<li><a href="https://data-structure-typed-docs.vercel.app/classes/SegmentTreeNode.html"><span>Segment<wbr/>Tree<wbr/>Node</span></a></li>
|
|
|
|
<li><a href="https://data-structure-typed-docs.vercel.app/classes/SinglyLinkedList.html"><span>Singly<wbr/>Linked<wbr/>List</span></a></li>
|
|
|
|
<li><a href="https://data-structure-typed-docs.vercel.app/classes/SinglyLinkedListNode.html"><span>Singly<wbr/>Linked<wbr/>List<wbr/>Node</span></a></li>
|
|
|
|
<li><a href="https://data-structure-typed-docs.vercel.app/classes/SplayTree.html"><span>Splay<wbr/>Tree</span></a></li>
|
|
|
|
<li><a href="https://data-structure-typed-docs.vercel.app/classes/Stack.html"><span>Stack</span></a></li>
|
|
|
|
<li><a href="https://data-structure-typed-docs.vercel.app/classes/TreeMultiSet.html"><span>Tree<wbr/>Multi<wbr/>Set</span></a></li>
|
|
|
|
<li><a href="https://data-structure-typed-docs.vercel.app/classes/Trie.html"><span>Trie</span></a></li>
|
|
|
|
<li><a href="https://data-structure-typed-docs.vercel.app/classes/TrieNode.html"><span>Trie<wbr/>Node</span></a></li>
|
|
|
|
<li><a href="https://data-structure-typed-docs.vercel.app/classes/TwoThreeTree.html"><span>Two<wbr/>Three<wbr/>Tree</span></a></li>
|
|
|
|
<li><a href="https://data-structure-typed-docs.vercel.app/classes/UndirectedEdge.html"><span>Undirected<wbr/>Edge</span></a></li>
|
|
|
|
<li><a href="https://data-structure-typed-docs.vercel.app/classes/UndirectedGraph.html"><span>Undirected<wbr/>Graph</span></a></li>
|
|
|
|
<li><a href="https://data-structure-typed-docs.vercel.app/classes/UndirectedVertex.html"><span>Undirected<wbr/>Vertex</span></a></li>
|
|
|
|
<li><a href="https://data-structure-typed-docs.vercel.app/classes/Vector2D.html"><span>Vector2D</span></a></li></ul></nav>
|
|
|
|
|
2023-08-11 04:02:16 +00:00
|
|
|
## data structures
|
|
|
|
|
2023-08-12 15:23:09 +00:00
|
|
|
Meticulously crafted to empower developers with a versatile set of essential data structures. Our library includes a wide range of data structures:
|
|
|
|
Binary Tree, Binary Search Tree (BST), AVL Tree, Tree Multiset, Segment Tree, Binary Indexed Tree, Graph, Directed Graph, Undirected Graph, Linked List, Singly Linked List, Doubly Linked List, Queue, Object Deque, Array Deque, Stack, Hash, Coordinate Set, Coordinate Map, Heap, Priority Queue, Max Priority Queue, Min Priority Queue, Trie
|
2023-08-11 04:02:16 +00:00
|
|
|
<table>
|
2023-08-11 11:21:34 +00:00
|
|
|
<thead>
|
2023-08-11 04:02:16 +00:00
|
|
|
<tr>
|
|
|
|
<th>Data Structure</th>
|
2023-08-11 11:21:34 +00:00
|
|
|
<th>Derived</th>
|
|
|
|
<th>Basic Features</th>
|
|
|
|
<th>Additional Features</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
|
|
|
|
<tbody>
|
|
|
|
<tr>
|
|
|
|
<td>Binary Tree</td>
|
|
|
|
<td>AVL Tree, Binary Search Tree, Tree Multiset</td>
|
|
|
|
<td>put, has, get, remove, size, insertTo, insertMany, fill, getDepth, getHeight, getMinHeight, getPathToRoot, isBalanced </td>
|
|
|
|
<td>getLeftMost, isBST, getSubTreeSizeAndCount, subTreeSum, subTreeAdd, BFS, DFS, DFSIterative, levelIterative, listLevels, getPredecessor, morris, </td>
|
2023-08-11 04:02:16 +00:00
|
|
|
</tr>
|
2023-08-11 11:21:34 +00:00
|
|
|
|
2023-08-11 04:02:16 +00:00
|
|
|
<tr>
|
2023-08-11 11:21:34 +00:00
|
|
|
<td>AVL Tree</td>
|
|
|
|
<td></td>
|
|
|
|
<td>All the features inherited from Binary Tree, balanceFactor, updateHeight, balancePath, balanceLL, balanceLR, balanceRR, balanceRL</td>
|
|
|
|
<td></td>
|
2023-08-11 04:02:16 +00:00
|
|
|
</tr>
|
2023-08-11 11:21:34 +00:00
|
|
|
|
2023-08-11 04:02:16 +00:00
|
|
|
<tr>
|
2023-08-11 11:21:34 +00:00
|
|
|
<td>Binary Search Tree (BST)</td>
|
2023-08-11 04:02:16 +00:00
|
|
|
<td></td>
|
2023-08-11 11:21:34 +00:00
|
|
|
<td>All the features inherited from Binary Tree, lastKey</td>
|
|
|
|
<td>All the features inherited from Binary Tree, lesserSum, allGreaterNodesAdd, balance, isAVLBalanced</td>
|
2023-08-11 04:02:16 +00:00
|
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
2023-08-11 11:21:34 +00:00
|
|
|
<td>Tree Multiset</td>
|
|
|
|
<td></td>
|
|
|
|
<td>All the features inherited from Binary Tree</td>
|
|
|
|
<td>All the features inherited from Binary Tree</td>
|
|
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
|
|
<td>Segment Tree</td>
|
|
|
|
<td></td>
|
|
|
|
<td>build, updateNode, querySumByRange</td>
|
|
|
|
<td></td>
|
|
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
|
|
<td>Binary Indexed Tree</td>
|
|
|
|
<td></td>
|
|
|
|
<td>update, getPrefixSum, getRangeSum, BinaryIndexedTree.lowBit</td>
|
|
|
|
<td></td>
|
2023-08-11 04:02:16 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>Graph</td>
|
|
|
|
<td>Directed Graph, Undirected Graph</td>
|
2023-08-11 11:21:34 +00:00
|
|
|
<td>getVertex, getVertexId, containsVertex, vertexSet, addVertex, removeVertex, removeAllVertices, containsEdge, setEdgeWeight, getAllPathsBetween, getPathSumWeight, getMinCostBetween, getMinPathBetween, </td>
|
|
|
|
<td>dijkstra, dijkstraWithoutHeap, bellmanFord, floyd, tarjan</td>
|
2023-08-11 04:02:16 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
2023-08-11 11:21:34 +00:00
|
|
|
<td>Directed Graph</td>
|
|
|
|
<td></td>
|
|
|
|
<td>All the features inherited from Graph, getEdge, addEdge, removeEdgeBetween, removeEdge, removeAllEdges, incomingEdgesOf, outgoingEdgesOf, degreeOf, inDegreeOf, outDegreeOf, edgesOf, getEdgeSrc, getEdgeDest, getDestinations, edgeSet, getNeighbors, getEndsOfEdge</td>
|
|
|
|
<td>All the features inherited from Graph, topologicalSort</td>
|
2023-08-11 04:02:16 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
2023-08-11 11:21:34 +00:00
|
|
|
<td>Undirected Graph</td>
|
2023-08-11 04:02:16 +00:00
|
|
|
<td></td>
|
2023-08-11 11:21:34 +00:00
|
|
|
<td>All the features inherited from Graph, getEdge, addEdge, removeEdgeBetween, removeEdge, degreeOf, edgesOf, edgeSet, getEdgesOf, getNeighbors, getEndsOfEdge</td>
|
|
|
|
<td>All the features inherited from Graph</td>
|
2023-08-11 04:02:16 +00:00
|
|
|
</tr>
|
2023-08-11 11:21:34 +00:00
|
|
|
<tr>
|
|
|
|
<td>Singly Linked List</td>
|
|
|
|
<td></td>
|
|
|
|
<td>length, head, tail, size, get, getNode, findNodeIndex, findNode, find, findIndex, append, push, prepend, insertAt, removeNode, removeAt, insertBefore, sort, insertAfter, shift, pop, merge, clear, slice, reverse, forEach, map, filter, reduce, toArray, toString</td>
|
|
|
|
<td></td>
|
|
|
|
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>Hash</td>
|
|
|
|
<td>CoordinateSet, CoordinateMap</td>
|
|
|
|
<td></td>
|
|
|
|
<td></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>CoordinateSet</td>
|
|
|
|
<td></td>
|
|
|
|
<td>has, set, get, delete</td>
|
|
|
|
<td></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>CoordinateMap</td>
|
|
|
|
<td></td>
|
|
|
|
<td>has, add, delete</td>
|
|
|
|
<td></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>Heap</td>
|
|
|
|
<td></td>
|
|
|
|
<td></td>
|
|
|
|
</tr>
|
|
|
|
|
|
|
|
|
|
|
|
<tr>
|
|
|
|
<td>Doubly Linked List</td>
|
|
|
|
<td></td>
|
|
|
|
<td>size, offerFirst, offerLast, peekFirst, peekLast, pollFirst, pollLast, get, isEmpty, insert, remove, </td>
|
|
|
|
<td></td>
|
|
|
|
</tr>
|
|
|
|
|
|
|
|
[//]: # ( <tr>)
|
|
|
|
|
|
|
|
[//]: # ( <td>Matrix</td>)
|
|
|
|
|
|
|
|
[//]: # ( <td></td>)
|
|
|
|
|
|
|
|
[//]: # ( <td></td>)
|
|
|
|
|
|
|
|
[//]: # ( <td></td>)
|
|
|
|
|
|
|
|
[//]: # ( </tr>)
|
|
|
|
|
2023-08-11 04:02:16 +00:00
|
|
|
<tr>
|
|
|
|
<td>Priority Queue</td>
|
|
|
|
<td>Max Priority Queue, Min Priority Queue</td>
|
2023-08-11 11:21:34 +00:00
|
|
|
<td>offer, peek, poll, leaf, isEmpty, clear, toArray, clone</td>
|
|
|
|
<td>isValid, sort, DFS</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>Max Priority Queue</td>
|
|
|
|
<td></td>
|
|
|
|
<td>All the features inherited from Priority Queue</td>
|
|
|
|
<td>All the features inherited from Priority Queue</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>Min Priority Queue</td>
|
|
|
|
<td></td>
|
|
|
|
<td>All the features inherited from Priority Queue</td>
|
|
|
|
<td>All the features inherited from Priority Queue</td>
|
2023-08-11 04:02:16 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>Queue</td>
|
|
|
|
<td>Queue, Dequeue</td>
|
2023-08-11 11:21:34 +00:00
|
|
|
<td>offer, poll, peek, peekLast, size, isEmpty, toArray, clear, clone, Queue.fromArray</td>
|
|
|
|
<td></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>ObjectDeque</td>
|
|
|
|
<td></td>
|
|
|
|
<td>size, offerFirst, offerLast, pollFirst, peekFirst, pollLast, peekLast, get, isEmpty</td>
|
|
|
|
<td></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>ArrayDeque</td>
|
|
|
|
<td></td>
|
|
|
|
<td>offerLast, pollLast, pollFirst, offerFirst, peekFirst, peekLast, get, set, insert, remove, isEmpty</td>
|
|
|
|
<td></td>
|
2023-08-11 04:02:16 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>Stack</td>
|
|
|
|
<td></td>
|
2023-08-11 11:21:34 +00:00
|
|
|
<td>isEmpty, size, peek, push, pop, toArray, clear, clone, Stack.fromArray</td>
|
|
|
|
<td></td>
|
2023-08-11 04:02:16 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>Trie</td>
|
|
|
|
<td></td>
|
2023-08-11 11:21:34 +00:00
|
|
|
<td>put, has, remove, isAbsPrefix, isPrefix, getAll</td>
|
|
|
|
<td></td>
|
2023-08-11 04:02:16 +00:00
|
|
|
</tr>
|
2023-08-11 11:21:34 +00:00
|
|
|
</tbody>
|
2023-08-11 04:02:16 +00:00
|
|
|
|
2023-08-11 11:21:34 +00:00
|
|
|
</table>
|
2023-08-11 04:02:16 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2023-06-27 16:32:34 +00:00
|
|
|
|
2023-06-27 16:42:28 +00:00
|
|
|
![complexities](src/assets/complexities-diff.jpg)
|
2023-06-27 16:32:34 +00:00
|
|
|
|
2023-08-12 03:35:25 +00:00
|
|
|
![complexities of data structures](src/assets/data-structure-complexities.jpg)
|
|
|
|
|
|
|
|
![](src/data-structures/binary-tree/diagrams/bst-rotation.gif)
|
|
|
|
|
|
|
|
![](src/data-structures/binary-tree/diagrams/avl-tree-inserting.gif)
|
|
|
|
|
|
|
|
|
|
|
|
![](src/data-structures/graph/diagrams/tarjan.webp)
|
|
|
|
|
2023-08-13 11:59:28 +00:00
|
|
|
![](src/data-structures/graph/diagrams/adjacency-list.jpg)
|
2023-08-12 03:35:25 +00:00
|
|
|
|
2023-08-13 11:59:28 +00:00
|
|
|
![](src/data-structures/graph/diagrams/adjacency-list-pros-cons.jpg)
|
2023-08-12 03:35:25 +00:00
|
|
|
|
2023-08-13 11:59:28 +00:00
|
|
|
![](src/data-structures/graph/diagrams/adjacency-matrix.jpg)
|
2023-08-12 03:35:25 +00:00
|
|
|
|
2023-08-13 11:59:28 +00:00
|
|
|
![](src/data-structures/graph/diagrams/adjacency-matrix-pros-cons.jpg)
|
2023-08-12 03:35:25 +00:00
|
|
|
|
2023-08-13 11:59:28 +00:00
|
|
|
![](src/data-structures/graph/diagrams/dfs-can-do.jpg)
|
2023-08-12 03:35:25 +00:00
|
|
|
|
2023-08-13 11:59:28 +00:00
|
|
|
![](src/data-structures/graph/diagrams/edge-list.jpg)
|
2023-08-12 03:35:25 +00:00
|
|
|
|
2023-08-13 11:59:28 +00:00
|
|
|
![](src/data-structures/graph/diagrams/edge-list-pros-cons.jpg)
|
2023-08-12 03:35:25 +00:00
|
|
|
|
2023-08-13 11:59:28 +00:00
|
|
|
![](src/data-structures/graph/diagrams/max-flow.jpg)
|
2023-08-12 03:35:25 +00:00
|
|
|
|
2023-08-13 11:59:28 +00:00
|
|
|
![](src/data-structures/graph/diagrams/mst.jpg)
|
2023-08-12 03:35:25 +00:00
|
|
|
|
2023-08-13 11:59:28 +00:00
|
|
|
[//]: # (![](src/data-structures/graph/diagrams/tarjan-articulation-point-bridge.png))
|
2023-08-12 03:35:25 +00:00
|
|
|
|
2023-08-13 11:59:28 +00:00
|
|
|
[//]: # (![](src/data-structures/graph/diagrams/tarjan-complicate-simple.png))
|
2023-08-12 03:35:25 +00:00
|
|
|
|
2023-08-13 11:59:28 +00:00
|
|
|
[//]: # (![](src/data-structures/graph/diagrams/tarjan-strongly-connected-component.png))
|
2023-08-12 03:35:25 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|