data-structure-typed 1.45.0 → 1.45.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/.eslintrc.js +6 -6
- package/CHANGELOG.md +1 -1
- package/dist/cjs/data-structures/binary-tree/avl-tree.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/binary-indexed-tree.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/binary-tree.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/bst.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/rb-tree.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/tree-multimap.js.map +1 -1
- package/dist/cjs/data-structures/graph/abstract-graph.js.map +1 -1
- package/dist/cjs/data-structures/graph/directed-graph.js.map +1 -1
- package/dist/cjs/data-structures/graph/map-graph.js.map +1 -1
- package/dist/cjs/data-structures/graph/undirected-graph.js.map +1 -1
- package/dist/cjs/data-structures/hash/hash-map.d.ts +58 -58
- package/dist/cjs/data-structures/hash/hash-map.js +73 -73
- package/dist/cjs/data-structures/hash/hash-map.js.map +1 -1
- package/dist/cjs/data-structures/hash/tree-map.js.map +1 -1
- package/dist/cjs/data-structures/hash/tree-set.js.map +1 -1
- package/dist/cjs/data-structures/heap/heap.js.map +1 -1
- package/dist/cjs/data-structures/heap/max-heap.js.map +1 -1
- package/dist/cjs/data-structures/heap/min-heap.js.map +1 -1
- package/dist/cjs/data-structures/linked-list/doubly-linked-list.js.map +1 -1
- package/dist/cjs/data-structures/linked-list/singly-linked-list.js.map +1 -1
- package/dist/cjs/data-structures/matrix/matrix.js.map +1 -1
- package/dist/cjs/data-structures/matrix/matrix2d.js.map +1 -1
- package/dist/cjs/data-structures/matrix/navigator.js.map +1 -1
- package/dist/cjs/data-structures/matrix/vector2d.js.map +1 -1
- package/dist/cjs/data-structures/priority-queue/max-priority-queue.js.map +1 -1
- package/dist/cjs/data-structures/priority-queue/min-priority-queue.js.map +1 -1
- package/dist/cjs/data-structures/priority-queue/priority-queue.js.map +1 -1
- package/dist/cjs/data-structures/queue/deque.js.map +1 -1
- package/dist/cjs/data-structures/queue/queue.js.map +1 -1
- package/dist/cjs/data-structures/tree/tree.js.map +1 -1
- package/dist/cjs/data-structures/trie/trie.js.map +1 -1
- package/dist/cjs/utils/utils.js.map +1 -1
- package/dist/mjs/data-structures/hash/hash-map.d.ts +58 -58
- package/dist/mjs/data-structures/hash/hash-map.js +76 -76
- package/dist/umd/data-structure-typed.js +74 -72
- package/dist/umd/data-structure-typed.min.js +1 -1
- package/dist/umd/data-structure-typed.min.js.map +1 -1
- package/package.json +1 -1
- package/src/data-structures/binary-tree/avl-tree.ts +7 -7
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +3 -3
- package/src/data-structures/binary-tree/binary-tree.ts +39 -31
- package/src/data-structures/binary-tree/bst.ts +12 -8
- package/src/data-structures/binary-tree/rb-tree.ts +17 -6
- package/src/data-structures/binary-tree/segment-tree.ts +1 -1
- package/src/data-structures/binary-tree/tree-multimap.ts +12 -9
- package/src/data-structures/graph/abstract-graph.ts +46 -31
- package/src/data-structures/graph/directed-graph.ts +10 -5
- package/src/data-structures/graph/map-graph.ts +8 -8
- package/src/data-structures/graph/undirected-graph.ts +9 -9
- package/src/data-structures/hash/hash-map.ts +103 -103
- package/src/data-structures/hash/hash-table.ts +1 -1
- package/src/data-structures/hash/tree-map.ts +2 -1
- package/src/data-structures/hash/tree-set.ts +2 -1
- package/src/data-structures/heap/heap.ts +8 -5
- package/src/data-structures/heap/max-heap.ts +3 -3
- package/src/data-structures/heap/min-heap.ts +3 -3
- package/src/data-structures/linked-list/doubly-linked-list.ts +1 -1
- package/src/data-structures/linked-list/singly-linked-list.ts +1 -1
- package/src/data-structures/matrix/matrix.ts +2 -2
- package/src/data-structures/matrix/matrix2d.ts +1 -1
- package/src/data-structures/matrix/navigator.ts +3 -3
- package/src/data-structures/matrix/vector2d.ts +2 -1
- package/src/data-structures/priority-queue/max-priority-queue.ts +3 -3
- package/src/data-structures/priority-queue/min-priority-queue.ts +3 -3
- package/src/data-structures/priority-queue/priority-queue.ts +3 -3
- package/src/data-structures/queue/deque.ts +5 -4
- package/src/data-structures/queue/queue.ts +2 -2
- package/src/data-structures/tree/tree.ts +1 -1
- package/src/data-structures/trie/trie.ts +1 -1
- package/src/interfaces/binary-tree.ts +2 -2
- package/src/interfaces/graph.ts +1 -1
- package/src/types/data-structures/binary-tree/avl-tree.ts +2 -2
- package/src/types/data-structures/binary-tree/binary-tree.ts +1 -1
- package/src/types/data-structures/binary-tree/bst.ts +2 -2
- package/src/types/data-structures/binary-tree/rb-tree.ts +2 -2
- package/src/types/data-structures/binary-tree/tree-multimap.ts +2 -2
- package/src/types/data-structures/hash/hash-map.ts +6 -6
- package/src/types/data-structures/matrix/navigator.ts +1 -1
- package/src/types/utils/utils.ts +1 -1
- package/src/types/utils/validate-type.ts +18 -4
- package/src/utils/utils.ts +6 -6
- package/test/integration/all-in-one.ts +1 -1
- package/test/integration/avl-tree.test.ts +1 -1
- package/test/integration/bst.test.ts +19 -19
- package/test/integration/heap.test.js +1 -1
- package/test/integration/index.html +7 -7
- package/test/performance/data-structures/binary-tree/avl-tree.test.ts +4 -4
- package/test/performance/data-structures/binary-tree/binary-tree.test.ts +4 -4
- package/test/performance/data-structures/binary-tree/bst.test.ts +4 -4
- package/test/performance/data-structures/binary-tree/rb-tree.test.ts +6 -6
- package/test/performance/data-structures/graph/directed-graph.test.ts +4 -4
- package/test/performance/data-structures/hash/hash-map.test.ts +6 -6
- package/test/performance/data-structures/heap/heap.test.ts +5 -5
- package/test/performance/data-structures/linked-list/doubly-linked-list.test.ts +6 -6
- package/test/performance/data-structures/linked-list/singly-linked-list.test.ts +4 -4
- package/test/performance/data-structures/priority-queue/max-priority-queue.test.ts +7 -5
- package/test/performance/data-structures/priority-queue/priority-queue.test.ts +7 -7
- package/test/performance/data-structures/queue/deque.test.ts +5 -5
- package/test/performance/data-structures/queue/queue.test.ts +6 -6
- package/test/performance/data-structures/stack/stack.test.ts +6 -6
- package/test/performance/data-structures/trie/trie.test.ts +4 -4
- package/test/performance/reportor.ts +15 -13
- package/test/performance/types/reportor.ts +1 -1
- package/test/types/utils/json2html.ts +1 -1
- package/test/unit/data-structures/binary-tree/avl-tree.test.ts +6 -6
- package/test/unit/data-structures/binary-tree/binary-index-tree.test.ts +12 -12
- package/test/unit/data-structures/binary-tree/binary-tree.test.ts +46 -76
- package/test/unit/data-structures/binary-tree/bst.test.ts +44 -40
- package/test/unit/data-structures/binary-tree/overall.test.ts +17 -17
- package/test/unit/data-structures/binary-tree/rb-tree.test.ts +9 -9
- package/test/unit/data-structures/binary-tree/segment-tree.test.ts +1 -1
- package/test/unit/data-structures/binary-tree/tree-multimap.test.ts +35 -35
- package/test/unit/data-structures/graph/abstract-graph.test.ts +7 -7
- package/test/unit/data-structures/graph/directed-graph.test.ts +34 -14
- package/test/unit/data-structures/graph/map-graph.test.ts +1 -1
- package/test/unit/data-structures/graph/overall.test.ts +1 -1
- package/test/unit/data-structures/graph/undirected-graph.test.ts +1 -1
- package/test/unit/data-structures/hash/coordinate-map.test.ts +1 -1
- package/test/unit/data-structures/hash/coordinate-set.test.ts +1 -1
- package/test/unit/data-structures/hash/hash-map.test.ts +10 -12
- package/test/unit/data-structures/hash/hash-table.test.ts +1 -1
- package/test/unit/data-structures/heap/heap.test.ts +35 -23
- package/test/unit/data-structures/heap/max-heap.test.ts +2 -2
- package/test/unit/data-structures/heap/min-heap.test.ts +2 -2
- package/test/unit/data-structures/linked-list/doubly-linked-list.test.ts +5 -5
- package/test/unit/data-structures/linked-list/singly-linked-list.test.ts +5 -5
- package/test/unit/data-structures/linked-list/skip-list.test.ts +1 -1
- package/test/unit/data-structures/matrix/matrix.test.ts +5 -5
- package/test/unit/data-structures/matrix/matrix2d.test.ts +3 -3
- package/test/unit/data-structures/matrix/navigator.test.ts +2 -2
- package/test/unit/data-structures/matrix/vector2d.test.ts +1 -1
- package/test/unit/data-structures/priority-queue/max-priority-queue.test.ts +7 -7
- package/test/unit/data-structures/priority-queue/min-priority-queue.test.ts +1 -1
- package/test/unit/data-structures/priority-queue/priority-queue.test.ts +19 -19
- package/test/unit/data-structures/queue/deque.test.ts +3 -3
- package/test/unit/data-structures/queue/queue.test.ts +3 -3
- package/test/unit/data-structures/stack/stack.test.ts +1 -1
- package/test/unit/data-structures/tree/tree.test.ts +1 -1
- package/test/unit/data-structures/trie/trie.test.ts +1 -1
- package/test/utils/array.ts +1 -1
- package/test/utils/big-o.ts +4 -4
- package/test/utils/json2html.ts +7 -3
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {PriorityQueue} from '../../../../src';
|
|
2
|
-
import {PriorityQueue as CPriorityQueue} from 'js-sdsl';
|
|
3
|
-
import {isDebugTest} from '../../../config';
|
|
1
|
+
import { PriorityQueue } from '../../../../src';
|
|
2
|
+
import { PriorityQueue as CPriorityQueue } from 'js-sdsl';
|
|
3
|
+
import { isDebugTest } from '../../../config';
|
|
4
4
|
|
|
5
5
|
const isDebug = isDebugTest;
|
|
6
6
|
describe('PriorityQueue Operation Test', () => {
|
|
7
7
|
it('should PriorityQueue poll, pee, heapify, toArray work well', function () {
|
|
8
|
-
const minPQ = new PriorityQueue<number>({comparator: (a, b) => a - b});
|
|
8
|
+
const minPQ = new PriorityQueue<number>({ comparator: (a, b) => a - b });
|
|
9
9
|
minPQ.refill([5, 2, 3, 4, 6, 1]);
|
|
10
10
|
expect(minPQ.toArray()).toEqual([1, 2, 3, 4, 6, 5]);
|
|
11
11
|
minPQ.poll();
|
|
@@ -13,16 +13,16 @@ describe('PriorityQueue Operation Test', () => {
|
|
|
13
13
|
minPQ.poll();
|
|
14
14
|
expect(minPQ.toArray()).toEqual([4, 5, 6]);
|
|
15
15
|
expect(minPQ.peek()).toBe(4);
|
|
16
|
-
expect(
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
]);
|
|
16
|
+
expect(
|
|
17
|
+
PriorityQueue.heapify({
|
|
18
|
+
nodes: [3, 2, 1, 5, 6, 7, 8, 9, 10],
|
|
19
|
+
comparator: (a, b) => a - b
|
|
20
|
+
}).toArray()
|
|
21
|
+
).toEqual([1, 2, 3, 5, 6, 7, 8, 9, 10]);
|
|
22
22
|
});
|
|
23
23
|
|
|
24
24
|
it('should Max PriorityQueue poll, peek, heapify, toArray work well', function () {
|
|
25
|
-
const maxPriorityQueue = new PriorityQueue<number>({comparator: (a, b) => b - a});
|
|
25
|
+
const maxPriorityQueue = new PriorityQueue<number>({ comparator: (a, b) => b - a });
|
|
26
26
|
maxPriorityQueue.refill([5, 2, 3, 4, 6, 1]);
|
|
27
27
|
expect(maxPriorityQueue.toArray()).toEqual([6, 5, 3, 4, 2, 1]);
|
|
28
28
|
maxPriorityQueue.poll();
|
|
@@ -30,16 +30,16 @@ describe('PriorityQueue Operation Test', () => {
|
|
|
30
30
|
maxPriorityQueue.poll();
|
|
31
31
|
expect(maxPriorityQueue.toArray()).toEqual([3, 2, 1]);
|
|
32
32
|
expect(maxPriorityQueue.peek()).toBe(3);
|
|
33
|
-
expect(
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
]);
|
|
33
|
+
expect(
|
|
34
|
+
PriorityQueue.heapify({
|
|
35
|
+
nodes: [3, 2, 1, 5, 6, 7, 8, 9, 10],
|
|
36
|
+
comparator: (a, b) => a - b
|
|
37
|
+
}).toArray()
|
|
38
|
+
).toEqual([1, 2, 3, 5, 6, 7, 8, 9, 10]);
|
|
39
39
|
});
|
|
40
40
|
|
|
41
41
|
it('should PriorityQueue clone, sort, getNodes, dfs work well', function () {
|
|
42
|
-
const minPQ1 = new PriorityQueue<number>({comparator: (a, b) => a - b});
|
|
42
|
+
const minPQ1 = new PriorityQueue<number>({ comparator: (a, b) => a - b });
|
|
43
43
|
minPQ1.refill([2, 5, 8, 3, 1, 6, 7, 4]);
|
|
44
44
|
const clonedPriorityQueue = minPQ1.clone();
|
|
45
45
|
expect(clonedPriorityQueue.getNodes()).toEqual(minPQ1.getNodes());
|
|
@@ -52,7 +52,7 @@ describe('PriorityQueue Operation Test', () => {
|
|
|
52
52
|
|
|
53
53
|
describe('Priority Queue Performance Test', () => {
|
|
54
54
|
it('should numeric heap work well', function () {
|
|
55
|
-
const pq = new PriorityQueue({comparator: (a, b) => b - a});
|
|
55
|
+
const pq = new PriorityQueue({ comparator: (a, b) => b - a });
|
|
56
56
|
|
|
57
57
|
const tS = performance.now();
|
|
58
58
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {ArrayDeque, Deque, ObjectDeque} from '../../../../src';
|
|
2
|
-
import {bigO} from '../../../utils';
|
|
3
|
-
import {isDebugTest} from '../../../config';
|
|
1
|
+
import { ArrayDeque, Deque, ObjectDeque } from '../../../../src';
|
|
2
|
+
import { bigO } from '../../../utils';
|
|
3
|
+
import { isDebugTest } from '../../../config';
|
|
4
4
|
|
|
5
5
|
const isDebug = isDebugTest;
|
|
6
6
|
describe('Deque Tests', () => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {LinkedListQueue, Queue} from '../../../../src';
|
|
2
|
-
import {bigO} from '../../../utils';
|
|
3
|
-
import {isDebugTest} from '../../../config';
|
|
1
|
+
import { LinkedListQueue, Queue } from '../../../../src';
|
|
2
|
+
import { bigO } from '../../../utils';
|
|
3
|
+
import { isDebugTest } from '../../../config';
|
|
4
4
|
|
|
5
5
|
const isDebug = isDebugTest;
|
|
6
6
|
describe('Queue Operation Test', () => {
|
package/test/utils/array.ts
CHANGED
package/test/utils/big-o.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {AnyFunction} from '../types';
|
|
2
|
-
import {isDebugTest} from '../config';
|
|
1
|
+
import { AnyFunction } from '../types';
|
|
2
|
+
import { isDebugTest } from '../config';
|
|
3
3
|
|
|
4
4
|
const isDebug = isDebugTest;
|
|
5
5
|
const orderReducedBy = 1; // reduction of bigO's order compared to the baseline bigO
|
|
@@ -32,7 +32,7 @@ export const bigO = {
|
|
|
32
32
|
|
|
33
33
|
function findPotentialN(input: any): number {
|
|
34
34
|
let longestArray: any[] = [];
|
|
35
|
-
let mostProperties: {[key: string]: any} = {};
|
|
35
|
+
let mostProperties: { [key: string]: any } = {};
|
|
36
36
|
|
|
37
37
|
function recurse(obj: any) {
|
|
38
38
|
if (Array.isArray(obj)) {
|
|
@@ -81,7 +81,7 @@ function linearRegression(x: number[], y: number[]) {
|
|
|
81
81
|
|
|
82
82
|
const rSquared = 1 - totalVariation / explainedVariation;
|
|
83
83
|
|
|
84
|
-
return {slope, intercept, rSquared};
|
|
84
|
+
return { slope, intercept, rSquared };
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
function estimateBigO(runtimes: number[], dataSizes: number[]): string {
|
package/test/utils/json2html.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _ from './is';
|
|
2
|
-
import {Json2htmlOptions} from '../types';
|
|
2
|
+
import { Json2htmlOptions } from '../types';
|
|
3
3
|
|
|
4
4
|
function toggleJS(options?: Json2htmlOptions): string {
|
|
5
5
|
if (options?.plainHtml) {
|
|
@@ -14,7 +14,9 @@ function makeLabelDiv(options: any, level: number, keyName: string | number, dat
|
|
|
14
14
|
return `<div class='index'><span class='json-to-html-label'>${keyName} </span></div>`;
|
|
15
15
|
} else if (typeof keyName === 'string') {
|
|
16
16
|
if (datatype === 'array') {
|
|
17
|
-
return `<div class='collapsible level${level}' ${toggleJS(
|
|
17
|
+
return `<div class='collapsible level${level}' ${toggleJS(
|
|
18
|
+
options
|
|
19
|
+
)}><span class='json-to-html-label'>${keyName}</span></div>`;
|
|
18
20
|
} else if (datatype === 'object') {
|
|
19
21
|
return `<div class='attribute collapsible level${level}' ${toggleJS(
|
|
20
22
|
options
|
|
@@ -120,7 +122,9 @@ function _render(name: string, data: any, options: Json2htmlOptions, level: numb
|
|
|
120
122
|
} else {
|
|
121
123
|
subs =
|
|
122
124
|
"<div class='altRows'>" +
|
|
123
|
-
data
|
|
125
|
+
data
|
|
126
|
+
.map((val: any, idx: number) => _render(idx.toString(), val, options, level + 1, idx % 2))
|
|
127
|
+
.join("</div><div class='altRows'>") +
|
|
124
128
|
'</div>';
|
|
125
129
|
}
|
|
126
130
|
return `<div class="json-to-html-collapse clearfix ${altRow}">
|