data-structure-typed 1.51.9 → 1.52.1
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/CHANGELOG.md +1 -1
- package/README.md +141 -54
- package/benchmark/report.html +37 -1
- package/benchmark/report.json +385 -13
- package/dist/cjs/data-structures/base/index.d.ts +2 -1
- package/dist/cjs/data-structures/base/index.js +2 -1
- package/dist/cjs/data-structures/base/index.js.map +1 -1
- package/dist/cjs/data-structures/base/iterable-element-base.d.ts +171 -0
- package/dist/cjs/data-structures/base/iterable-element-base.js +226 -0
- package/dist/cjs/data-structures/base/iterable-element-base.js.map +1 -0
- package/dist/cjs/data-structures/base/{iterable-base.d.ts → iterable-entry-base.d.ts} +4 -147
- package/dist/cjs/data-structures/base/{iterable-base.js → iterable-entry-base.js} +13 -190
- package/dist/cjs/data-structures/base/iterable-entry-base.js.map +1 -0
- package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.d.ts +13 -13
- package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.js +6 -6
- package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/avl-tree.d.ts +13 -13
- package/dist/cjs/data-structures/binary-tree/avl-tree.js +6 -6
- package/dist/cjs/data-structures/binary-tree/avl-tree.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/binary-tree.d.ts +99 -99
- package/dist/cjs/data-structures/binary-tree/binary-tree.js +54 -52
- package/dist/cjs/data-structures/binary-tree/binary-tree.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/bst.d.ts +37 -45
- package/dist/cjs/data-structures/binary-tree/bst.js +17 -25
- package/dist/cjs/data-structures/binary-tree/bst.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/rb-tree.d.ts +10 -10
- package/dist/cjs/data-structures/binary-tree/rb-tree.js +6 -6
- package/dist/cjs/data-structures/binary-tree/rb-tree.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/tree-multi-map.d.ts +12 -12
- package/dist/cjs/data-structures/binary-tree/tree-multi-map.js +5 -5
- package/dist/cjs/data-structures/binary-tree/tree-multi-map.js.map +1 -1
- package/dist/cjs/data-structures/graph/directed-graph.js +2 -1
- package/dist/cjs/data-structures/graph/directed-graph.js.map +1 -1
- package/dist/cjs/data-structures/hash/hash-map.d.ts +2 -2
- package/dist/cjs/data-structures/hash/hash-map.js.map +1 -1
- package/dist/cjs/data-structures/heap/heap.d.ts +43 -114
- package/dist/cjs/data-structures/heap/heap.js +59 -127
- package/dist/cjs/data-structures/heap/heap.js.map +1 -1
- package/dist/cjs/data-structures/heap/max-heap.d.ts +50 -4
- package/dist/cjs/data-structures/heap/max-heap.js +76 -10
- package/dist/cjs/data-structures/heap/max-heap.js.map +1 -1
- package/dist/cjs/data-structures/heap/min-heap.d.ts +51 -5
- package/dist/cjs/data-structures/heap/min-heap.js +68 -11
- package/dist/cjs/data-structures/heap/min-heap.js.map +1 -1
- package/dist/cjs/data-structures/linked-list/doubly-linked-list.d.ts +22 -28
- package/dist/cjs/data-structures/linked-list/doubly-linked-list.js +26 -28
- package/dist/cjs/data-structures/linked-list/doubly-linked-list.js.map +1 -1
- package/dist/cjs/data-structures/linked-list/singly-linked-list.d.ts +22 -25
- package/dist/cjs/data-structures/linked-list/singly-linked-list.js +29 -26
- package/dist/cjs/data-structures/linked-list/singly-linked-list.js.map +1 -1
- package/dist/cjs/data-structures/priority-queue/max-priority-queue.d.ts +50 -4
- package/dist/cjs/data-structures/priority-queue/max-priority-queue.js +79 -10
- package/dist/cjs/data-structures/priority-queue/max-priority-queue.js.map +1 -1
- package/dist/cjs/data-structures/priority-queue/min-priority-queue.d.ts +51 -5
- package/dist/cjs/data-structures/priority-queue/min-priority-queue.js +71 -11
- package/dist/cjs/data-structures/priority-queue/min-priority-queue.js.map +1 -1
- package/dist/cjs/data-structures/priority-queue/priority-queue.d.ts +50 -4
- package/dist/cjs/data-structures/priority-queue/priority-queue.js +70 -1
- package/dist/cjs/data-structures/priority-queue/priority-queue.js.map +1 -1
- package/dist/cjs/data-structures/queue/deque.d.ts +27 -18
- package/dist/cjs/data-structures/queue/deque.js +43 -21
- package/dist/cjs/data-structures/queue/deque.js.map +1 -1
- package/dist/cjs/data-structures/queue/queue.d.ts +8 -29
- package/dist/cjs/data-structures/queue/queue.js +15 -32
- package/dist/cjs/data-structures/queue/queue.js.map +1 -1
- package/dist/cjs/data-structures/stack/stack.d.ts +17 -22
- package/dist/cjs/data-structures/stack/stack.js +25 -24
- package/dist/cjs/data-structures/stack/stack.js.map +1 -1
- package/dist/cjs/data-structures/trie/trie.d.ts +18 -13
- package/dist/cjs/data-structures/trie/trie.js +26 -15
- package/dist/cjs/data-structures/trie/trie.js.map +1 -1
- package/dist/cjs/interfaces/binary-tree.d.ts +4 -4
- package/dist/cjs/types/common.d.ts +1 -22
- package/dist/cjs/types/data-structures/base/base.d.ts +5 -2
- package/dist/cjs/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +2 -3
- package/dist/cjs/types/data-structures/binary-tree/avl-tree.d.ts +2 -3
- package/dist/cjs/types/data-structures/binary-tree/binary-tree.d.ts +20 -4
- package/dist/cjs/types/data-structures/binary-tree/bst.d.ts +5 -3
- package/dist/cjs/types/data-structures/binary-tree/rb-tree.d.ts +2 -3
- package/dist/cjs/types/data-structures/binary-tree/tree-multi-map.d.ts +2 -3
- package/dist/cjs/types/data-structures/heap/heap.d.ts +3 -2
- package/dist/cjs/types/data-structures/linked-list/doubly-linked-list.d.ts +2 -1
- package/dist/cjs/types/data-structures/linked-list/singly-linked-list.d.ts +2 -1
- package/dist/cjs/types/data-structures/priority-queue/priority-queue.d.ts +1 -1
- package/dist/cjs/types/data-structures/queue/deque.d.ts +4 -2
- package/dist/cjs/types/data-structures/queue/queue.d.ts +2 -1
- package/dist/cjs/types/data-structures/stack/stack.d.ts +2 -1
- package/dist/cjs/types/data-structures/trie/trie.d.ts +3 -2
- package/dist/cjs/utils/number.js +1 -2
- package/dist/cjs/utils/number.js.map +1 -1
- package/dist/cjs/utils/utils.js +2 -2
- package/dist/cjs/utils/utils.js.map +1 -1
- package/dist/mjs/data-structures/base/index.d.ts +2 -1
- package/dist/mjs/data-structures/base/index.js +2 -1
- package/dist/mjs/data-structures/base/iterable-element-base.d.ts +171 -0
- package/dist/mjs/data-structures/base/iterable-element-base.js +222 -0
- package/dist/mjs/data-structures/base/{iterable-base.d.ts → iterable-entry-base.d.ts} +4 -147
- package/dist/mjs/data-structures/base/{iterable-base.js → iterable-entry-base.js} +10 -186
- package/dist/mjs/data-structures/binary-tree/avl-tree-multi-map.d.ts +13 -13
- package/dist/mjs/data-structures/binary-tree/avl-tree-multi-map.js +6 -6
- package/dist/mjs/data-structures/binary-tree/avl-tree.d.ts +13 -13
- package/dist/mjs/data-structures/binary-tree/avl-tree.js +6 -6
- package/dist/mjs/data-structures/binary-tree/binary-tree.d.ts +99 -99
- package/dist/mjs/data-structures/binary-tree/binary-tree.js +54 -52
- package/dist/mjs/data-structures/binary-tree/bst.d.ts +37 -45
- package/dist/mjs/data-structures/binary-tree/bst.js +17 -25
- package/dist/mjs/data-structures/binary-tree/rb-tree.d.ts +10 -10
- package/dist/mjs/data-structures/binary-tree/rb-tree.js +6 -6
- package/dist/mjs/data-structures/binary-tree/tree-multi-map.d.ts +12 -12
- package/dist/mjs/data-structures/binary-tree/tree-multi-map.js +5 -5
- package/dist/mjs/data-structures/graph/directed-graph.js +2 -1
- package/dist/mjs/data-structures/hash/hash-map.d.ts +2 -2
- package/dist/mjs/data-structures/heap/heap.d.ts +43 -114
- package/dist/mjs/data-structures/heap/heap.js +60 -128
- package/dist/mjs/data-structures/heap/max-heap.d.ts +50 -4
- package/dist/mjs/data-structures/heap/max-heap.js +79 -10
- package/dist/mjs/data-structures/heap/min-heap.d.ts +51 -5
- package/dist/mjs/data-structures/heap/min-heap.js +68 -11
- package/dist/mjs/data-structures/linked-list/doubly-linked-list.d.ts +22 -28
- package/dist/mjs/data-structures/linked-list/doubly-linked-list.js +26 -28
- package/dist/mjs/data-structures/linked-list/singly-linked-list.d.ts +22 -25
- package/dist/mjs/data-structures/linked-list/singly-linked-list.js +29 -26
- package/dist/mjs/data-structures/priority-queue/max-priority-queue.d.ts +50 -4
- package/dist/mjs/data-structures/priority-queue/max-priority-queue.js +82 -10
- package/dist/mjs/data-structures/priority-queue/min-priority-queue.d.ts +51 -5
- package/dist/mjs/data-structures/priority-queue/min-priority-queue.js +71 -11
- package/dist/mjs/data-structures/priority-queue/priority-queue.d.ts +50 -4
- package/dist/mjs/data-structures/priority-queue/priority-queue.js +70 -1
- package/dist/mjs/data-structures/queue/deque.d.ts +27 -18
- package/dist/mjs/data-structures/queue/deque.js +43 -21
- package/dist/mjs/data-structures/queue/queue.d.ts +8 -29
- package/dist/mjs/data-structures/queue/queue.js +15 -32
- package/dist/mjs/data-structures/stack/stack.d.ts +17 -22
- package/dist/mjs/data-structures/stack/stack.js +25 -24
- package/dist/mjs/data-structures/trie/trie.d.ts +18 -13
- package/dist/mjs/data-structures/trie/trie.js +26 -15
- package/dist/mjs/interfaces/binary-tree.d.ts +4 -4
- package/dist/mjs/types/common.d.ts +1 -22
- package/dist/mjs/types/data-structures/base/base.d.ts +5 -2
- package/dist/mjs/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +2 -3
- package/dist/mjs/types/data-structures/binary-tree/avl-tree.d.ts +2 -3
- package/dist/mjs/types/data-structures/binary-tree/binary-tree.d.ts +20 -4
- package/dist/mjs/types/data-structures/binary-tree/bst.d.ts +5 -3
- package/dist/mjs/types/data-structures/binary-tree/rb-tree.d.ts +2 -3
- package/dist/mjs/types/data-structures/binary-tree/tree-multi-map.d.ts +2 -3
- package/dist/mjs/types/data-structures/heap/heap.d.ts +3 -2
- package/dist/mjs/types/data-structures/linked-list/doubly-linked-list.d.ts +2 -1
- package/dist/mjs/types/data-structures/linked-list/singly-linked-list.d.ts +2 -1
- package/dist/mjs/types/data-structures/priority-queue/priority-queue.d.ts +1 -1
- package/dist/mjs/types/data-structures/queue/deque.d.ts +4 -2
- package/dist/mjs/types/data-structures/queue/queue.d.ts +2 -1
- package/dist/mjs/types/data-structures/stack/stack.d.ts +2 -1
- package/dist/mjs/types/data-structures/trie/trie.d.ts +3 -2
- package/dist/umd/data-structure-typed.js +732 -409
- package/dist/umd/data-structure-typed.min.js +2 -2
- package/dist/umd/data-structure-typed.min.js.map +1 -1
- package/package.json +7 -7
- package/src/data-structures/base/index.ts +2 -1
- package/src/data-structures/base/iterable-element-base.ts +250 -0
- package/src/data-structures/base/{iterable-base.ts → iterable-entry-base.ts} +22 -213
- package/src/data-structures/binary-tree/avl-tree-multi-map.ts +14 -15
- package/src/data-structures/binary-tree/avl-tree.ts +13 -14
- package/src/data-structures/binary-tree/binary-tree.ts +156 -152
- package/src/data-structures/binary-tree/bst.ts +52 -60
- package/src/data-structures/binary-tree/rb-tree.ts +12 -13
- package/src/data-structures/binary-tree/tree-multi-map.ts +12 -13
- package/src/data-structures/graph/directed-graph.ts +2 -1
- package/src/data-structures/hash/hash-map.ts +4 -4
- package/src/data-structures/heap/heap.ts +71 -152
- package/src/data-structures/heap/max-heap.ts +88 -13
- package/src/data-structures/heap/min-heap.ts +78 -15
- package/src/data-structures/linked-list/doubly-linked-list.ts +32 -32
- package/src/data-structures/linked-list/singly-linked-list.ts +37 -29
- package/src/data-structures/priority-queue/max-priority-queue.ts +94 -13
- package/src/data-structures/priority-queue/min-priority-queue.ts +84 -15
- package/src/data-structures/priority-queue/priority-queue.ts +81 -4
- package/src/data-structures/queue/deque.ts +50 -25
- package/src/data-structures/queue/queue.ts +23 -37
- package/src/data-structures/stack/stack.ts +31 -26
- package/src/data-structures/trie/trie.ts +33 -18
- package/src/interfaces/binary-tree.ts +4 -5
- package/src/types/common.ts +2 -24
- package/src/types/data-structures/base/base.ts +14 -6
- package/src/types/data-structures/binary-tree/avl-tree-multi-map.ts +2 -3
- package/src/types/data-structures/binary-tree/avl-tree.ts +2 -3
- package/src/types/data-structures/binary-tree/binary-tree.ts +24 -5
- package/src/types/data-structures/binary-tree/bst.ts +9 -3
- package/src/types/data-structures/binary-tree/rb-tree.ts +2 -3
- package/src/types/data-structures/binary-tree/tree-multi-map.ts +2 -3
- package/src/types/data-structures/heap/heap.ts +4 -1
- package/src/types/data-structures/linked-list/doubly-linked-list.ts +3 -1
- package/src/types/data-structures/linked-list/singly-linked-list.ts +3 -1
- package/src/types/data-structures/priority-queue/priority-queue.ts +1 -1
- package/src/types/data-structures/queue/deque.ts +6 -1
- package/src/types/data-structures/queue/queue.ts +3 -1
- package/src/types/data-structures/stack/stack.ts +3 -1
- package/src/types/data-structures/trie/trie.ts +3 -1
- package/test/unit/data-structures/binary-tree/avl-tree-multi-map.test.ts +1 -1
- package/test/unit/data-structures/graph/directed-graph.test.ts +28 -0
- package/test/unit/data-structures/heap/heap.test.ts +100 -0
- package/test/unit/data-structures/heap/max-heap.test.ts +44 -1
- package/test/unit/data-structures/heap/min-heap.test.ts +18 -1
- package/test/unit/data-structures/priority-queue/max-priority-queue.test.ts +42 -0
- package/test/unit/data-structures/queue/deque.test.ts +49 -0
- package/test/unit/data-structures/queue/queue.test.ts +56 -0
- package/dist/cjs/data-structures/base/iterable-base.js.map +0 -1
package/benchmark/report.json
CHANGED
|
@@ -1,43 +1,415 @@
|
|
|
1
1
|
{
|
|
2
|
+
"heap": {
|
|
3
|
+
"benchmarks": [
|
|
4
|
+
{
|
|
5
|
+
"test name": "100,000 add",
|
|
6
|
+
"time taken (ms)": "6.09",
|
|
7
|
+
"executions per sec": "164.12",
|
|
8
|
+
"sample deviation": "1.35e-4"
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"test name": "100,000 add & poll",
|
|
12
|
+
"time taken (ms)": "34.55",
|
|
13
|
+
"executions per sec": "28.94",
|
|
14
|
+
"sample deviation": "6.43e-4"
|
|
15
|
+
}
|
|
16
|
+
],
|
|
17
|
+
"testName": "heap"
|
|
18
|
+
},
|
|
2
19
|
"rb-tree": {
|
|
3
20
|
"benchmarks": [
|
|
4
21
|
{
|
|
5
22
|
"test name": "100,000 add",
|
|
6
|
-
"time taken (ms)": "
|
|
7
|
-
"executions per sec": "13.
|
|
23
|
+
"time taken (ms)": "76.73",
|
|
24
|
+
"executions per sec": "13.03",
|
|
8
25
|
"sample deviation": "0.00"
|
|
9
26
|
},
|
|
10
27
|
{
|
|
11
28
|
"test name": "100,000 add randomly",
|
|
12
|
-
"time taken (ms)": "
|
|
13
|
-
"executions per sec": "12.
|
|
29
|
+
"time taken (ms)": "80.67",
|
|
30
|
+
"executions per sec": "12.40",
|
|
14
31
|
"sample deviation": "0.00"
|
|
15
32
|
},
|
|
16
33
|
{
|
|
17
34
|
"test name": "100,000 get",
|
|
18
|
-
"time taken (ms)": "
|
|
19
|
-
"executions per sec": "9.
|
|
35
|
+
"time taken (ms)": "110.86",
|
|
36
|
+
"executions per sec": "9.02",
|
|
20
37
|
"sample deviation": "0.00"
|
|
21
38
|
},
|
|
22
39
|
{
|
|
23
40
|
"test name": "100,000 iterator",
|
|
24
|
-
"time taken (ms)": "
|
|
25
|
-
"executions per sec": "
|
|
41
|
+
"time taken (ms)": "24.99",
|
|
42
|
+
"executions per sec": "40.02",
|
|
26
43
|
"sample deviation": "0.00"
|
|
27
44
|
},
|
|
28
45
|
{
|
|
29
46
|
"test name": "100,000 add & delete orderly",
|
|
30
|
-
"time taken (ms)": "
|
|
31
|
-
"executions per sec": "
|
|
47
|
+
"time taken (ms)": "152.66",
|
|
48
|
+
"executions per sec": "6.55",
|
|
32
49
|
"sample deviation": "0.00"
|
|
33
50
|
},
|
|
34
51
|
{
|
|
35
52
|
"test name": "100,000 add & delete randomly",
|
|
36
|
-
"time taken (ms)": "
|
|
37
|
-
"executions per sec": "4.
|
|
38
|
-
"sample deviation": "0.
|
|
53
|
+
"time taken (ms)": "230.75",
|
|
54
|
+
"executions per sec": "4.33",
|
|
55
|
+
"sample deviation": "0.00"
|
|
39
56
|
}
|
|
40
57
|
],
|
|
41
58
|
"testName": "rb-tree"
|
|
59
|
+
},
|
|
60
|
+
"queue": {
|
|
61
|
+
"benchmarks": [
|
|
62
|
+
{
|
|
63
|
+
"test name": "1,000,000 push",
|
|
64
|
+
"time taken (ms)": "39.27",
|
|
65
|
+
"executions per sec": "25.46",
|
|
66
|
+
"sample deviation": "0.01"
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
"test name": "100,000 push & shift",
|
|
70
|
+
"time taken (ms)": "4.53",
|
|
71
|
+
"executions per sec": "220.81",
|
|
72
|
+
"sample deviation": "4.84e-4"
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
"test name": "Native JS Array 100,000 push & shift",
|
|
76
|
+
"time taken (ms)": "1948.05",
|
|
77
|
+
"executions per sec": "0.51",
|
|
78
|
+
"sample deviation": "0.02"
|
|
79
|
+
}
|
|
80
|
+
],
|
|
81
|
+
"testName": "queue"
|
|
82
|
+
},
|
|
83
|
+
"deque": {
|
|
84
|
+
"benchmarks": [
|
|
85
|
+
{
|
|
86
|
+
"test name": "1,000,000 push",
|
|
87
|
+
"time taken (ms)": "23.22",
|
|
88
|
+
"executions per sec": "43.06",
|
|
89
|
+
"sample deviation": "0.00"
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
"test name": "1,000,000 push & pop",
|
|
93
|
+
"time taken (ms)": "29.68",
|
|
94
|
+
"executions per sec": "33.69",
|
|
95
|
+
"sample deviation": "0.00"
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
"test name": "1,000,000 push & shift",
|
|
99
|
+
"time taken (ms)": "29.33",
|
|
100
|
+
"executions per sec": "34.09",
|
|
101
|
+
"sample deviation": "0.00"
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
"test name": "100,000 push & shift",
|
|
105
|
+
"time taken (ms)": "3.10",
|
|
106
|
+
"executions per sec": "323.01",
|
|
107
|
+
"sample deviation": "2.47e-4"
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
"test name": "Native JS Array 100,000 push & shift",
|
|
111
|
+
"time taken (ms)": "1942.12",
|
|
112
|
+
"executions per sec": "0.51",
|
|
113
|
+
"sample deviation": "0.02"
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
"test name": "100,000 unshift & shift",
|
|
117
|
+
"time taken (ms)": "2.77",
|
|
118
|
+
"executions per sec": "360.50",
|
|
119
|
+
"sample deviation": "2.43e-4"
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
"test name": "Native JS Array 100,000 unshift & shift",
|
|
123
|
+
"time taken (ms)": "3835.21",
|
|
124
|
+
"executions per sec": "0.26",
|
|
125
|
+
"sample deviation": "0.03"
|
|
126
|
+
}
|
|
127
|
+
],
|
|
128
|
+
"testName": "deque"
|
|
129
|
+
},
|
|
130
|
+
"hash-map": {
|
|
131
|
+
"benchmarks": [
|
|
132
|
+
{
|
|
133
|
+
"test name": "1,000,000 set",
|
|
134
|
+
"time taken (ms)": "112.38",
|
|
135
|
+
"executions per sec": "8.90",
|
|
136
|
+
"sample deviation": "0.02"
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
"test name": "Native JS Map 1,000,000 set",
|
|
140
|
+
"time taken (ms)": "199.97",
|
|
141
|
+
"executions per sec": "5.00",
|
|
142
|
+
"sample deviation": "0.01"
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
"test name": "Native JS Set 1,000,000 add",
|
|
146
|
+
"time taken (ms)": "163.34",
|
|
147
|
+
"executions per sec": "6.12",
|
|
148
|
+
"sample deviation": "0.01"
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
"test name": "1,000,000 set & get",
|
|
152
|
+
"time taken (ms)": "109.86",
|
|
153
|
+
"executions per sec": "9.10",
|
|
154
|
+
"sample deviation": "0.02"
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
"test name": "Native JS Map 1,000,000 set & get",
|
|
158
|
+
"time taken (ms)": "255.33",
|
|
159
|
+
"executions per sec": "3.92",
|
|
160
|
+
"sample deviation": "0.00"
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
"test name": "Native JS Set 1,000,000 add & has",
|
|
164
|
+
"time taken (ms)": "163.91",
|
|
165
|
+
"executions per sec": "6.10",
|
|
166
|
+
"sample deviation": "0.00"
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
"test name": "1,000,000 ObjKey set & get",
|
|
170
|
+
"time taken (ms)": "317.89",
|
|
171
|
+
"executions per sec": "3.15",
|
|
172
|
+
"sample deviation": "0.04"
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
"test name": "Native JS Map 1,000,000 ObjKey set & get",
|
|
176
|
+
"time taken (ms)": "282.99",
|
|
177
|
+
"executions per sec": "3.53",
|
|
178
|
+
"sample deviation": "0.03"
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
"test name": "Native JS Set 1,000,000 ObjKey add & has",
|
|
182
|
+
"time taken (ms)": "253.93",
|
|
183
|
+
"executions per sec": "3.94",
|
|
184
|
+
"sample deviation": "0.03"
|
|
185
|
+
}
|
|
186
|
+
],
|
|
187
|
+
"testName": "hash-map"
|
|
188
|
+
},
|
|
189
|
+
"trie": {
|
|
190
|
+
"benchmarks": [
|
|
191
|
+
{
|
|
192
|
+
"test name": "100,000 push",
|
|
193
|
+
"time taken (ms)": "43.71",
|
|
194
|
+
"executions per sec": "22.88",
|
|
195
|
+
"sample deviation": "7.33e-4"
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
"test name": "100,000 getWords",
|
|
199
|
+
"time taken (ms)": "83.63",
|
|
200
|
+
"executions per sec": "11.96",
|
|
201
|
+
"sample deviation": "0.00"
|
|
202
|
+
}
|
|
203
|
+
],
|
|
204
|
+
"testName": "trie"
|
|
205
|
+
},
|
|
206
|
+
"avl-tree": {
|
|
207
|
+
"benchmarks": [
|
|
208
|
+
{
|
|
209
|
+
"test name": "100,000 add",
|
|
210
|
+
"time taken (ms)": "271.93",
|
|
211
|
+
"executions per sec": "3.68",
|
|
212
|
+
"sample deviation": "0.01"
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
"test name": "100,000 add randomly",
|
|
216
|
+
"time taken (ms)": "318.27",
|
|
217
|
+
"executions per sec": "3.14",
|
|
218
|
+
"sample deviation": "0.00"
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
"test name": "100,000 get",
|
|
222
|
+
"time taken (ms)": "128.85",
|
|
223
|
+
"executions per sec": "7.76",
|
|
224
|
+
"sample deviation": "0.00"
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
"test name": "100,000 iterator",
|
|
228
|
+
"time taken (ms)": "29.09",
|
|
229
|
+
"executions per sec": "34.38",
|
|
230
|
+
"sample deviation": "0.00"
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
"test name": "100,000 add & delete orderly",
|
|
234
|
+
"time taken (ms)": "435.48",
|
|
235
|
+
"executions per sec": "2.30",
|
|
236
|
+
"sample deviation": "7.44e-4"
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
"test name": "100,000 add & delete randomly",
|
|
240
|
+
"time taken (ms)": "578.70",
|
|
241
|
+
"executions per sec": "1.73",
|
|
242
|
+
"sample deviation": "0.00"
|
|
243
|
+
}
|
|
244
|
+
],
|
|
245
|
+
"testName": "avl-tree"
|
|
246
|
+
},
|
|
247
|
+
"binary-tree-overall": {
|
|
248
|
+
"benchmarks": [
|
|
249
|
+
{
|
|
250
|
+
"test name": "10,000 RBTree add randomly",
|
|
251
|
+
"time taken (ms)": "6.69",
|
|
252
|
+
"executions per sec": "149.54",
|
|
253
|
+
"sample deviation": "1.06e-4"
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
"test name": "10,000 RBTree get randomly",
|
|
257
|
+
"time taken (ms)": "9.19",
|
|
258
|
+
"executions per sec": "108.82",
|
|
259
|
+
"sample deviation": "1.43e-4"
|
|
260
|
+
},
|
|
261
|
+
{
|
|
262
|
+
"test name": "10,000 RBTree add & delete randomly",
|
|
263
|
+
"time taken (ms)": "18.54",
|
|
264
|
+
"executions per sec": "53.94",
|
|
265
|
+
"sample deviation": "1.73e-4"
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
"test name": "10,000 AVLTree add randomly",
|
|
269
|
+
"time taken (ms)": "23.70",
|
|
270
|
+
"executions per sec": "42.20",
|
|
271
|
+
"sample deviation": "1.88e-4"
|
|
272
|
+
},
|
|
273
|
+
{
|
|
274
|
+
"test name": "10,000 AVLTree get randomly",
|
|
275
|
+
"time taken (ms)": "9.89",
|
|
276
|
+
"executions per sec": "101.11",
|
|
277
|
+
"sample deviation": "0.00"
|
|
278
|
+
},
|
|
279
|
+
{
|
|
280
|
+
"test name": "10,000 AVLTree add & delete randomly",
|
|
281
|
+
"time taken (ms)": "44.44",
|
|
282
|
+
"executions per sec": "22.50",
|
|
283
|
+
"sample deviation": "4.30e-4"
|
|
284
|
+
}
|
|
285
|
+
],
|
|
286
|
+
"testName": "binary-tree-overall"
|
|
287
|
+
},
|
|
288
|
+
"directed-graph": {
|
|
289
|
+
"benchmarks": [
|
|
290
|
+
{
|
|
291
|
+
"test name": "1,000 addVertex",
|
|
292
|
+
"time taken (ms)": "0.10",
|
|
293
|
+
"executions per sec": "9766.65",
|
|
294
|
+
"sample deviation": "9.83e-7"
|
|
295
|
+
},
|
|
296
|
+
{
|
|
297
|
+
"test name": "1,000 addEdge",
|
|
298
|
+
"time taken (ms)": "6.15",
|
|
299
|
+
"executions per sec": "162.57",
|
|
300
|
+
"sample deviation": "7.99e-4"
|
|
301
|
+
},
|
|
302
|
+
{
|
|
303
|
+
"test name": "1,000 getVertex",
|
|
304
|
+
"time taken (ms)": "0.05",
|
|
305
|
+
"executions per sec": "2.18e+4",
|
|
306
|
+
"sample deviation": "4.52e-7"
|
|
307
|
+
},
|
|
308
|
+
{
|
|
309
|
+
"test name": "1,000 getEdge",
|
|
310
|
+
"time taken (ms)": "22.70",
|
|
311
|
+
"executions per sec": "44.06",
|
|
312
|
+
"sample deviation": "0.00"
|
|
313
|
+
},
|
|
314
|
+
{
|
|
315
|
+
"test name": "tarjan",
|
|
316
|
+
"time taken (ms)": "203.00",
|
|
317
|
+
"executions per sec": "4.93",
|
|
318
|
+
"sample deviation": "0.01"
|
|
319
|
+
},
|
|
320
|
+
{
|
|
321
|
+
"test name": "topologicalSort",
|
|
322
|
+
"time taken (ms)": "176.40",
|
|
323
|
+
"executions per sec": "5.67",
|
|
324
|
+
"sample deviation": "0.00"
|
|
325
|
+
}
|
|
326
|
+
],
|
|
327
|
+
"testName": "directed-graph"
|
|
328
|
+
},
|
|
329
|
+
"doubly-linked-list": {
|
|
330
|
+
"benchmarks": [
|
|
331
|
+
{
|
|
332
|
+
"test name": "1,000,000 push",
|
|
333
|
+
"time taken (ms)": "222.02",
|
|
334
|
+
"executions per sec": "4.50",
|
|
335
|
+
"sample deviation": "0.07"
|
|
336
|
+
},
|
|
337
|
+
{
|
|
338
|
+
"test name": "1,000,000 unshift",
|
|
339
|
+
"time taken (ms)": "220.41",
|
|
340
|
+
"executions per sec": "4.54",
|
|
341
|
+
"sample deviation": "0.05"
|
|
342
|
+
},
|
|
343
|
+
{
|
|
344
|
+
"test name": "1,000,000 unshift & shift",
|
|
345
|
+
"time taken (ms)": "185.31",
|
|
346
|
+
"executions per sec": "5.40",
|
|
347
|
+
"sample deviation": "0.01"
|
|
348
|
+
},
|
|
349
|
+
{
|
|
350
|
+
"test name": "1,000,000 addBefore",
|
|
351
|
+
"time taken (ms)": "317.20",
|
|
352
|
+
"executions per sec": "3.15",
|
|
353
|
+
"sample deviation": "0.07"
|
|
354
|
+
}
|
|
355
|
+
],
|
|
356
|
+
"testName": "doubly-linked-list"
|
|
357
|
+
},
|
|
358
|
+
"singly-linked-list": {
|
|
359
|
+
"benchmarks": [
|
|
360
|
+
{
|
|
361
|
+
"test name": "1,000,000 push & shift",
|
|
362
|
+
"time taken (ms)": "204.82",
|
|
363
|
+
"executions per sec": "4.88",
|
|
364
|
+
"sample deviation": "0.09"
|
|
365
|
+
},
|
|
366
|
+
{
|
|
367
|
+
"test name": "10,000 push & pop",
|
|
368
|
+
"time taken (ms)": "221.88",
|
|
369
|
+
"executions per sec": "4.51",
|
|
370
|
+
"sample deviation": "0.03"
|
|
371
|
+
},
|
|
372
|
+
{
|
|
373
|
+
"test name": "10,000 addBefore",
|
|
374
|
+
"time taken (ms)": "247.28",
|
|
375
|
+
"executions per sec": "4.04",
|
|
376
|
+
"sample deviation": "0.01"
|
|
377
|
+
}
|
|
378
|
+
],
|
|
379
|
+
"testName": "singly-linked-list"
|
|
380
|
+
},
|
|
381
|
+
"priority-queue": {
|
|
382
|
+
"benchmarks": [
|
|
383
|
+
{
|
|
384
|
+
"test name": "100,000 add",
|
|
385
|
+
"time taken (ms)": "26.97",
|
|
386
|
+
"executions per sec": "37.08",
|
|
387
|
+
"sample deviation": "7.97e-4"
|
|
388
|
+
},
|
|
389
|
+
{
|
|
390
|
+
"test name": "100,000 add & poll",
|
|
391
|
+
"time taken (ms)": "74.55",
|
|
392
|
+
"executions per sec": "13.41",
|
|
393
|
+
"sample deviation": "5.19e-4"
|
|
394
|
+
}
|
|
395
|
+
],
|
|
396
|
+
"testName": "priority-queue"
|
|
397
|
+
},
|
|
398
|
+
"stack": {
|
|
399
|
+
"benchmarks": [
|
|
400
|
+
{
|
|
401
|
+
"test name": "1,000,000 push",
|
|
402
|
+
"time taken (ms)": "35.54",
|
|
403
|
+
"executions per sec": "28.14",
|
|
404
|
+
"sample deviation": "0.00"
|
|
405
|
+
},
|
|
406
|
+
{
|
|
407
|
+
"test name": "1,000,000 push & pop",
|
|
408
|
+
"time taken (ms)": "44.89",
|
|
409
|
+
"executions per sec": "22.27",
|
|
410
|
+
"sample deviation": "0.01"
|
|
411
|
+
}
|
|
412
|
+
],
|
|
413
|
+
"testName": "stack"
|
|
42
414
|
}
|
|
43
415
|
}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export * from './iterable-base';
|
|
1
|
+
export * from './iterable-entry-base';
|
|
2
|
+
export * from './iterable-element-base';
|
|
@@ -14,5 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./iterable-base"), exports);
|
|
17
|
+
__exportStar(require("./iterable-entry-base"), exports);
|
|
18
|
+
__exportStar(require("./iterable-element-base"), exports);
|
|
18
19
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/data-structures/base/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/data-structures/base/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wDAAsC;AACtC,0DAAwC"}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { ElementCallback, IterableElementBaseOptions, ReduceElementCallback } from '../../types';
|
|
2
|
+
export declare abstract class IterableElementBase<E, R, C> {
|
|
3
|
+
/**
|
|
4
|
+
* The protected constructor initializes the options for the IterableElementBase class, including the
|
|
5
|
+
* toElementFn function.
|
|
6
|
+
* @param [options] - An optional object that contains the following properties:
|
|
7
|
+
*/
|
|
8
|
+
protected constructor(options?: IterableElementBaseOptions<E, R>);
|
|
9
|
+
abstract get size(): number;
|
|
10
|
+
protected _toElementFn?: (rawElement: R) => E;
|
|
11
|
+
/**
|
|
12
|
+
* The function returns the _toElementFn property, which is a function that converts a raw element to
|
|
13
|
+
* a specific type.
|
|
14
|
+
* @returns The function `get toElementFn()` is returning either a function that takes a raw element
|
|
15
|
+
* `rawElement` of type `R` and returns an element `E`, or `undefined` if no function is assigned to
|
|
16
|
+
* `_toElementFn`.
|
|
17
|
+
*/
|
|
18
|
+
get toElementFn(): ((rawElement: R) => E) | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* Time Complexity: O(n)
|
|
21
|
+
* Space Complexity: O(1)
|
|
22
|
+
*/
|
|
23
|
+
/**
|
|
24
|
+
* Time Complexity: O(n)
|
|
25
|
+
* Space Complexity: O(1)
|
|
26
|
+
*
|
|
27
|
+
* The function is an implementation of the Symbol.iterator method that returns an IterableIterator.
|
|
28
|
+
* @param {any[]} args - The `args` parameter in the code snippet represents a rest parameter. It
|
|
29
|
+
* allows the function to accept any number of arguments as an array. In this case, the `args`
|
|
30
|
+
* parameter is used to pass any number of arguments to the `_getIterator` method.
|
|
31
|
+
*/
|
|
32
|
+
[Symbol.iterator](...args: any[]): IterableIterator<E>;
|
|
33
|
+
/**
|
|
34
|
+
* Time Complexity: O(n)
|
|
35
|
+
* Space Complexity: O(n)
|
|
36
|
+
*/
|
|
37
|
+
/**
|
|
38
|
+
* Time Complexity: O(n)
|
|
39
|
+
* Space Complexity: O(n)
|
|
40
|
+
*
|
|
41
|
+
* The function returns an iterator that yields all the values in the object.
|
|
42
|
+
*/
|
|
43
|
+
values(): IterableIterator<E>;
|
|
44
|
+
/**
|
|
45
|
+
* Time Complexity: O(n)
|
|
46
|
+
* Space Complexity: O(1)
|
|
47
|
+
*/
|
|
48
|
+
/**
|
|
49
|
+
* Time Complexity: O(n)
|
|
50
|
+
* Space Complexity: O(1)
|
|
51
|
+
*
|
|
52
|
+
* The `every` function checks if every element in the array satisfies a given predicate.
|
|
53
|
+
* @param predicate - The `predicate` parameter is a callback function that takes three arguments:
|
|
54
|
+
* the current element being processed, its index, and the array it belongs to. It should return a
|
|
55
|
+
* boolean value indicating whether the element satisfies a certain condition or not.
|
|
56
|
+
* @param {any} [thisArg] - The `thisArg` parameter is an optional argument that specifies the value
|
|
57
|
+
* to be used as `this` when executing the `predicate` function. If `thisArg` is provided, it will be
|
|
58
|
+
* passed as the `this` value to the `predicate` function. If `thisArg` is
|
|
59
|
+
* @returns The `every` method is returning a boolean value. It returns `true` if every element in
|
|
60
|
+
* the array satisfies the provided predicate function, and `false` otherwise.
|
|
61
|
+
*/
|
|
62
|
+
every(predicate: ElementCallback<E, R, boolean, C>, thisArg?: any): boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Time Complexity: O(n)
|
|
65
|
+
* Space Complexity: O(1)
|
|
66
|
+
*/
|
|
67
|
+
/**
|
|
68
|
+
* Time Complexity: O(n)
|
|
69
|
+
* Space Complexity: O(1)
|
|
70
|
+
*/
|
|
71
|
+
/**
|
|
72
|
+
* Time Complexity: O(n)
|
|
73
|
+
* Space Complexity: O(1)
|
|
74
|
+
*
|
|
75
|
+
* The "some" function checks if at least one element in a collection satisfies a given predicate.
|
|
76
|
+
* @param predicate - The `predicate` parameter is a callback function that takes three arguments:
|
|
77
|
+
* `value`, `index`, and `array`. It should return a boolean value indicating whether the current
|
|
78
|
+
* element satisfies the condition.
|
|
79
|
+
* @param {any} [thisArg] - The `thisArg` parameter is an optional argument that specifies the value
|
|
80
|
+
* to be used as the `this` value when executing the `predicate` function. If `thisArg` is provided,
|
|
81
|
+
* it will be passed as the `this` value to the `predicate` function. If `thisArg
|
|
82
|
+
* @returns a boolean value. It returns true if the predicate function returns true for any element
|
|
83
|
+
* in the collection, and false otherwise.
|
|
84
|
+
*/
|
|
85
|
+
some(predicate: ElementCallback<E, R, boolean, C>, thisArg?: any): boolean;
|
|
86
|
+
/**
|
|
87
|
+
* Time Complexity: O(n)
|
|
88
|
+
* Space Complexity: O(1)
|
|
89
|
+
*/
|
|
90
|
+
/**
|
|
91
|
+
* Time Complexity: O(n)
|
|
92
|
+
* Space Complexity: O(1)
|
|
93
|
+
*
|
|
94
|
+
* The `forEach` function iterates over each element in an array-like object and calls a callback
|
|
95
|
+
* function for each element.
|
|
96
|
+
* @param callbackfn - The callbackfn parameter is a function that will be called for each element in
|
|
97
|
+
* the array. It takes three arguments: the current element being processed, the index of the current
|
|
98
|
+
* element, and the array that forEach was called upon.
|
|
99
|
+
* @param {any} [thisArg] - The `thisArg` parameter is an optional argument that specifies the value
|
|
100
|
+
* to be used as `this` when executing the `callbackfn` function. If `thisArg` is provided, it will
|
|
101
|
+
* be passed as the `this` value to the `callbackfn` function. If `thisArg
|
|
102
|
+
*/
|
|
103
|
+
forEach(callbackfn: ElementCallback<E, R, void, C>, thisArg?: any): void;
|
|
104
|
+
/**
|
|
105
|
+
* Time Complexity: O(n)
|
|
106
|
+
* Space Complexity: O(1)
|
|
107
|
+
*/
|
|
108
|
+
/**
|
|
109
|
+
* Time Complexity: O(n)
|
|
110
|
+
* Space Complexity: O(1)
|
|
111
|
+
*
|
|
112
|
+
* The `find` function iterates over the elements of an array-like object and returns the first
|
|
113
|
+
* element that satisfies the provided callback function.
|
|
114
|
+
* @param callbackfn - The callbackfn parameter is a function that will be called for each element in
|
|
115
|
+
* the array. It takes three arguments: the current element being processed, the index of the current
|
|
116
|
+
* element, and the array itself. The function should return a boolean value indicating whether the
|
|
117
|
+
* current element matches the desired condition.
|
|
118
|
+
* @param {any} [thisArg] - The `thisArg` parameter is an optional argument that specifies the value
|
|
119
|
+
* to be used as `this` when executing the `callbackfn` function. If `thisArg` is provided, it will
|
|
120
|
+
* be passed as the `this` value to the `callbackfn` function. If `thisArg
|
|
121
|
+
* @returns The `find` method returns the first element in the array that satisfies the provided
|
|
122
|
+
* callback function. If no element satisfies the callback function, `undefined` is returned.
|
|
123
|
+
*/
|
|
124
|
+
find(callbackfn: ElementCallback<E, R, boolean, C>, thisArg?: any): E | undefined;
|
|
125
|
+
/**
|
|
126
|
+
* Time Complexity: O(n)
|
|
127
|
+
* Space Complexity: O(1)
|
|
128
|
+
*
|
|
129
|
+
* The function checks if a given element exists in a collection.
|
|
130
|
+
* @param {E} element - The parameter "element" is of type E, which means it can be any type. It
|
|
131
|
+
* represents the element that we want to check for existence in the collection.
|
|
132
|
+
* @returns a boolean value. It returns true if the element is found in the collection, and false
|
|
133
|
+
* otherwise.
|
|
134
|
+
*/
|
|
135
|
+
has(element: E): boolean;
|
|
136
|
+
/**
|
|
137
|
+
* Time Complexity: O(n)
|
|
138
|
+
* Space Complexity: O(1)
|
|
139
|
+
*/
|
|
140
|
+
/**
|
|
141
|
+
* Time Complexity: O(n)
|
|
142
|
+
* Space Complexity: O(1)
|
|
143
|
+
*
|
|
144
|
+
* The `reduce` function iterates over the elements of an array-like object and applies a callback
|
|
145
|
+
* function to reduce them into a single value.
|
|
146
|
+
* @param callbackfn - The callbackfn parameter is a function that will be called for each element in
|
|
147
|
+
* the array. It takes four arguments:
|
|
148
|
+
* @param {U} initialValue - The initialValue parameter is the initial value of the accumulator. It
|
|
149
|
+
* is the value that the accumulator starts with before the reduction operation begins.
|
|
150
|
+
* @returns The `reduce` method is returning the final value of the accumulator after iterating over
|
|
151
|
+
* all the elements in the array and applying the callback function to each element.
|
|
152
|
+
*/
|
|
153
|
+
reduce<U>(callbackfn: ReduceElementCallback<E, R, U, C>, initialValue: U): U;
|
|
154
|
+
/**
|
|
155
|
+
* Time Complexity: O(n)
|
|
156
|
+
* Space Complexity: O(n)
|
|
157
|
+
*/
|
|
158
|
+
/**
|
|
159
|
+
* Time Complexity: O(n)
|
|
160
|
+
* Space Complexity: O(n)
|
|
161
|
+
*
|
|
162
|
+
* The print function logs the elements of an array to the console.
|
|
163
|
+
*/
|
|
164
|
+
print(): void;
|
|
165
|
+
abstract isEmpty(): boolean;
|
|
166
|
+
abstract clear(): void;
|
|
167
|
+
abstract clone(): C;
|
|
168
|
+
abstract map(...args: any[]): any;
|
|
169
|
+
abstract filter(...args: any[]): any;
|
|
170
|
+
protected abstract _getIterator(...args: any[]): IterableIterator<E>;
|
|
171
|
+
}
|