diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8866bc1..5a6c379 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,7 +8,7 @@ All notable changes to this project will be documented in this file.
- [Semantic Versioning](https://semver.org/spec/v2.0.0.html)
- [`auto-changelog`](https://github.com/CookPete/auto-changelog)
-## [v1.42.9](https://github.com/zrwusa/data-structure-typed/compare/v1.35.0...main) (upcoming)
+## [v1.43.0](https://github.com/zrwusa/data-structure-typed/compare/v1.35.0...main) (upcoming)
### Changes
diff --git a/README.md b/README.md
index 6947dea..9f977bb 100644
--- a/README.md
+++ b/README.md
@@ -728,40 +728,40 @@ optimal approach to data structure design.
[//]: # (No deletion!!! Start of Replace Section)
avl-tree
-
test name | time taken (ms) | executions per sec | sample deviation |
---|
10,000 add randomly | 33.60 | 29.76 | 0.00 |
10,000 add & delete randomly | 72.39 | 13.81 | 0.01 |
10,000 addMany | 41.06 | 24.35 | 0.00 |
10,000 get | 28.01 | 35.71 | 0.00 |
+
test name | time taken (ms) | executions per sec | sample deviation |
---|
10,000 add randomly | 32.23 | 31.03 | 0.00 |
10,000 add & delete randomly | 72.19 | 13.85 | 0.00 |
10,000 addMany | 41.39 | 24.16 | 9.33e-4 |
10,000 get | 28.05 | 35.66 | 0.00 |
binary-tree
-
test name | time taken (ms) | executions per sec | sample deviation |
---|
1,000 add randomly | 12.64 | 79.09 | 6.90e-4 |
1,000 add & delete randomly | 16.03 | 62.38 | 5.30e-4 |
1,000 addMany | 10.44 | 95.78 | 0.00 |
1,000 get | 18.19 | 54.98 | 3.11e-4 |
1,000 dfs | 154.71 | 6.46 | 0.00 |
1,000 bfs | 56.97 | 17.55 | 8.92e-4 |
1,000 morris | 260.71 | 3.84 | 0.00 |
+
test name | time taken (ms) | executions per sec | sample deviation |
---|
1,000 add randomly | 12.56 | 79.59 | 6.46e-4 |
1,000 add & delete randomly | 16.15 | 61.91 | 7.18e-4 |
1,000 addMany | 10.64 | 93.95 | 6.17e-4 |
1,000 get | 18.44 | 54.22 | 4.23e-4 |
1,000 dfs | 160.17 | 6.24 | 0.01 |
1,000 bfs | 57.41 | 17.42 | 0.00 |
1,000 morris | 264.54 | 3.78 | 0.00 |
bst
-
test name | time taken (ms) | executions per sec | sample deviation |
---|
10,000 add randomly | 29.57 | 33.81 | 2.75e-4 |
10,000 add & delete randomly | 70.78 | 14.13 | 0.00 |
10,000 addMany | 29.10 | 34.36 | 6.84e-4 |
10,000 get | 28.75 | 34.78 | 6.05e-4 |
+
test name | time taken (ms) | executions per sec | sample deviation |
---|
10,000 add randomly | 28.45 | 35.15 | 4.14e-4 |
10,000 add & delete randomly | 67.78 | 14.75 | 0.00 |
10,000 addMany | 29.04 | 34.43 | 5.76e-4 |
10,000 get | 28.67 | 34.88 | 8.26e-4 |
rb-tree
-
test name | time taken (ms) | executions per sec | sample deviation |
---|
100,000 add randomly | 88.55 | 11.29 | 0.01 |
100,000 add & delete randomly | 220.41 | 4.54 | 0.01 |
100,000 getNode | 37.52 | 26.65 | 2.68e-4 |
+
test name | time taken (ms) | executions per sec | sample deviation |
---|
100,000 add randomly | 90.96 | 10.99 | 0.01 |
100,000 competitor add randomly | 50.10 | 19.96 | 0.01 |
100,000 add & delete randomly | 219.06 | 4.56 | 0.01 |
100,000 getNode | 106.06 | 9.43 | 0.00 |
directed-graph
-
test name | time taken (ms) | executions per sec | sample deviation |
---|
1,000 addVertex | 0.10 | 9804.12 | 1.07e-6 |
1,000 addEdge | 6.06 | 165.11 | 1.66e-4 |
1,000 getVertex | 0.05 | 2.17e+4 | 3.48e-7 |
1,000 getEdge | 23.26 | 43.00 | 0.00 |
tarjan | 223.27 | 4.48 | 0.01 |
tarjan all | 224.27 | 4.46 | 0.00 |
topologicalSort | 179.19 | 5.58 | 0.00 |
+
test name | time taken (ms) | executions per sec | sample deviation |
---|
1,000 addVertex | 0.11 | 9433.92 | 4.40e-6 |
1,000 addEdge | 6.24 | 160.30 | 2.02e-4 |
1,000 getVertex | 0.05 | 2.13e+4 | 1.64e-6 |
1,000 getEdge | 23.80 | 42.02 | 0.00 |
tarjan | 218.46 | 4.58 | 0.01 |
tarjan all | 221.95 | 4.51 | 0.00 |
topologicalSort | 183.70 | 5.44 | 0.01 |
heap
-
test name | time taken (ms) | executions per sec | sample deviation |
---|
10,000 add & pop | 4.62 | 216.39 | 3.75e-5 |
10,000 fib add & pop | 354.57 | 2.82 | 0.00 |
+
test name | time taken (ms) | executions per sec | sample deviation |
---|
10,000 add & pop | 4.63 | 215.97 | 4.50e-5 |
10,000 fib add & pop | 359.98 | 2.78 | 0.00 |
doubly-linked-list
-
test name | time taken (ms) | executions per sec | sample deviation |
---|
1,000,000 unshift | 225.57 | 4.43 | 0.02 |
1,000,000 unshift & shift | 164.91 | 6.06 | 0.02 |
1,000,000 insertBefore | 342.06 | 2.92 | 0.09 |
+
test name | time taken (ms) | executions per sec | sample deviation |
---|
1,000,000 unshift | 233.68 | 4.28 | 0.06 |
1,000,000 unshift & shift | 185.63 | 5.39 | 0.05 |
1,000,000 insertBefore | 321.19 | 3.11 | 0.04 |
singly-linked-list
-
test name | time taken (ms) | executions per sec | sample deviation |
---|
10,000 push & pop | 224.20 | 4.46 | 0.02 |
10,000 insertBefore | 244.96 | 4.08 | 0.00 |
+
test name | time taken (ms) | executions per sec | sample deviation |
---|
10,000 push & pop | 217.95 | 4.59 | 0.01 |
10,000 insertBefore | 248.81 | 4.02 | 0.00 |
max-priority-queue
-
test name | time taken (ms) | executions per sec | sample deviation |
---|
10,000 refill & poll | 11.45 | 87.32 | 1.74e-4 |
+
test name | time taken (ms) | executions per sec | sample deviation |
---|
10,000 refill & poll | 11.72 | 85.30 | 2.79e-4 |
deque
-
test name | time taken (ms) | executions per sec | sample deviation |
---|
1,000,000 push | 222.74 | 4.49 | 0.08 |
1,000,000 shift | 26.48 | 37.77 | 0.00 |
+
test name | time taken (ms) | executions per sec | sample deviation |
---|
1,000,000 push | 204.13 | 4.90 | 0.04 |
1,000,000 shift | 25.71 | 38.89 | 0.00 |
queue
-
test name | time taken (ms) | executions per sec | sample deviation |
---|
1,000,000 push | 45.50 | 21.98 | 0.01 |
1,000,000 push & shift | 80.10 | 12.48 | 0.00 |
+
test name | time taken (ms) | executions per sec | sample deviation |
---|
1,000,000 push | 42.93 | 23.30 | 0.00 |
1,000,000 push & shift | 80.12 | 12.48 | 0.00 |
trie
-
test name | time taken (ms) | executions per sec | sample deviation |
---|
100,000 push | 56.99 | 17.55 | 0.01 |
100,000 getWords | 98.43 | 10.16 | 0.01 |
+
test name | time taken (ms) | executions per sec | sample deviation |
---|
100,000 push | 56.09 | 17.83 | 0.00 |
100,000 getWords | 97.76 | 10.23 | 0.01 |
[//]: # (No deletion!!! End of Replace Section)
\ No newline at end of file
diff --git a/package-lock.json b/package-lock.json
index c0faebd..6915fd4 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "data-structure-typed",
- "version": "1.42.5",
+ "version": "1.43.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "data-structure-typed",
- "version": "1.42.5",
+ "version": "1.43.0",
"license": "MIT",
"devDependencies": {
"@types/benchmark": "^2.1.3",
@@ -30,6 +30,7 @@
"heap-typed": "^1.42.5",
"istanbul-badges-readme": "^1.8.5",
"jest": "^29.7.0",
+ "js-sdsl": "^4.4.2",
"prettier": "^3.0.3",
"ts-jest": "^29.1.1",
"ts-loader": "^9.4.4",
@@ -6628,6 +6629,16 @@
"node": ">=10"
}
},
+ "node_modules/js-sdsl": {
+ "version": "4.4.2",
+ "resolved": "https://registry.npmjs.org/js-sdsl/-/js-sdsl-4.4.2.tgz",
+ "integrity": "sha512-dwXFwByc/ajSV6m5bcKAPwe4yDDF6D614pxmIi5odytzxRlwqF6nwoiCek80Ixc7Cvma5awClxrzFtxCQvcM8w==",
+ "dev": true,
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/js-sdsl"
+ }
+ },
"node_modules/js-tokens": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",
diff --git a/package.json b/package.json
index e464d1b..ca7ae2a 100644
--- a/package.json
+++ b/package.json
@@ -78,6 +78,7 @@
"heap-typed": "^1.42.5",
"istanbul-badges-readme": "^1.8.5",
"jest": "^29.7.0",
+ "js-sdsl": "^4.4.2",
"prettier": "^3.0.3",
"ts-jest": "^29.1.1",
"ts-loader": "^9.4.4",
diff --git a/test/performance/data-structures/binary-tree/rb-tree.test.ts b/test/performance/data-structures/binary-tree/rb-tree.test.ts
index 34b4532..2eb72f9 100644
--- a/test/performance/data-structures/binary-tree/rb-tree.test.ts
+++ b/test/performance/data-structures/binary-tree/rb-tree.test.ts
@@ -1,11 +1,13 @@
import {RedBlackTree} from '../../../../src';
import * as Benchmark from 'benchmark';
import {getRandomIntArray, magnitude} from '../../../utils';
+import {OrderedMap} from 'js-sdsl';
const suite = new Benchmark.Suite();
const rbTree = new RedBlackTree();
const {HUNDRED_THOUSAND} = magnitude;
const arr = getRandomIntArray(HUNDRED_THOUSAND, 0, HUNDRED_THOUSAND, true);
+const competitor = new OrderedMap();
suite
.add(`${HUNDRED_THOUSAND.toLocaleString()} add randomly`, () => {
@@ -14,6 +16,11 @@ suite
rbTree.add(arr[i]);
}
})
+ .add(`${HUNDRED_THOUSAND.toLocaleString()} competitor add randomly`, () => {
+ for (let i = 0; i < arr.length; i++) {
+ competitor.setElement(arr[i], arr[i]);
+ }
+ })
.add(`${HUNDRED_THOUSAND.toLocaleString()} add & delete randomly`, () => {
rbTree.clear();
for (let i = 0; i < arr.length; i++) {
diff --git a/test/performance/data-structures/hash/hash-map.test.ts b/test/performance/data-structures/hash/hash-map.test.ts
index e69de29..703b76f 100644
--- a/test/performance/data-structures/hash/hash-map.test.ts
+++ b/test/performance/data-structures/hash/hash-map.test.ts
@@ -0,0 +1,45 @@
+import {HashMap} from '../../../../src';
+import {HashMap as CHashMap} from 'js-sdsl';
+import * as Benchmark from 'benchmark';
+import {magnitude} from '../../../utils';
+
+const suite = new Benchmark.Suite();
+const {LINEAR} = magnitude;
+
+suite
+ .add(`${LINEAR.toLocaleString()} set`, () => {
+ const hm = new HashMap();
+
+ for (let i = 0; i < LINEAR; i++) {
+ hm.set(i, i);
+ }
+ })
+ .add(`${LINEAR.toLocaleString()} competitor set`, () => {
+ const hm = new CHashMap();
+
+ for (let i = 0; i < LINEAR; i++) {
+ hm.setElement(i, i);
+ }
+ })
+ .add(`${LINEAR.toLocaleString()} set & get`, () => {
+ const hm = new HashMap();
+
+ for (let i = 0; i < LINEAR; i++) {
+ hm.set(i, i);
+ }
+ for (let i = 0; i < LINEAR; i++) {
+ hm.get(i);
+ }
+ })
+ .add(`${LINEAR.toLocaleString()} competitor set & get`, () => {
+ const hm = new CHashMap();
+
+ for (let i = 0; i < LINEAR; i++) {
+ hm.setElement(i, i);
+ }
+ for (let i = 0; i < LINEAR; i++) {
+ hm.getElementByKey(i);
+ }
+ });
+
+export {suite};
diff --git a/test/performance/data-structures/linked-list/doubly-linked-list.test.ts b/test/performance/data-structures/linked-list/doubly-linked-list.test.ts
index 5cc9977..3911fd9 100644
--- a/test/performance/data-structures/linked-list/doubly-linked-list.test.ts
+++ b/test/performance/data-structures/linked-list/doubly-linked-list.test.ts
@@ -1,4 +1,5 @@
import {DoublyLinkedList, DoublyLinkedListNode} from '../../../../src';
+import {LinkList as CLinkedList} from 'js-sdsl';
import * as Benchmark from 'benchmark';
import {magnitude} from '../../../utils';
@@ -13,6 +14,13 @@ suite
list.unshift(i);
}
})
+ .add(`${LINEAR.toLocaleString()} competitor unshift`, () => {
+ const list = new CLinkedList();
+
+ for (let i = 0; i < LINEAR; i++) {
+ list.pushFront(i);
+ }
+ })
.add(`${LINEAR.toLocaleString()} unshift & shift`, () => {
const list = new DoublyLinkedList();
diff --git a/test/performance/data-structures/priority-queue/priority-queue.test.ts b/test/performance/data-structures/priority-queue/priority-queue.test.ts
index e69de29..04808f2 100644
--- a/test/performance/data-structures/priority-queue/priority-queue.test.ts
+++ b/test/performance/data-structures/priority-queue/priority-queue.test.ts
@@ -0,0 +1,33 @@
+import {PriorityQueue as CPriorityQueue} from 'js-sdsl';
+import {PriorityQueue} from '../../../../src';
+import * as Benchmark from 'benchmark';
+import {magnitude} from '../../../utils';
+
+const suite = new Benchmark.Suite();
+const {TEN_THOUSAND} = magnitude;
+
+suite
+ .add(`${TEN_THOUSAND.toLocaleString()} add & pop`, () => {
+ const pq = new PriorityQueue({comparator: (a, b) => b - a});
+
+ for (let i = 0; i < TEN_THOUSAND; i++) {
+ pq.add(i);
+ }
+
+ for (let i = 0; i < TEN_THOUSAND; i++) {
+ pq.pop();
+ }
+ })
+ .add(`${TEN_THOUSAND.toLocaleString()} competitor add & pop`, () => {
+ const pq = new CPriorityQueue();
+
+ for (let i = 0; i < TEN_THOUSAND; i++) {
+ pq.push(i);
+ }
+
+ for (let i = 0; i < TEN_THOUSAND; i++) {
+ pq.pop();
+ }
+ });
+
+export {suite};
diff --git a/test/performance/data-structures/queue/deque.test.ts b/test/performance/data-structures/queue/deque.test.ts
index 566b370..a0bde90 100644
--- a/test/performance/data-structures/queue/deque.test.ts
+++ b/test/performance/data-structures/queue/deque.test.ts
@@ -1,4 +1,5 @@
import {Deque} from '../../../../src';
+import {Deque as CDeque} from 'js-sdsl';
import * as Benchmark from 'benchmark';
import {magnitude} from '../../../utils';
@@ -12,6 +13,12 @@ suite
deque.push(i);
}
})
+ .add(`${LINEAR.toLocaleString()} competitor push`, () => {
+ const deque = new CDeque();
+ for (let i = 0; i < LINEAR; i++) {
+ deque.pushBack(i);
+ }
+ })
.add(`${LINEAR.toLocaleString()} shift`, () => {
const deque = new Deque();
for (let i = 0; i < LINEAR; i++) {
diff --git a/test/performance/data-structures/queue/queue.test.ts b/test/performance/data-structures/queue/queue.test.ts
index a5b5874..93e32a2 100644
--- a/test/performance/data-structures/queue/queue.test.ts
+++ b/test/performance/data-structures/queue/queue.test.ts
@@ -1,4 +1,5 @@
import {Queue} from '../../../../src';
+import {Queue as CQueue} from 'js-sdsl';
import * as Benchmark from 'benchmark';
import {magnitude} from '../../../utils';
@@ -13,6 +14,13 @@ suite
queue.push(i);
}
})
+ .add(`${LINEAR.toLocaleString()} competitor push`, () => {
+ const queue = new CQueue();
+
+ for (let i = 0; i < LINEAR; i++) {
+ queue.push(i);
+ }
+ })
.add(`${LINEAR.toLocaleString()} push & shift`, () => {
const queue = new Queue();
diff --git a/test/performance/data-structures/stack/stack.test.ts b/test/performance/data-structures/stack/stack.test.ts
index e69de29..ec3c24d 100644
--- a/test/performance/data-structures/stack/stack.test.ts
+++ b/test/performance/data-structures/stack/stack.test.ts
@@ -0,0 +1,45 @@
+import {Stack} from '../../../../src';
+import {Stack as CStack} from 'js-sdsl';
+import * as Benchmark from 'benchmark';
+import {magnitude} from '../../../utils';
+
+const suite = new Benchmark.Suite();
+const {LINEAR} = magnitude;
+
+suite
+ .add(`${LINEAR.toLocaleString()} push`, () => {
+ const stack = new Stack();
+
+ for (let i = 0; i < LINEAR; i++) {
+ stack.push(i);
+ }
+ })
+ .add(`${LINEAR.toLocaleString()} competitor push`, () => {
+ const queue = new CStack();
+
+ for (let i = 0; i < LINEAR; i++) {
+ queue.push(i);
+ }
+ })
+ .add(`${LINEAR.toLocaleString()} push & pop`, () => {
+ const queue = new Stack();
+
+ for (let i = 0; i < LINEAR; i++) {
+ queue.push(i);
+ }
+ for (let i = 0; i < LINEAR; i++) {
+ queue.pop();
+ }
+ })
+ .add(`${LINEAR.toLocaleString()} competitor push & pop`, () => {
+ const queue = new CStack();
+
+ for (let i = 0; i < LINEAR; i++) {
+ queue.push(i);
+ }
+ for (let i = 0; i < LINEAR; i++) {
+ queue.pop();
+ }
+ });
+
+export {suite};