data-structure-typed 1.33.0 → 1.33.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{.eslintrc.json → .eslintrc.js} +2 -1
- package/.github/workflows/ci.yml +15 -3
- package/.github/workflows/release-package.yml +32 -0
- package/{.prettierrc → .prettierrc.js} +1 -1
- package/CHANGELOG.md +5 -1
- package/README.md +196 -257
- package/coverage/coverage-final.json +64 -64
- package/coverage/coverage-summary.json +16 -16
- package/dist/data-structures/binary-tree/abstract-binary-tree.js +1 -16
- package/dist/data-structures/binary-tree/abstract-binary-tree.js.map +1 -1
- package/dist/data-structures/binary-tree/avl-tree.js +2 -2
- package/dist/data-structures/binary-tree/avl-tree.js.map +1 -1
- package/dist/data-structures/binary-tree/rb-tree.js +3 -4
- package/dist/data-structures/binary-tree/rb-tree.js.map +1 -1
- package/dist/data-structures/graph/abstract-graph.js +12 -12
- package/dist/data-structures/graph/abstract-graph.js.map +1 -1
- package/dist/data-structures/graph/directed-graph.js.map +1 -1
- package/dist/data-structures/graph/undirected-graph.js.map +1 -1
- package/dist/data-structures/hash/hash-table.js +107 -2
- package/dist/data-structures/hash/hash-table.js.map +1 -1
- package/dist/data-structures/heap/max-heap.js.map +1 -1
- package/dist/data-structures/heap/min-heap.js.map +1 -1
- package/dist/data-structures/linked-list/doubly-linked-list.js +30 -0
- package/dist/data-structures/linked-list/doubly-linked-list.js.map +1 -1
- package/dist/data-structures/matrix/matrix2d.js +5 -8
- package/dist/data-structures/matrix/matrix2d.js.map +1 -1
- package/dist/data-structures/priority-queue/max-priority-queue.js.map +1 -1
- package/dist/data-structures/priority-queue/min-priority-queue.js.map +1 -1
- package/dist/data-structures/priority-queue/priority-queue.js +6 -6
- package/dist/data-structures/priority-queue/priority-queue.js.map +1 -1
- package/dist/data-structures/queue/deque.js.map +1 -1
- package/docs/index.html +196 -256
- package/docs/modules.html +2 -0
- package/lib/data-structures/binary-tree/abstract-binary-tree.d.ts +8 -18
- package/lib/data-structures/binary-tree/abstract-binary-tree.js +5 -23
- package/lib/data-structures/binary-tree/avl-tree.d.ts +7 -10
- package/lib/data-structures/binary-tree/avl-tree.js +6 -9
- package/lib/data-structures/binary-tree/binary-tree.d.ts +2 -2
- package/lib/data-structures/binary-tree/bst.d.ts +2 -2
- package/lib/data-structures/binary-tree/rb-tree.d.ts +3 -3
- package/lib/data-structures/binary-tree/rb-tree.js +3 -3
- package/lib/data-structures/binary-tree/tree-multiset.d.ts +3 -3
- package/lib/data-structures/binary-tree/tree-multiset.js +1 -1
- package/lib/data-structures/graph/abstract-graph.d.ts +10 -10
- package/lib/data-structures/graph/abstract-graph.js +2 -2
- package/lib/data-structures/graph/directed-graph.d.ts +6 -6
- package/lib/data-structures/graph/directed-graph.js +2 -2
- package/lib/data-structures/graph/map-graph.d.ts +6 -6
- package/lib/data-structures/graph/map-graph.js +2 -2
- package/lib/data-structures/graph/undirected-graph.d.ts +6 -6
- package/lib/data-structures/graph/undirected-graph.js +2 -2
- package/lib/data-structures/hash/hash-table.d.ts +61 -1
- package/lib/data-structures/hash/hash-table.js +136 -0
- package/lib/data-structures/heap/heap.d.ts +31 -31
- package/lib/data-structures/heap/heap.js +11 -11
- package/lib/data-structures/heap/max-heap.d.ts +4 -4
- package/lib/data-structures/heap/max-heap.js +1 -1
- package/lib/data-structures/heap/min-heap.d.ts +4 -4
- package/lib/data-structures/heap/min-heap.js +1 -1
- package/lib/data-structures/linked-list/doubly-linked-list.d.ts +93 -54
- package/lib/data-structures/linked-list/doubly-linked-list.js +79 -22
- package/lib/data-structures/linked-list/singly-linked-list.d.ts +46 -46
- package/lib/data-structures/linked-list/singly-linked-list.js +20 -20
- package/lib/data-structures/matrix/matrix.d.ts +3 -3
- package/lib/data-structures/matrix/matrix2d.d.ts +1 -1
- package/lib/data-structures/matrix/matrix2d.js +3 -2
- package/lib/data-structures/priority-queue/max-priority-queue.d.ts +4 -4
- package/lib/data-structures/priority-queue/min-priority-queue.d.ts +4 -4
- package/lib/data-structures/priority-queue/priority-queue.d.ts +26 -26
- package/lib/data-structures/priority-queue/priority-queue.js +8 -8
- package/lib/data-structures/queue/deque.d.ts +30 -30
- package/lib/data-structures/queue/deque.js +7 -7
- package/lib/data-structures/queue/queue.d.ts +27 -27
- package/lib/data-structures/queue/queue.js +8 -8
- package/lib/data-structures/stack/stack.d.ts +15 -15
- package/lib/data-structures/stack/stack.js +6 -6
- package/lib/data-structures/tree/tree.d.ts +7 -7
- package/lib/interfaces/abstract-binary-tree.d.ts +0 -1
- package/lib/interfaces/avl-tree.d.ts +1 -1
- package/lib/types/data-structures/navigator.d.ts +1 -1
- package/package.json +68 -62
- package/src/data-structures/binary-tree/aa-tree.ts +1 -0
- package/src/data-structures/binary-tree/abstract-binary-tree.ts +1608 -0
- package/src/data-structures/binary-tree/avl-tree.ts +307 -0
- package/src/data-structures/binary-tree/b-tree.ts +1 -0
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +76 -0
- package/src/data-structures/binary-tree/binary-tree.ts +47 -0
- package/src/data-structures/binary-tree/bst.ts +537 -0
- package/src/data-structures/binary-tree/index.ts +12 -0
- package/src/data-structures/binary-tree/rb-tree.ts +366 -0
- package/src/data-structures/binary-tree/segment-tree.ts +242 -0
- package/src/data-structures/binary-tree/splay-tree.ts +1 -0
- package/src/data-structures/binary-tree/tree-multiset.ts +700 -0
- package/src/data-structures/binary-tree/two-three-tree.ts +1 -0
- package/src/data-structures/graph/abstract-graph.ts +1040 -0
- package/src/data-structures/graph/directed-graph.ts +470 -0
- package/src/data-structures/graph/index.ts +4 -0
- package/src/data-structures/graph/map-graph.ts +129 -0
- package/src/data-structures/graph/undirected-graph.ts +274 -0
- package/src/data-structures/hash/coordinate-map.ts +67 -0
- package/src/data-structures/hash/coordinate-set.ts +56 -0
- package/src/data-structures/hash/hash-table.ts +157 -0
- package/src/data-structures/hash/index.ts +6 -0
- package/src/data-structures/hash/pair.ts +1 -0
- package/src/data-structures/hash/tree-map.ts +1 -0
- package/src/data-structures/hash/tree-set.ts +1 -0
- package/src/data-structures/heap/heap.ts +212 -0
- package/src/data-structures/heap/index.ts +3 -0
- package/src/data-structures/heap/max-heap.ts +31 -0
- package/src/data-structures/heap/min-heap.ts +32 -0
- package/src/data-structures/index.ts +11 -0
- package/src/data-structures/linked-list/doubly-linked-list.ts +636 -0
- package/src/data-structures/linked-list/index.ts +3 -0
- package/src/data-structures/linked-list/singly-linked-list.ts +501 -0
- package/src/data-structures/linked-list/skip-linked-list.ts +1 -0
- package/src/data-structures/matrix/index.ts +4 -0
- package/src/data-structures/matrix/matrix.ts +27 -0
- package/src/data-structures/matrix/matrix2d.ts +213 -0
- package/src/data-structures/matrix/navigator.ts +121 -0
- package/src/data-structures/matrix/vector2d.ts +316 -0
- package/src/data-structures/priority-queue/index.ts +3 -0
- package/src/data-structures/priority-queue/max-priority-queue.ts +56 -0
- package/src/data-structures/priority-queue/min-priority-queue.ts +57 -0
- package/src/data-structures/priority-queue/priority-queue.ts +359 -0
- package/src/data-structures/queue/deque.ts +297 -0
- package/src/data-structures/queue/index.ts +2 -0
- package/src/data-structures/queue/queue.ts +191 -0
- package/src/data-structures/stack/index.ts +1 -0
- package/src/data-structures/stack/stack.ts +98 -0
- package/src/data-structures/tree/index.ts +1 -0
- package/src/data-structures/tree/tree.ts +69 -0
- package/src/data-structures/trie/index.ts +1 -0
- package/src/data-structures/trie/trie.ts +225 -0
- package/src/index.ts +4 -0
- package/src/interfaces/abstract-binary-tree.ts +189 -0
- package/src/interfaces/abstract-graph.ts +31 -0
- package/src/interfaces/avl-tree.ts +25 -0
- package/src/interfaces/binary-tree.ts +6 -0
- package/src/interfaces/bst.ts +31 -0
- package/src/interfaces/directed-graph.ts +20 -0
- package/src/interfaces/doubly-linked-list.ts +1 -0
- package/src/interfaces/heap.ts +1 -0
- package/src/interfaces/index.ts +15 -0
- package/src/interfaces/navigator.ts +1 -0
- package/src/interfaces/priority-queue.ts +1 -0
- package/src/interfaces/rb-tree.ts +9 -0
- package/src/interfaces/segment-tree.ts +1 -0
- package/src/interfaces/singly-linked-list.ts +1 -0
- package/src/interfaces/tree-multiset.ts +7 -0
- package/src/interfaces/undirected-graph.ts +6 -0
- package/src/types/data-structures/abstract-binary-tree.ts +50 -0
- package/src/types/data-structures/abstract-graph.ts +11 -0
- package/src/types/data-structures/avl-tree.ts +5 -0
- package/src/types/data-structures/binary-tree.ts +5 -0
- package/src/types/data-structures/bst.ts +13 -0
- package/src/types/data-structures/directed-graph.ts +8 -0
- package/src/types/data-structures/doubly-linked-list.ts +1 -0
- package/src/types/data-structures/heap.ts +5 -0
- package/src/types/data-structures/index.ts +15 -0
- package/src/types/data-structures/map-graph.ts +1 -0
- package/src/types/data-structures/navigator.ts +13 -0
- package/src/types/data-structures/priority-queue.ts +9 -0
- package/src/types/data-structures/rb-tree.ts +8 -0
- package/src/types/data-structures/segment-tree.ts +1 -0
- package/src/types/data-structures/singly-linked-list.ts +1 -0
- package/src/types/data-structures/tree-multiset.ts +6 -0
- package/src/types/helpers.ts +1 -0
- package/src/types/index.ts +3 -0
- package/src/types/utils/index.ts +2 -0
- package/src/types/utils/utils.ts +6 -0
- package/src/types/utils/validate-type.ts +35 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/utils.ts +79 -0
- package/test/integration/avl-tree.test.ts +14 -17
- package/test/integration/bst.test.ts +50 -41
- package/test/integration/heap.test.js +0 -3
- package/test/integration/index.html +6 -6
- package/test/unit/data-structures/binary-tree/avl-tree.test.ts +14 -17
- package/test/unit/data-structures/binary-tree/binary-tree.test.ts +142 -0
- package/test/unit/data-structures/binary-tree/bst.test.ts +50 -41
- package/test/unit/data-structures/binary-tree/overall.test.ts +36 -28
- package/test/unit/data-structures/binary-tree/rb-tree.test.ts +43 -0
- package/test/unit/data-structures/binary-tree/tree-multiset.test.ts +23 -12
- package/test/unit/data-structures/graph/directed-graph.test.ts +27 -25
- package/test/unit/data-structures/graph/map-graph.test.ts +4 -5
- package/test/unit/data-structures/graph/overall.test.ts +10 -11
- package/test/unit/data-structures/graph/undirected-graph.test.ts +0 -1
- package/test/unit/data-structures/hash/coordinate-map.test.ts +54 -0
- package/test/unit/data-structures/hash/coordinate-set.test.ts +41 -0
- package/test/unit/data-structures/hash/hash-table.test.ts +97 -0
- package/test/unit/data-structures/heap/heap.test.ts +7 -8
- package/test/unit/data-structures/heap/max-heap.test.ts +7 -5
- package/test/unit/data-structures/heap/min-heap.test.ts +6 -5
- package/test/unit/data-structures/linked-list/doubly-linked-list.test.ts +8 -9
- package/test/unit/data-structures/linked-list/linked-list.test.ts +2 -4
- package/test/unit/data-structures/linked-list/singly-linked-list.test.ts +57 -7
- package/test/unit/data-structures/linked-list/skip-linked-list.test.ts +3 -3
- package/test/unit/data-structures/matrix/matrix.test.ts +54 -0
- package/test/unit/data-structures/matrix/matrix2d.test.ts +138 -0
- package/test/unit/data-structures/matrix/navigator.test.ts +79 -0
- package/test/unit/data-structures/priority-queue/max-priority-queue.test.ts +5 -7
- package/test/unit/data-structures/priority-queue/min-priority-queue.test.ts +13 -13
- package/test/unit/data-structures/priority-queue/priority-queue.test.ts +8 -8
- package/test/unit/data-structures/queue/deque.test.ts +130 -0
- package/test/unit/data-structures/queue/queue.test.ts +167 -4
- package/test/unit/data-structures/stack/stack.test.ts +67 -0
- package/test/unit/data-structures/tree/tree.test.ts +39 -0
- package/test/unit/data-structures/trie/trie.test.ts +95 -0
- package/test/utils/magnitude.ts +3 -3
- package/tsconfig.json +3 -12
- package/tsconfig.prod.json +25 -0
- package/umd/bundle.min.js +1 -1
- package/umd/bundle.min.js.map +1 -1
- package/.auto-changelog +0 -9
- package/.gitattributes +0 -112
- package/.idea/data-structure-typed.iml +0 -19
- package/.idea/inspectionProfiles/Project_Default.xml +0 -6
- package/.idea/misc.xml +0 -6
- package/.idea/modules.xml +0 -8
- package/.idea/vcs.xml +0 -6
- package/.prettierignore +0 -6
- package/webpack.config.js +0 -28
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
{
|
|
1
|
+
module.exports = {
|
|
2
2
|
"extends": [
|
|
3
3
|
"plugin:@typescript-eslint/recommended",
|
|
4
4
|
"prettier"
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
"@typescript-eslint/no-unused-vars": "error",
|
|
9
9
|
"@typescript-eslint/ban-ts-comment": "off",
|
|
10
10
|
"@typescript-eslint/no-explicit-any": "off",
|
|
11
|
+
"@typescript-eslint/no-var-requires": "off",
|
|
11
12
|
"@typescript-eslint/no-non-null-assertion": "off",
|
|
12
13
|
"lines-around-comment": [
|
|
13
14
|
"error",
|
package/.github/workflows/ci.yml
CHANGED
|
@@ -21,7 +21,7 @@ jobs:
|
|
|
21
21
|
runs-on: ubuntu-latest
|
|
22
22
|
strategy:
|
|
23
23
|
matrix:
|
|
24
|
-
node-version: [19.
|
|
24
|
+
node-version: [19.9.0]
|
|
25
25
|
steps:
|
|
26
26
|
- name: Checkout code
|
|
27
27
|
uses: actions/checkout@v4
|
|
@@ -34,8 +34,20 @@ jobs:
|
|
|
34
34
|
- name: Install dependencies
|
|
35
35
|
run: npm install
|
|
36
36
|
|
|
37
|
-
- name:
|
|
37
|
+
- name: Print Environment Variables
|
|
38
|
+
run: env
|
|
39
|
+
|
|
40
|
+
- name: Lint
|
|
41
|
+
run: npm run lint
|
|
42
|
+
|
|
43
|
+
- name: Build and documentation
|
|
38
44
|
run: npm run build
|
|
39
45
|
|
|
40
|
-
- name: Run tests
|
|
46
|
+
- name: Run tests
|
|
41
47
|
run: npm test
|
|
48
|
+
|
|
49
|
+
- name: Fetch Tags
|
|
50
|
+
run: git fetch --tags
|
|
51
|
+
|
|
52
|
+
- name: Changelog
|
|
53
|
+
run: npm run changelog
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
name: data-structure-typed
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [created]
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
build:
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
steps:
|
|
11
|
+
- uses: actions/checkout@v4
|
|
12
|
+
- uses: actions/setup-node@v3
|
|
13
|
+
with:
|
|
14
|
+
node-version: 19
|
|
15
|
+
- run: npm ci
|
|
16
|
+
|
|
17
|
+
publish-gpr:
|
|
18
|
+
needs: build
|
|
19
|
+
runs-on: ubuntu-latest
|
|
20
|
+
permissions:
|
|
21
|
+
packages: write
|
|
22
|
+
contents: read
|
|
23
|
+
steps:
|
|
24
|
+
- uses: actions/checkout@v4
|
|
25
|
+
- uses: actions/setup-node@v3
|
|
26
|
+
with:
|
|
27
|
+
node-version: 19
|
|
28
|
+
registry-url: https://npm.pkg.github.com/
|
|
29
|
+
- run: npm publish
|
|
30
|
+
env:
|
|
31
|
+
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
|
32
|
+
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
package/CHANGELOG.md
CHANGED
|
@@ -8,7 +8,11 @@ All notable changes to this project will be documented in this file.
|
|
|
8
8
|
- [Semantic Versioning](https://semver.org/spec/v2.0.0.html)
|
|
9
9
|
- [`auto-changelog`](https://github.com/CookPete/auto-changelog)
|
|
10
10
|
|
|
11
|
-
## [v1.33.
|
|
11
|
+
## [v1.33.5](https://github.com/zrwusa/data-structure-typed/compare/v1.33.4...main) (upcoming)
|
|
12
|
+
|
|
13
|
+
## [v1.33.4](https://github.com/zrwusa/data-structure-typed/compare/v1.33.3...v1.33.4) (26 September 2023)
|
|
14
|
+
|
|
15
|
+
## [v1.33.3](https://github.com/zrwusa/data-structure-typed/compare/v1.12.9...v1.33.3) (26 September 2023)
|
|
12
16
|
|
|
13
17
|
## [v1.12.9](https://github.com/zrwusa/data-structure-typed/compare/v1.12.8...v1.12.9) (14 August 2023)
|
|
14
18
|
|
package/README.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Data Structure Typed
|
|
2
2
|
|
|
3
|
+
Data Structures of Javascript & TypeScript.
|
|
4
|
+
|
|
5
|
+
Do you envy languages like C++ with <span style="border-radius: 5px;background-color: #0A7DBE; color: #ffffff; padding: 0 3px;">std</span>, Python with <span style="border-radius: 5px;background-color: #0A7DBE; color: #ffffff; padding: 0 3px;">collections</span>, and Java with <span style="border-radius: 5px;background-color: #0A7DBE; color: #ffffff; padding: 0 3px;">java.util</span>? Well, no need to envy anymore! JavaScript and TypeScript now have <span style="border-radius: 5px;background-color: #0A7DBE; color: #ffffff; padding: 0 3px;">data-structure-typed</span>
|
|
6
|
+
|
|
7
|
+
Now you can use this library in Node.js and browser environments in CommonJS(require export.modules = ), ESModule(import export), Typescript(import export), UMD(var Queue = dataStructureTyped.Queue)
|
|
8
|
+
|
|
3
9
|

|
|
4
10
|

|
|
5
11
|

|
|
@@ -7,10 +13,6 @@
|
|
|
7
13
|

|
|
8
14
|

|
|
9
15
|
|
|
10
|
-
## Brief
|
|
11
|
-
|
|
12
|
-
Data Structures of Javascript & TypeScript.
|
|
13
|
-
|
|
14
16
|
## Built-in classic algorithms
|
|
15
17
|
|
|
16
18
|
DFS(Depth-First Search), DFSIterative, BFS(Breadth-First Search), morris, Bellman-Ford Algorithm, Dijkstra's Algorithm,
|
|
@@ -21,7 +23,7 @@ Floyd-Warshall Algorithm, Tarjan's Algorithm.
|
|
|
21
23
|
### npm
|
|
22
24
|
|
|
23
25
|
```bash
|
|
24
|
-
npm
|
|
26
|
+
npm i data-structure-typed --save
|
|
25
27
|
```
|
|
26
28
|
|
|
27
29
|
### yarn
|
|
@@ -34,7 +36,7 @@ yarn add data-structure-typed
|
|
|
34
36
|
|
|
35
37
|
```html
|
|
36
38
|
|
|
37
|
-
<script src=
|
|
39
|
+
<script src='https://cdn.jsdelivr.net/npm/data-structure-typed/umd/bundle.min.js'></script>
|
|
38
40
|
```
|
|
39
41
|
|
|
40
42
|
```js
|
|
@@ -96,7 +98,7 @@ bst.get(6); // null
|
|
|
96
98
|
bst.isAVLBalanced(); // true
|
|
97
99
|
bst.BFS()[0] === 11; // true
|
|
98
100
|
|
|
99
|
-
const objBST = new BST<BSTNode<{
|
|
101
|
+
const objBST = new BST<BSTNode<{id: number, keyA: number}>>();
|
|
100
102
|
objBST.add(11, {id: 11, keyA: 11});
|
|
101
103
|
objBST.add(3, {id: 3, keyA: 3});
|
|
102
104
|
|
|
@@ -407,6 +409,193 @@ Array.from(dijkstraResult?.seen ?? []).map(vertex => vertex.id) // ['A', 'B', 'D
|
|
|
407
409
|
</tbody>
|
|
408
410
|
</table>
|
|
409
411
|
|
|
412
|
+
|
|
413
|
+
|
|
414
|
+
### Standard library data structure comparison
|
|
415
|
+
|
|
416
|
+
<table>
|
|
417
|
+
<thead>
|
|
418
|
+
<tr>
|
|
419
|
+
<th>Data Structure</th>
|
|
420
|
+
<th>C++ std</th>
|
|
421
|
+
<th>Data Structure Typed</th>
|
|
422
|
+
<th>java.util</th>
|
|
423
|
+
<th>Python collections</th>
|
|
424
|
+
</tr>
|
|
425
|
+
</thead>
|
|
426
|
+
<tbody>
|
|
427
|
+
<tr>
|
|
428
|
+
<td>Dynamic Array</td>
|
|
429
|
+
<td>std::vector<T></td>
|
|
430
|
+
<td>Array<E></td>
|
|
431
|
+
<td>ArrayList<E></td>
|
|
432
|
+
<td>list</td>
|
|
433
|
+
</tr>
|
|
434
|
+
<tr>
|
|
435
|
+
<td>Linked List</td>
|
|
436
|
+
<td>std::list<T></td>
|
|
437
|
+
<td>DoublyLinkedList<E></td>
|
|
438
|
+
<td>LinkedList<E></td>
|
|
439
|
+
<td>deque</td>
|
|
440
|
+
</tr>
|
|
441
|
+
<tr>
|
|
442
|
+
<td>Set</td>
|
|
443
|
+
<td>std::set<T></td>
|
|
444
|
+
<td>Set</td>
|
|
445
|
+
<td>HashSet<E></td>
|
|
446
|
+
<td>set</td>
|
|
447
|
+
</tr>
|
|
448
|
+
<tr>
|
|
449
|
+
<td>Map</td>
|
|
450
|
+
<td>std::map<K, V></td>
|
|
451
|
+
<td>Map</td>
|
|
452
|
+
<td>HashMap<K, V></td>
|
|
453
|
+
<td>dict</td>
|
|
454
|
+
</tr>
|
|
455
|
+
<tr>
|
|
456
|
+
<td>Unordered Map</td>
|
|
457
|
+
<td>std::unordered_map<K, V></td>
|
|
458
|
+
<td>N/A</td>
|
|
459
|
+
<td>HashMap<K, V></td>
|
|
460
|
+
<td>defaultdict</td>
|
|
461
|
+
</tr>
|
|
462
|
+
<tr>
|
|
463
|
+
<td>Unordered Set</td>
|
|
464
|
+
<td>std::unordered_set<T></td>
|
|
465
|
+
<td>N/A</td>
|
|
466
|
+
<td>HashSet<E></td>
|
|
467
|
+
<td>N/A</td>
|
|
468
|
+
</tr>
|
|
469
|
+
<tr>
|
|
470
|
+
<td>Queue</td>
|
|
471
|
+
<td>std::queue<T></td>
|
|
472
|
+
<td>Queue</td>
|
|
473
|
+
<td>Queue<E></td>
|
|
474
|
+
<td>N/A</td>
|
|
475
|
+
</tr>
|
|
476
|
+
<tr>
|
|
477
|
+
<td>Priority Queue</td>
|
|
478
|
+
<td>std::priority_queue<T></td>
|
|
479
|
+
<td>PriorityQueue</td>
|
|
480
|
+
<td>PriorityQueue<E></td>
|
|
481
|
+
<td>N/A</td>
|
|
482
|
+
</tr>
|
|
483
|
+
<tr>
|
|
484
|
+
<td>Stack</td>
|
|
485
|
+
<td>std::stack<T></td>
|
|
486
|
+
<td>Stack</td>
|
|
487
|
+
<td>Stack<E></td>
|
|
488
|
+
<td>N/A</td>
|
|
489
|
+
</tr>
|
|
490
|
+
<tr>
|
|
491
|
+
<td>Bitset</td>
|
|
492
|
+
<td>std::bitset<N></td>
|
|
493
|
+
<td>N/A</td>
|
|
494
|
+
<td>N/A</td>
|
|
495
|
+
<td>N/A</td>
|
|
496
|
+
</tr>
|
|
497
|
+
<tr>
|
|
498
|
+
<td>Deque</td>
|
|
499
|
+
<td>std::deque<T></td>
|
|
500
|
+
<td>Deque</td>
|
|
501
|
+
<td>N/A</td>
|
|
502
|
+
<td>N/A</td>
|
|
503
|
+
</tr>
|
|
504
|
+
<tr>
|
|
505
|
+
<td>Multiset</td>
|
|
506
|
+
<td>std::multiset<T></td>
|
|
507
|
+
<td>N/A</td>
|
|
508
|
+
<td>N/A</td>
|
|
509
|
+
<td>N/A</td>
|
|
510
|
+
</tr>
|
|
511
|
+
<tr>
|
|
512
|
+
<td>Multimap</td>
|
|
513
|
+
<td>std::multimap<K, V></td>
|
|
514
|
+
<td>N/A</td>
|
|
515
|
+
<td>N/A</td>
|
|
516
|
+
<td>N/A</td>
|
|
517
|
+
</tr>
|
|
518
|
+
<tr>
|
|
519
|
+
<td>Unordered Multiset</td>
|
|
520
|
+
<td>std::unordered_multiset</td>
|
|
521
|
+
<td>N/A</td>
|
|
522
|
+
<td>Counter</td>
|
|
523
|
+
<td>N/A</td>
|
|
524
|
+
</tr>
|
|
525
|
+
<tr>
|
|
526
|
+
<td>Ordered Dictionary</td>
|
|
527
|
+
<td>N/A</td>
|
|
528
|
+
<td>Map</td>
|
|
529
|
+
<td>N/A</td>
|
|
530
|
+
<td>OrderedDict</td>
|
|
531
|
+
</tr>
|
|
532
|
+
<tr>
|
|
533
|
+
<td>Double-Ended Queue (Deque)</td>
|
|
534
|
+
<td>std::deque<T></td>
|
|
535
|
+
<td>Deque</td>
|
|
536
|
+
<td>N/A</td>
|
|
537
|
+
<td>N/A</td>
|
|
538
|
+
</tr>
|
|
539
|
+
<tr>
|
|
540
|
+
<td>Linked Hash Set</td>
|
|
541
|
+
<td>N/A</td>
|
|
542
|
+
<td>N/A</td>
|
|
543
|
+
<td>LinkedHashSet<E></td>
|
|
544
|
+
<td>N/A</td>
|
|
545
|
+
</tr>
|
|
546
|
+
<tr>
|
|
547
|
+
<td>Linked Hash Map</td>
|
|
548
|
+
<td>N/A</td>
|
|
549
|
+
<td>N/A</td>
|
|
550
|
+
<td>LinkedHashMap<K, V></td>
|
|
551
|
+
<td>N/A</td>
|
|
552
|
+
</tr>
|
|
553
|
+
<tr>
|
|
554
|
+
<td>Sorted Set</td>
|
|
555
|
+
<td>N/A</td>
|
|
556
|
+
<td>AVLTree, RBTree</td>
|
|
557
|
+
<td>TreeSet<E></td>
|
|
558
|
+
<td>N/A</td>
|
|
559
|
+
</tr>
|
|
560
|
+
<tr>
|
|
561
|
+
<td>Sorted Map</td>
|
|
562
|
+
<td>N/A</td>
|
|
563
|
+
<td>AVLTree, RBTree</td>
|
|
564
|
+
<td>TreeMap<K, V></td>
|
|
565
|
+
<td>N/A</td>
|
|
566
|
+
</tr>
|
|
567
|
+
<tr>
|
|
568
|
+
<td>Tree Set</td>
|
|
569
|
+
<td>std::set</td>
|
|
570
|
+
<td>AVLTree, RBTree</td>
|
|
571
|
+
<td>TreeSet<E></td>
|
|
572
|
+
<td>N/A</td>
|
|
573
|
+
</tr>
|
|
574
|
+
<tr>
|
|
575
|
+
<td>Persistent Collections</td>
|
|
576
|
+
<td>N/A</td>
|
|
577
|
+
<td>N/A</td>
|
|
578
|
+
<td>N/A</td>
|
|
579
|
+
<td>N/A</td>
|
|
580
|
+
</tr>
|
|
581
|
+
<tr>
|
|
582
|
+
<td>unordered multiset</td>
|
|
583
|
+
<td>unordered multiset<T></td>
|
|
584
|
+
<td>N/A</td>
|
|
585
|
+
<td>N/A</td>
|
|
586
|
+
<td>N/A</td>
|
|
587
|
+
</tr>
|
|
588
|
+
<tr>
|
|
589
|
+
<td>Unordered Multimap</td>
|
|
590
|
+
<td>std::unordered_multimap<K, V></td>
|
|
591
|
+
<td>N/A</td>
|
|
592
|
+
<td>N/A</td>
|
|
593
|
+
<td>N/A</td>
|
|
594
|
+
</tr>
|
|
595
|
+
</tbody>
|
|
596
|
+
</table>
|
|
597
|
+
|
|
598
|
+
|
|
410
599
|
## Code design
|
|
411
600
|
|
|
412
601
|
By strictly adhering to object-oriented design (BinaryTree -> BST -> AVLTree -> TreeMultiset), you can seamlessly
|
|
@@ -675,253 +864,3 @@ optimal approach to data structure design.
|
|
|
675
864
|
</tr>
|
|
676
865
|
</tbody>
|
|
677
866
|
</table>
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
<table>
|
|
681
|
-
<tr>
|
|
682
|
-
<th>Data Structure</th>
|
|
683
|
-
<th>C++ STL</th>
|
|
684
|
-
<th>java.util</th>
|
|
685
|
-
<th>Python collections</th>
|
|
686
|
-
</tr>
|
|
687
|
-
<tr>
|
|
688
|
-
<td>Dynamic Array (ArrayList)</td>
|
|
689
|
-
<td>std::vector<T></td>
|
|
690
|
-
<td>ArrayList<E></td>
|
|
691
|
-
<td>list</td>
|
|
692
|
-
</tr>
|
|
693
|
-
<tr>
|
|
694
|
-
<td>Linked List</td>
|
|
695
|
-
<td>std::list<T></td>
|
|
696
|
-
<td>LinkedList<E></td>
|
|
697
|
-
<td>deque</td>
|
|
698
|
-
</tr>
|
|
699
|
-
<tr>
|
|
700
|
-
<td>Set</td>
|
|
701
|
-
<td>std::set<T></td>
|
|
702
|
-
<td>HashSet<E></td>
|
|
703
|
-
<td>set</td>
|
|
704
|
-
</tr>
|
|
705
|
-
<tr>
|
|
706
|
-
<td>Map</td>
|
|
707
|
-
<td>std::map<K, V></td>
|
|
708
|
-
<td>HashMap<K, V></td>
|
|
709
|
-
<td>dict</td>
|
|
710
|
-
</tr>
|
|
711
|
-
<tr>
|
|
712
|
-
<td>Stack</td>
|
|
713
|
-
<td>std::stack<T></td>
|
|
714
|
-
<td>Stack<E></td>
|
|
715
|
-
<td>N/A</td>
|
|
716
|
-
</tr>
|
|
717
|
-
<tr>
|
|
718
|
-
<td>Queue</td>
|
|
719
|
-
<td>std::queue<T></td>
|
|
720
|
-
<td>LinkedList<E></td>
|
|
721
|
-
<td>N/A</td>
|
|
722
|
-
</tr>
|
|
723
|
-
<tr>
|
|
724
|
-
<td>Priority Queue</td>
|
|
725
|
-
<td>std::priority_queue<T></td>
|
|
726
|
-
<td>PriorityQueue<E></td>
|
|
727
|
-
<td>N/A</td>
|
|
728
|
-
</tr>
|
|
729
|
-
<tr>
|
|
730
|
-
<td>Hash Table</td>
|
|
731
|
-
<td>N/A</td>
|
|
732
|
-
<td>N/A</td>
|
|
733
|
-
<td>defaultdict, Counter, etc.</td>
|
|
734
|
-
</tr>
|
|
735
|
-
<tr>
|
|
736
|
-
<td>Deque</td>
|
|
737
|
-
<td>std::deque<T></td>
|
|
738
|
-
<td>N/A</td>
|
|
739
|
-
<td>N/A</td>
|
|
740
|
-
</tr>
|
|
741
|
-
<tr>
|
|
742
|
-
<td>Multiset</td>
|
|
743
|
-
<td>std::multiset<T></td>
|
|
744
|
-
<td>N/A</td>
|
|
745
|
-
<td>N/A</td>
|
|
746
|
-
</tr>
|
|
747
|
-
<tr>
|
|
748
|
-
<td>Multimap</td>
|
|
749
|
-
<td>std::multimap<K, V></td>
|
|
750
|
-
<td>N/A</td>
|
|
751
|
-
<td>N/A</td>
|
|
752
|
-
</tr>
|
|
753
|
-
<tr>
|
|
754
|
-
<td>Unordered Set</td>
|
|
755
|
-
<td>std::unordered_set<T></td>
|
|
756
|
-
<td>HashSet<E></td>
|
|
757
|
-
<td>N/A</td>
|
|
758
|
-
</tr>
|
|
759
|
-
<tr>
|
|
760
|
-
<td>Unordered Map</td>
|
|
761
|
-
<td>std::unordered_map<K, V></td>
|
|
762
|
-
<td>HashMap<K, V></td>
|
|
763
|
-
<td>N/A</td>
|
|
764
|
-
</tr>
|
|
765
|
-
<tr>
|
|
766
|
-
<td>Bitset</td>
|
|
767
|
-
<td>std::bitset<N></td>
|
|
768
|
-
<td>N/A</td>
|
|
769
|
-
<td>N/A</td>
|
|
770
|
-
</tr>
|
|
771
|
-
<tr>
|
|
772
|
-
<td>Ordered Dictionary (OrderedDict)</td>
|
|
773
|
-
<td>N/A</td>
|
|
774
|
-
<td>N/A</td>
|
|
775
|
-
<td>OrderedDict</td>
|
|
776
|
-
</tr>
|
|
777
|
-
<tr>
|
|
778
|
-
<td>User-Defined Dictionary</td>
|
|
779
|
-
<td>N/A</td>
|
|
780
|
-
<td>N/A</td>
|
|
781
|
-
<td>UserDict</td>
|
|
782
|
-
</tr>
|
|
783
|
-
<tr>
|
|
784
|
-
<td>User-Defined List</td>
|
|
785
|
-
<td>N/A</td>
|
|
786
|
-
<td>N/A</td>
|
|
787
|
-
<td>UserList</td>
|
|
788
|
-
</tr>
|
|
789
|
-
<tr>
|
|
790
|
-
<td>User-Defined Set</td>
|
|
791
|
-
<td>N/A</td>
|
|
792
|
-
<td>N/A</td>
|
|
793
|
-
<td>UserSet</td>
|
|
794
|
-
</tr>
|
|
795
|
-
<tr>
|
|
796
|
-
<td>Double-Ended Queue (Deque)</td>
|
|
797
|
-
<td>std::deque<T></td>
|
|
798
|
-
<td>N/A</td>
|
|
799
|
-
<td>N/A</td>
|
|
800
|
-
</tr>
|
|
801
|
-
<tr>
|
|
802
|
-
<td>Skip List</td>
|
|
803
|
-
<td>N/A</td>
|
|
804
|
-
<td>N/A</td>
|
|
805
|
-
<td>N/A</td>
|
|
806
|
-
</tr>
|
|
807
|
-
<tr>
|
|
808
|
-
<td>Circular Queue</td>
|
|
809
|
-
<td>N/A</td>
|
|
810
|
-
<td>N/A</td>
|
|
811
|
-
<td>N/A</td>
|
|
812
|
-
</tr>
|
|
813
|
-
<tr>
|
|
814
|
-
<td>Bit Array</td>
|
|
815
|
-
<td>N/A</td>
|
|
816
|
-
<td>N/A</td>
|
|
817
|
-
<td>N/A</td>
|
|
818
|
-
</tr>
|
|
819
|
-
<tr>
|
|
820
|
-
<td>Bloom Filter</td>
|
|
821
|
-
<td>N/A</td>
|
|
822
|
-
<td>N/A</td>
|
|
823
|
-
<td>N/A</td>
|
|
824
|
-
</tr>
|
|
825
|
-
<tr>
|
|
826
|
-
<td>Linked Hash Set</td>
|
|
827
|
-
<td>N/A</td>
|
|
828
|
-
<td>LinkedHashSet<E></td>
|
|
829
|
-
<td>N/A</td>
|
|
830
|
-
</tr>
|
|
831
|
-
<tr>
|
|
832
|
-
<td>Linked Hash Map</td>
|
|
833
|
-
<td>N/A</td>
|
|
834
|
-
<td>LinkedHashMap<K, V></td>
|
|
835
|
-
<td>N/A</td>
|
|
836
|
-
</tr>
|
|
837
|
-
<tr>
|
|
838
|
-
<td>Sorted Set</td>
|
|
839
|
-
<td>N/A</td>
|
|
840
|
-
<td>TreeSet<E></td>
|
|
841
|
-
<td>N/A</td>
|
|
842
|
-
</tr>
|
|
843
|
-
<tr>
|
|
844
|
-
<td>Sorted Map</td>
|
|
845
|
-
<td>N/A</td>
|
|
846
|
-
<td>TreeMap<K, V></td>
|
|
847
|
-
<td>N/A</td>
|
|
848
|
-
</tr>
|
|
849
|
-
<tr>
|
|
850
|
-
<td>Tree Set</td>
|
|
851
|
-
<td>N/A</td>
|
|
852
|
-
<td>N/A</td>
|
|
853
|
-
<td>N/A</td>
|
|
854
|
-
</tr>
|
|
855
|
-
<tr>
|
|
856
|
-
<td>Tree Map</td>
|
|
857
|
-
<td>N/A</td>
|
|
858
|
-
<td>N/A</td>
|
|
859
|
-
<td>N/A</td>
|
|
860
|
-
</tr>
|
|
861
|
-
<tr>
|
|
862
|
-
<td>Persistent Collections</td>
|
|
863
|
-
<td>N/A</td>
|
|
864
|
-
<td>N/A</td>
|
|
865
|
-
<td>N/A</td>
|
|
866
|
-
</tr>
|
|
867
|
-
<tr>
|
|
868
|
-
<td>std::unordered_multiset</td>
|
|
869
|
-
<td>std::unordered_multiset<T></td>
|
|
870
|
-
<td>N/A</td>
|
|
871
|
-
<td>N/A</td>
|
|
872
|
-
</tr>
|
|
873
|
-
<tr>
|
|
874
|
-
<td>std::unordered_multimap</td>
|
|
875
|
-
<td>std::unordered_multimap<K, V></td>
|
|
876
|
-
<td>N/A</td>
|
|
877
|
-
<td>N/A</td>
|
|
878
|
-
</tr>
|
|
879
|
-
<tr>
|
|
880
|
-
<td>N/A</td>
|
|
881
|
-
<td>TreeSet<E></td>
|
|
882
|
-
<td>TreeSet<E></td>
|
|
883
|
-
<td>N/A</td>
|
|
884
|
-
</tr>
|
|
885
|
-
<tr>
|
|
886
|
-
<td>N/A</td>
|
|
887
|
-
<td>TreeMap<K, V></td>
|
|
888
|
-
<td>TreeMap<K, V></td>
|
|
889
|
-
<td>N/A</td>
|
|
890
|
-
</tr>
|
|
891
|
-
<tr>
|
|
892
|
-
<td>N/A</td>
|
|
893
|
-
<td>LinkedBlockingQueue<E></td>
|
|
894
|
-
<td>N/A</td>
|
|
895
|
-
<td>N/A</td>
|
|
896
|
-
</tr>
|
|
897
|
-
<tr>
|
|
898
|
-
<td>N/A</td>
|
|
899
|
-
<td>ConcurrentHashMap<K, V></td>
|
|
900
|
-
<td>N/A</td>
|
|
901
|
-
<td>N/A</td>
|
|
902
|
-
</tr>
|
|
903
|
-
<tr>
|
|
904
|
-
<td>N/A</td>
|
|
905
|
-
<td>N/A</td>
|
|
906
|
-
<td>namedtuple</td>
|
|
907
|
-
<td>N/A</td>
|
|
908
|
-
</tr>
|
|
909
|
-
<tr>
|
|
910
|
-
<td>N/A</td>
|
|
911
|
-
<td>N/A</td>
|
|
912
|
-
<td>ChainMap</td>
|
|
913
|
-
<td>N/A</td>
|
|
914
|
-
</tr>
|
|
915
|
-
<tr>
|
|
916
|
-
<td>N/A</td>
|
|
917
|
-
<td>N/A</td>
|
|
918
|
-
<td>defaultdict</td>
|
|
919
|
-
<td>N/A</td>
|
|
920
|
-
</tr>
|
|
921
|
-
<tr>
|
|
922
|
-
<td>N/A</td>
|
|
923
|
-
<td>N/A</td>
|
|
924
|
-
<td>Counter</td>
|
|
925
|
-
<td>N/A</td>
|
|
926
|
-
</tr>
|
|
927
|
-
</table>
|