avl-tree-typed 1.40.0-rc → 1.40.0
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/README.md +21 -3
- package/coverage/clover.xml +5 -2
- package/coverage/coverage-final.json +95 -1
- package/coverage/coverage-summary.json +59 -2
- package/coverage/lcov-report/base.css +294 -115
- package/coverage/lcov-report/block-navigation.js +68 -68
- package/coverage/lcov-report/index.html +108 -105
- package/coverage/lcov-report/index.ts.html +76 -76
- package/coverage/lcov-report/sorter.js +183 -173
- package/dist/data-structures/binary-tree/avl-tree.d.ts +106 -0
- package/dist/data-structures/binary-tree/avl-tree.js +347 -0
- package/dist/data-structures/binary-tree/binary-indexed-tree.d.ts +149 -0
- package/dist/data-structures/binary-tree/binary-indexed-tree.js +269 -0
- package/dist/data-structures/binary-tree/binary-tree.d.ts +355 -0
- package/dist/data-structures/binary-tree/binary-tree.js +1115 -0
- package/dist/data-structures/binary-tree/bst.d.ts +167 -0
- package/dist/data-structures/binary-tree/bst.js +512 -0
- package/dist/data-structures/binary-tree/index.d.ts +7 -0
- package/dist/data-structures/binary-tree/index.js +23 -0
- package/dist/data-structures/binary-tree/rb-tree.d.ts +11 -0
- package/dist/data-structures/binary-tree/rb-tree.js +21 -0
- package/dist/data-structures/binary-tree/segment-tree.d.ts +67 -0
- package/dist/data-structures/binary-tree/segment-tree.js +180 -0
- package/dist/data-structures/binary-tree/tree-multiset.d.ts +126 -0
- package/dist/data-structures/binary-tree/tree-multiset.js +355 -0
- package/dist/data-structures/graph/abstract-graph.d.ts +313 -0
- package/dist/data-structures/graph/abstract-graph.js +884 -0
- package/dist/data-structures/graph/directed-graph.d.ts +194 -0
- package/dist/data-structures/graph/directed-graph.js +404 -0
- package/dist/data-structures/graph/index.d.ts +4 -0
- package/dist/data-structures/graph/index.js +20 -0
- package/dist/data-structures/graph/map-graph.d.ts +73 -0
- package/dist/data-structures/graph/map-graph.js +93 -0
- package/dist/data-structures/graph/undirected-graph.d.ts +120 -0
- package/dist/data-structures/graph/undirected-graph.js +239 -0
- package/dist/data-structures/hash/coordinate-map.d.ts +44 -0
- package/dist/data-structures/hash/coordinate-map.js +62 -0
- package/dist/data-structures/hash/coordinate-set.d.ts +36 -0
- package/dist/data-structures/hash/coordinate-set.js +52 -0
- package/dist/data-structures/hash/hash-map.d.ts +50 -0
- package/dist/data-structures/hash/hash-map.js +153 -0
- package/dist/data-structures/hash/hash-table.d.ts +103 -0
- package/dist/data-structures/hash/hash-table.js +236 -0
- package/dist/data-structures/hash/index.d.ts +6 -0
- package/dist/data-structures/hash/index.js +22 -0
- package/dist/data-structures/hash/tree-map.d.ts +2 -0
- package/dist/data-structures/hash/tree-map.js +6 -0
- package/dist/data-structures/hash/tree-set.d.ts +2 -0
- package/dist/data-structures/hash/tree-set.js +6 -0
- package/dist/data-structures/heap/heap.d.ts +235 -0
- package/dist/data-structures/heap/heap.js +515 -0
- package/dist/data-structures/heap/index.d.ts +3 -0
- package/dist/data-structures/heap/index.js +19 -0
- package/dist/data-structures/heap/max-heap.d.ts +15 -0
- package/dist/data-structures/heap/max-heap.js +26 -0
- package/dist/data-structures/heap/min-heap.d.ts +15 -0
- package/dist/data-structures/heap/min-heap.js +26 -0
- package/dist/data-structures/index.d.ts +11 -0
- package/dist/data-structures/index.js +27 -0
- package/dist/data-structures/linked-list/doubly-linked-list.d.ts +253 -0
- package/dist/data-structures/linked-list/doubly-linked-list.js +569 -0
- package/dist/data-structures/linked-list/index.d.ts +3 -0
- package/dist/data-structures/linked-list/index.js +19 -0
- package/dist/data-structures/linked-list/singly-linked-list.d.ts +232 -0
- package/dist/data-structures/linked-list/singly-linked-list.js +533 -0
- package/dist/data-structures/linked-list/skip-linked-list.d.ts +80 -0
- package/dist/data-structures/linked-list/skip-linked-list.js +187 -0
- package/dist/data-structures/matrix/index.d.ts +4 -0
- package/dist/data-structures/matrix/index.js +20 -0
- package/dist/data-structures/matrix/matrix.d.ts +21 -0
- package/dist/data-structures/matrix/matrix.js +28 -0
- package/dist/data-structures/matrix/matrix2d.d.ts +107 -0
- package/dist/data-structures/matrix/matrix2d.js +199 -0
- package/dist/data-structures/matrix/navigator.d.ts +52 -0
- package/dist/data-structures/matrix/navigator.js +106 -0
- package/dist/data-structures/matrix/vector2d.d.ts +200 -0
- package/dist/data-structures/matrix/vector2d.js +290 -0
- package/dist/data-structures/priority-queue/index.d.ts +3 -0
- package/dist/data-structures/priority-queue/index.js +19 -0
- package/dist/data-structures/priority-queue/max-priority-queue.d.ts +15 -0
- package/dist/data-structures/priority-queue/max-priority-queue.js +26 -0
- package/dist/data-structures/priority-queue/min-priority-queue.d.ts +15 -0
- package/dist/data-structures/priority-queue/min-priority-queue.js +26 -0
- package/dist/data-structures/priority-queue/priority-queue.d.ts +15 -0
- package/dist/data-structures/priority-queue/priority-queue.js +17 -0
- package/dist/data-structures/queue/deque.d.ts +161 -0
- package/dist/data-structures/queue/deque.js +264 -0
- package/dist/data-structures/queue/index.d.ts +2 -0
- package/dist/data-structures/queue/index.js +18 -0
- package/dist/data-structures/queue/queue.d.ts +122 -0
- package/dist/data-structures/queue/queue.js +187 -0
- package/dist/data-structures/stack/index.d.ts +1 -0
- package/dist/data-structures/stack/index.js +17 -0
- package/dist/data-structures/stack/stack.d.ts +64 -0
- package/dist/data-structures/stack/stack.js +94 -0
- package/dist/data-structures/tree/index.d.ts +1 -0
- package/dist/data-structures/tree/index.js +17 -0
- package/dist/data-structures/tree/tree.d.ts +8 -0
- package/dist/data-structures/tree/tree.js +40 -0
- package/dist/data-structures/trie/index.d.ts +1 -0
- package/dist/data-structures/trie/index.js +17 -0
- package/dist/data-structures/trie/trie.d.ts +79 -0
- package/dist/data-structures/trie/trie.js +251 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +18 -4
- package/dist/interfaces/binary-tree.d.ts +7 -0
- package/dist/interfaces/binary-tree.js +2 -0
- package/dist/interfaces/doubly-linked-list.d.ts +1 -0
- package/dist/interfaces/doubly-linked-list.js +2 -0
- package/dist/interfaces/graph.d.ts +5 -0
- package/dist/interfaces/graph.js +2 -0
- package/dist/interfaces/heap.d.ts +1 -0
- package/dist/interfaces/heap.js +2 -0
- package/dist/interfaces/index.d.ts +8 -0
- package/dist/interfaces/index.js +24 -0
- package/dist/interfaces/navigator.d.ts +1 -0
- package/dist/interfaces/navigator.js +2 -0
- package/dist/interfaces/priority-queue.d.ts +1 -0
- package/dist/interfaces/priority-queue.js +2 -0
- package/dist/interfaces/segment-tree.d.ts +1 -0
- package/dist/interfaces/segment-tree.js +2 -0
- package/dist/interfaces/singly-linked-list.d.ts +1 -0
- package/dist/interfaces/singly-linked-list.js +2 -0
- package/dist/types/data-structures/binary-tree/avl-tree.d.ts +4 -0
- package/dist/types/data-structures/binary-tree/avl-tree.js +2 -0
- package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +1 -0
- package/dist/types/data-structures/binary-tree/binary-indexed-tree.js +2 -0
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +29 -0
- package/dist/types/data-structures/binary-tree/binary-tree.js +24 -0
- package/dist/types/data-structures/binary-tree/bst.d.ts +7 -0
- package/dist/types/data-structures/binary-tree/bst.js +2 -0
- package/dist/types/data-structures/binary-tree/index.d.ts +6 -0
- package/dist/types/data-structures/binary-tree/index.js +22 -0
- package/dist/types/data-structures/binary-tree/rb-tree.d.ts +8 -0
- package/dist/types/data-structures/binary-tree/rb-tree.js +8 -0
- package/dist/types/data-structures/binary-tree/segment-tree.d.ts +1 -0
- package/dist/types/data-structures/binary-tree/segment-tree.js +2 -0
- package/dist/types/data-structures/binary-tree/tree-multiset.d.ts +4 -0
- package/dist/types/data-structures/binary-tree/tree-multiset.js +2 -0
- package/dist/types/data-structures/graph/abstract-graph.d.ts +10 -0
- package/dist/types/data-structures/graph/abstract-graph.js +2 -0
- package/dist/types/data-structures/graph/directed-graph.d.ts +6 -0
- package/dist/types/data-structures/graph/directed-graph.js +9 -0
- package/dist/types/data-structures/graph/index.d.ts +3 -0
- package/dist/types/data-structures/graph/index.js +19 -0
- package/dist/types/data-structures/graph/map-graph.d.ts +1 -0
- package/dist/types/data-structures/graph/map-graph.js +2 -0
- package/dist/types/data-structures/graph/undirected-graph.d.ts +1 -0
- package/dist/types/data-structures/graph/undirected-graph.js +2 -0
- package/dist/types/data-structures/hash/coordinate-map.d.ts +1 -0
- package/dist/types/data-structures/hash/coordinate-map.js +2 -0
- package/dist/types/data-structures/hash/coordinate-set.d.ts +1 -0
- package/dist/types/data-structures/hash/coordinate-set.js +2 -0
- package/dist/types/data-structures/hash/hash-map.d.ts +1 -0
- package/dist/types/data-structures/hash/hash-map.js +2 -0
- package/dist/types/data-structures/hash/hash-table.d.ts +1 -0
- package/dist/types/data-structures/hash/hash-table.js +2 -0
- package/dist/types/data-structures/hash/index.d.ts +1 -0
- package/dist/types/data-structures/hash/index.js +2 -0
- package/dist/types/data-structures/hash/tree-map.d.ts +1 -0
- package/dist/types/data-structures/hash/tree-map.js +2 -0
- package/dist/types/data-structures/hash/tree-set.d.ts +1 -0
- package/dist/types/data-structures/hash/tree-set.js +2 -0
- package/dist/types/data-structures/heap/heap.d.ts +1 -0
- package/dist/types/data-structures/heap/heap.js +2 -0
- package/dist/types/data-structures/heap/index.d.ts +1 -0
- package/dist/types/data-structures/heap/index.js +17 -0
- package/dist/types/data-structures/heap/max-heap.d.ts +1 -0
- package/dist/types/data-structures/heap/max-heap.js +2 -0
- package/dist/types/data-structures/heap/min-heap.d.ts +1 -0
- package/dist/types/data-structures/heap/min-heap.js +2 -0
- package/dist/types/data-structures/index.d.ts +11 -0
- package/dist/types/data-structures/index.js +27 -0
- package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +1 -0
- package/dist/types/data-structures/linked-list/doubly-linked-list.js +2 -0
- package/dist/types/data-structures/linked-list/index.d.ts +2 -0
- package/dist/types/data-structures/linked-list/index.js +18 -0
- package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +1 -0
- package/dist/types/data-structures/linked-list/singly-linked-list.js +2 -0
- package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +1 -0
- package/dist/types/data-structures/linked-list/skip-linked-list.js +2 -0
- package/dist/types/data-structures/matrix/index.d.ts +1 -0
- package/dist/types/data-structures/matrix/index.js +17 -0
- package/dist/types/data-structures/matrix/matrix.d.ts +1 -0
- package/dist/types/data-structures/matrix/matrix.js +2 -0
- package/dist/types/data-structures/matrix/matrix2d.d.ts +1 -0
- package/dist/types/data-structures/matrix/matrix2d.js +2 -0
- package/dist/types/data-structures/matrix/navigator.d.ts +14 -0
- package/dist/types/data-structures/matrix/navigator.js +2 -0
- package/dist/types/data-structures/matrix/vector2d.d.ts +1 -0
- package/dist/types/data-structures/matrix/vector2d.js +2 -0
- package/dist/types/data-structures/priority-queue/index.d.ts +3 -0
- package/dist/types/data-structures/priority-queue/index.js +19 -0
- package/dist/types/data-structures/priority-queue/max-priority-queue.d.ts +1 -0
- package/dist/types/data-structures/priority-queue/max-priority-queue.js +2 -0
- package/dist/types/data-structures/priority-queue/min-priority-queue.d.ts +1 -0
- package/dist/types/data-structures/priority-queue/min-priority-queue.js +2 -0
- package/dist/types/data-structures/priority-queue/priority-queue.d.ts +1 -0
- package/dist/types/data-structures/priority-queue/priority-queue.js +2 -0
- package/dist/types/data-structures/queue/deque.d.ts +1 -0
- package/dist/types/data-structures/queue/deque.js +2 -0
- package/dist/types/data-structures/queue/index.d.ts +2 -0
- package/dist/types/data-structures/queue/index.js +18 -0
- package/dist/types/data-structures/queue/queue.d.ts +1 -0
- package/dist/types/data-structures/queue/queue.js +2 -0
- package/dist/types/data-structures/stack/index.d.ts +1 -0
- package/dist/types/data-structures/stack/index.js +17 -0
- package/dist/types/data-structures/stack/stack.d.ts +1 -0
- package/dist/types/data-structures/stack/stack.js +2 -0
- package/dist/types/data-structures/tree/index.d.ts +1 -0
- package/dist/types/data-structures/tree/index.js +17 -0
- package/dist/types/data-structures/tree/tree.d.ts +1 -0
- package/dist/types/data-structures/tree/tree.js +2 -0
- package/dist/types/data-structures/trie/index.d.ts +1 -0
- package/dist/types/data-structures/trie/index.js +17 -0
- package/dist/types/data-structures/trie/trie.d.ts +1 -0
- package/dist/types/data-structures/trie/trie.js +2 -0
- package/dist/types/helpers.d.ts +8 -0
- package/dist/types/helpers.js +9 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.js +19 -0
- package/dist/types/utils/index.d.ts +2 -0
- package/dist/types/utils/index.js +18 -0
- package/dist/types/utils/utils.d.ts +7 -0
- package/dist/types/utils/utils.js +2 -0
- package/dist/types/utils/validate-type.d.ts +19 -0
- package/dist/types/utils/validate-type.js +2 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +17 -0
- package/dist/utils/utils.d.ts +20 -0
- package/dist/utils/utils.js +73 -0
- package/package.json +2 -2
- package/src/data-structures/binary-tree/avl-tree.ts +350 -0
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +306 -0
- package/src/data-structures/binary-tree/binary-tree.ts +1262 -0
- package/src/data-structures/binary-tree/bst.ts +522 -0
- package/src/data-structures/binary-tree/index.ts +7 -0
- package/src/data-structures/binary-tree/rb-tree.ts +358 -0
- package/src/data-structures/binary-tree/segment-tree.ts +190 -0
- package/src/data-structures/binary-tree/tree-multiset.ts +379 -0
- package/src/data-structures/graph/abstract-graph.ts +1000 -0
- package/src/data-structures/graph/directed-graph.ts +449 -0
- package/src/data-structures/graph/index.ts +4 -0
- package/src/data-structures/graph/map-graph.ts +106 -0
- package/src/data-structures/graph/undirected-graph.ts +259 -0
- package/src/data-structures/hash/coordinate-map.ts +63 -0
- package/src/data-structures/hash/coordinate-set.ts +52 -0
- package/src/data-structures/hash/hash-map.ts +185 -0
- package/src/data-structures/hash/hash-table.ts +268 -0
- package/src/data-structures/hash/index.ts +6 -0
- package/src/data-structures/hash/tree-map.ts +2 -0
- package/src/data-structures/hash/tree-set.ts +2 -0
- package/src/data-structures/heap/heap.ts +589 -0
- package/src/data-structures/heap/index.ts +3 -0
- package/src/data-structures/heap/max-heap.ts +26 -0
- package/src/data-structures/heap/min-heap.ts +26 -0
- package/src/data-structures/index.ts +11 -0
- package/src/data-structures/linked-list/doubly-linked-list.ts +605 -0
- package/src/data-structures/linked-list/index.ts +3 -0
- package/src/data-structures/linked-list/singly-linked-list.ts +576 -0
- package/src/data-structures/linked-list/skip-linked-list.ts +221 -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 +211 -0
- package/src/data-structures/matrix/navigator.ts +121 -0
- package/src/data-structures/matrix/vector2d.ts +315 -0
- package/src/data-structures/priority-queue/index.ts +3 -0
- package/src/data-structures/priority-queue/max-priority-queue.ts +25 -0
- package/src/data-structures/priority-queue/min-priority-queue.ts +25 -0
- package/src/data-structures/priority-queue/priority-queue.ts +16 -0
- package/src/data-structures/queue/deque.ts +282 -0
- package/src/data-structures/queue/index.ts +2 -0
- package/src/data-structures/queue/queue.ts +209 -0
- package/src/data-structures/stack/index.ts +1 -0
- package/src/data-structures/stack/stack.ts +102 -0
- package/src/data-structures/tree/index.ts +1 -0
- package/src/data-structures/tree/tree.ts +41 -0
- package/src/data-structures/trie/index.ts +1 -0
- package/src/data-structures/trie/trie.ts +262 -0
- package/src/index.ts +4 -1
- package/src/interfaces/binary-tree.ts +10 -0
- package/src/interfaces/doubly-linked-list.ts +1 -0
- package/src/interfaces/graph.ts +7 -0
- package/src/interfaces/heap.ts +1 -0
- package/src/interfaces/index.ts +8 -0
- package/src/interfaces/navigator.ts +1 -0
- package/src/interfaces/priority-queue.ts +1 -0
- package/src/interfaces/segment-tree.ts +1 -0
- package/src/interfaces/singly-linked-list.ts +1 -0
- package/src/types/data-structures/binary-tree/avl-tree.ts +5 -0
- package/src/types/data-structures/binary-tree/binary-indexed-tree.ts +1 -0
- package/src/types/data-structures/binary-tree/binary-tree.ts +31 -0
- package/src/types/data-structures/binary-tree/bst.ts +11 -0
- package/src/types/data-structures/binary-tree/index.ts +6 -0
- package/src/types/data-structures/binary-tree/rb-tree.ts +8 -0
- package/src/types/data-structures/binary-tree/segment-tree.ts +1 -0
- package/src/types/data-structures/binary-tree/tree-multiset.ts +6 -0
- package/src/types/data-structures/graph/abstract-graph.ts +11 -0
- package/src/types/data-structures/graph/directed-graph.ts +8 -0
- package/src/types/data-structures/graph/index.ts +3 -0
- package/src/types/data-structures/graph/map-graph.ts +1 -0
- package/src/types/data-structures/graph/undirected-graph.ts +1 -0
- package/src/types/data-structures/hash/coordinate-map.ts +1 -0
- package/src/types/data-structures/hash/coordinate-set.ts +1 -0
- package/src/types/data-structures/hash/hash-map.ts +1 -0
- package/src/types/data-structures/hash/hash-table.ts +1 -0
- package/src/types/data-structures/hash/index.ts +1 -0
- package/src/types/data-structures/hash/tree-map.ts +1 -0
- package/src/types/data-structures/hash/tree-set.ts +1 -0
- package/src/types/data-structures/heap/heap.ts +1 -0
- package/src/types/data-structures/heap/index.ts +1 -0
- package/src/types/data-structures/heap/max-heap.ts +1 -0
- package/src/types/data-structures/heap/min-heap.ts +1 -0
- package/src/types/data-structures/index.ts +11 -0
- package/src/types/data-structures/linked-list/doubly-linked-list.ts +1 -0
- package/src/types/data-structures/linked-list/index.ts +2 -0
- package/src/types/data-structures/linked-list/singly-linked-list.ts +1 -0
- package/src/types/data-structures/linked-list/skip-linked-list.ts +1 -0
- package/src/types/data-structures/matrix/index.ts +1 -0
- package/src/types/data-structures/matrix/matrix.ts +1 -0
- package/src/types/data-structures/matrix/matrix2d.ts +1 -0
- package/src/types/data-structures/matrix/navigator.ts +14 -0
- package/src/types/data-structures/matrix/vector2d.ts +1 -0
- package/src/types/data-structures/priority-queue/index.ts +3 -0
- package/src/types/data-structures/priority-queue/max-priority-queue.ts +1 -0
- package/src/types/data-structures/priority-queue/min-priority-queue.ts +1 -0
- package/src/types/data-structures/priority-queue/priority-queue.ts +1 -0
- package/src/types/data-structures/queue/deque.ts +1 -0
- package/src/types/data-structures/queue/index.ts +2 -0
- package/src/types/data-structures/queue/queue.ts +1 -0
- package/src/types/data-structures/stack/index.ts +1 -0
- package/src/types/data-structures/stack/stack.ts +1 -0
- package/src/types/data-structures/tree/index.ts +1 -0
- package/src/types/data-structures/tree/tree.ts +1 -0
- package/src/types/data-structures/trie/index.ts +1 -0
- package/src/types/data-structures/trie/trie.ts +1 -0
- package/src/types/helpers.ts +11 -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 +86 -0
- package/test/index.test.ts +78 -78
- package/tsconfig.json +1 -2
|
@@ -1,196 +1,206 @@
|
|
|
1
1
|
/* eslint-disable */
|
|
2
|
-
var addSorting = (function() {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
var addSorting = (function () {
|
|
3
|
+
'use strict';
|
|
4
|
+
var cols,
|
|
5
|
+
currentSort = {
|
|
6
|
+
index: 0,
|
|
7
|
+
desc: false
|
|
8
|
+
};
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
10
|
+
// returns the summary table element
|
|
11
|
+
function getTable() {
|
|
12
|
+
return document.querySelector('.coverage-summary');
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// returns the thead element of the summary table
|
|
16
|
+
function getTableHeader() {
|
|
17
|
+
return getTable().querySelector('thead tr');
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// returns the tbody element of the summary table
|
|
21
|
+
function getTableBody() {
|
|
22
|
+
return getTable().querySelector('tbody');
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// returns the th element for nth column
|
|
26
|
+
function getNthColumn(n) {
|
|
27
|
+
return getTableHeader().querySelectorAll('th')[n];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function onFilterInput() {
|
|
31
|
+
const searchValue = document.getElementById('fileSearch').value;
|
|
32
|
+
const rows = document.getElementsByTagName('tbody')[0].children;
|
|
33
|
+
for (let i = 0; i < rows.length; i++) {
|
|
34
|
+
const row = rows[i];
|
|
35
|
+
if (
|
|
36
|
+
row.textContent
|
|
37
|
+
.toLowerCase()
|
|
38
|
+
.includes(searchValue.toLowerCase())
|
|
39
|
+
) {
|
|
40
|
+
row.style.display = '';
|
|
41
|
+
} else {
|
|
42
|
+
row.style.display = 'none';
|
|
43
|
+
}
|
|
21
44
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// loads the search box
|
|
48
|
+
function addSearchBox() {
|
|
49
|
+
var template = document.getElementById('filterTemplate');
|
|
50
|
+
var templateClone = template.content.cloneNode(true);
|
|
51
|
+
templateClone.getElementById('fileSearch').oninput = onFilterInput;
|
|
52
|
+
template.parentElement.appendChild(templateClone);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// loads all columns
|
|
56
|
+
function loadColumns() {
|
|
57
|
+
var colNodes = getTableHeader().querySelectorAll('th'),
|
|
58
|
+
colNode,
|
|
59
|
+
cols = [],
|
|
60
|
+
col,
|
|
61
|
+
i;
|
|
62
|
+
|
|
63
|
+
for (i = 0; i < colNodes.length; i += 1) {
|
|
64
|
+
colNode = colNodes[i];
|
|
65
|
+
col = {
|
|
66
|
+
key: colNode.getAttribute('data-col'),
|
|
67
|
+
sortable: !colNode.getAttribute('data-nosort'),
|
|
68
|
+
type: colNode.getAttribute('data-type') || 'string'
|
|
69
|
+
};
|
|
70
|
+
cols.push(col);
|
|
71
|
+
if (col.sortable) {
|
|
72
|
+
col.defaultDescSort = col.type === 'number';
|
|
73
|
+
colNode.innerHTML =
|
|
74
|
+
colNode.innerHTML + '<span class="sorter"></span>';
|
|
75
|
+
}
|
|
25
76
|
}
|
|
77
|
+
return cols;
|
|
78
|
+
}
|
|
26
79
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
80
|
+
// attaches a data attribute to every tr element with an object
|
|
81
|
+
// of data values keyed by column name
|
|
82
|
+
function loadRowData(tableRow) {
|
|
83
|
+
var tableCols = tableRow.querySelectorAll('td'),
|
|
84
|
+
colNode,
|
|
85
|
+
col,
|
|
86
|
+
data = {},
|
|
87
|
+
i,
|
|
88
|
+
val;
|
|
89
|
+
for (i = 0; i < tableCols.length; i += 1) {
|
|
90
|
+
colNode = tableCols[i];
|
|
91
|
+
col = cols[i];
|
|
92
|
+
val = colNode.getAttribute('data-value');
|
|
93
|
+
if (col.type === 'number') {
|
|
94
|
+
val = Number(val);
|
|
95
|
+
}
|
|
96
|
+
data[col.key] = val;
|
|
42
97
|
}
|
|
98
|
+
return data;
|
|
99
|
+
}
|
|
43
100
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
101
|
+
// loads all row data
|
|
102
|
+
function loadData() {
|
|
103
|
+
var rows = getTableBody().querySelectorAll('tr'),
|
|
104
|
+
i;
|
|
105
|
+
|
|
106
|
+
for (i = 0; i < rows.length; i += 1) {
|
|
107
|
+
rows[i].data = loadRowData(rows[i]);
|
|
50
108
|
}
|
|
109
|
+
}
|
|
51
110
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
colNode.innerHTML =
|
|
71
|
-
colNode.innerHTML + '<span class="sorter"></span>';
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
return cols;
|
|
111
|
+
// sorts the table using the data for the ith column
|
|
112
|
+
function sortByIndex(index, desc) {
|
|
113
|
+
var key = cols[index].key,
|
|
114
|
+
sorter = function (a, b) {
|
|
115
|
+
a = a.data[key];
|
|
116
|
+
b = b.data[key];
|
|
117
|
+
return a < b ? -1 : a > b ? 1 : 0;
|
|
118
|
+
},
|
|
119
|
+
finalSorter = sorter,
|
|
120
|
+
tableBody = document.querySelector('.coverage-summary tbody'),
|
|
121
|
+
rowNodes = tableBody.querySelectorAll('tr'),
|
|
122
|
+
rows = [],
|
|
123
|
+
i;
|
|
124
|
+
|
|
125
|
+
if (desc) {
|
|
126
|
+
finalSorter = function (a, b) {
|
|
127
|
+
return -1 * sorter(a, b);
|
|
128
|
+
};
|
|
75
129
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
colNode,
|
|
81
|
-
col,
|
|
82
|
-
data = {},
|
|
83
|
-
i,
|
|
84
|
-
val;
|
|
85
|
-
for (i = 0; i < tableCols.length; i += 1) {
|
|
86
|
-
colNode = tableCols[i];
|
|
87
|
-
col = cols[i];
|
|
88
|
-
val = colNode.getAttribute('data-value');
|
|
89
|
-
if (col.type === 'number') {
|
|
90
|
-
val = Number(val);
|
|
91
|
-
}
|
|
92
|
-
data[col.key] = val;
|
|
93
|
-
}
|
|
94
|
-
return data;
|
|
130
|
+
|
|
131
|
+
for (i = 0; i < rowNodes.length; i += 1) {
|
|
132
|
+
rows.push(rowNodes[i]);
|
|
133
|
+
tableBody.removeChild(rowNodes[i]);
|
|
95
134
|
}
|
|
96
|
-
// loads all row data
|
|
97
|
-
function loadData() {
|
|
98
|
-
var rows = getTableBody().querySelectorAll('tr'),
|
|
99
|
-
i;
|
|
100
135
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
136
|
+
rows.sort(finalSorter);
|
|
137
|
+
|
|
138
|
+
for (i = 0; i < rows.length; i += 1) {
|
|
139
|
+
tableBody.appendChild(rows[i]);
|
|
104
140
|
}
|
|
105
|
-
|
|
106
|
-
function sortByIndex(index, desc) {
|
|
107
|
-
var key = cols[index].key,
|
|
108
|
-
sorter = function(a, b) {
|
|
109
|
-
a = a.data[key];
|
|
110
|
-
b = b.data[key];
|
|
111
|
-
return a < b ? -1 : a > b ? 1 : 0;
|
|
112
|
-
},
|
|
113
|
-
finalSorter = sorter,
|
|
114
|
-
tableBody = document.querySelector('.coverage-summary tbody'),
|
|
115
|
-
rowNodes = tableBody.querySelectorAll('tr'),
|
|
116
|
-
rows = [],
|
|
117
|
-
i;
|
|
118
|
-
|
|
119
|
-
if (desc) {
|
|
120
|
-
finalSorter = function(a, b) {
|
|
121
|
-
return -1 * sorter(a, b);
|
|
122
|
-
};
|
|
123
|
-
}
|
|
141
|
+
}
|
|
124
142
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
143
|
+
// removes sort indicators for current column being sorted
|
|
144
|
+
function removeSortIndicators() {
|
|
145
|
+
var col = getNthColumn(currentSort.index),
|
|
146
|
+
cls = col.className;
|
|
147
|
+
|
|
148
|
+
cls = cls.replace(/ sorted$/, '').replace(/ sorted-desc$/, '');
|
|
149
|
+
col.className = cls;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// adds sort indicators for current column being sorted
|
|
153
|
+
function addSortIndicators() {
|
|
154
|
+
getNthColumn(currentSort.index).className += currentSort.desc
|
|
155
|
+
? ' sorted-desc'
|
|
156
|
+
: ' sorted';
|
|
157
|
+
}
|
|
129
158
|
|
|
130
|
-
|
|
159
|
+
// adds event listeners for all sorter widgets
|
|
160
|
+
function enableUI() {
|
|
161
|
+
var i,
|
|
162
|
+
el,
|
|
163
|
+
ithSorter = function ithSorter(i) {
|
|
164
|
+
var col = cols[i];
|
|
131
165
|
|
|
132
|
-
|
|
133
|
-
|
|
166
|
+
return function () {
|
|
167
|
+
var desc = col.defaultDescSort;
|
|
168
|
+
|
|
169
|
+
if (currentSort.index === i) {
|
|
170
|
+
desc = !currentSort.desc;
|
|
171
|
+
}
|
|
172
|
+
sortByIndex(i, desc);
|
|
173
|
+
removeSortIndicators();
|
|
174
|
+
currentSort.index = i;
|
|
175
|
+
currentSort.desc = desc;
|
|
176
|
+
addSortIndicators();
|
|
177
|
+
};
|
|
178
|
+
};
|
|
179
|
+
for (i = 0; i < cols.length; i += 1) {
|
|
180
|
+
if (cols[i].sortable) {
|
|
181
|
+
// add the click event handler on the th so users
|
|
182
|
+
// dont have to click on those tiny arrows
|
|
183
|
+
el = getNthColumn(i).querySelector('.sorter').parentElement;
|
|
184
|
+
if (el.addEventListener) {
|
|
185
|
+
el.addEventListener('click', ithSorter(i));
|
|
186
|
+
} else {
|
|
187
|
+
el.attachEvent('onclick', ithSorter(i));
|
|
134
188
|
}
|
|
189
|
+
}
|
|
135
190
|
}
|
|
136
|
-
|
|
137
|
-
function removeSortIndicators() {
|
|
138
|
-
var col = getNthColumn(currentSort.index),
|
|
139
|
-
cls = col.className;
|
|
191
|
+
}
|
|
140
192
|
|
|
141
|
-
|
|
142
|
-
|
|
193
|
+
// adds sorting functionality to the UI
|
|
194
|
+
return function () {
|
|
195
|
+
if (!getTable()) {
|
|
196
|
+
return;
|
|
143
197
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
// adds event listeners for all sorter widgets
|
|
151
|
-
function enableUI() {
|
|
152
|
-
var i,
|
|
153
|
-
el,
|
|
154
|
-
ithSorter = function ithSorter(i) {
|
|
155
|
-
var col = cols[i];
|
|
156
|
-
|
|
157
|
-
return function() {
|
|
158
|
-
var desc = col.defaultDescSort;
|
|
159
|
-
|
|
160
|
-
if (currentSort.index === i) {
|
|
161
|
-
desc = !currentSort.desc;
|
|
162
|
-
}
|
|
163
|
-
sortByIndex(i, desc);
|
|
164
|
-
removeSortIndicators();
|
|
165
|
-
currentSort.index = i;
|
|
166
|
-
currentSort.desc = desc;
|
|
167
|
-
addSortIndicators();
|
|
168
|
-
};
|
|
169
|
-
};
|
|
170
|
-
for (i = 0; i < cols.length; i += 1) {
|
|
171
|
-
if (cols[i].sortable) {
|
|
172
|
-
// add the click event handler on the th so users
|
|
173
|
-
// dont have to click on those tiny arrows
|
|
174
|
-
el = getNthColumn(i).querySelector('.sorter').parentElement;
|
|
175
|
-
if (el.addEventListener) {
|
|
176
|
-
el.addEventListener('click', ithSorter(i));
|
|
177
|
-
} else {
|
|
178
|
-
el.attachEvent('onclick', ithSorter(i));
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
// adds sorting functionality to the UI
|
|
184
|
-
return function() {
|
|
185
|
-
if (!getTable()) {
|
|
186
|
-
return;
|
|
187
|
-
}
|
|
188
|
-
cols = loadColumns();
|
|
189
|
-
loadData();
|
|
190
|
-
addSearchBox();
|
|
191
|
-
addSortIndicators();
|
|
192
|
-
enableUI();
|
|
193
|
-
};
|
|
198
|
+
cols = loadColumns();
|
|
199
|
+
loadData();
|
|
200
|
+
addSearchBox();
|
|
201
|
+
addSortIndicators();
|
|
202
|
+
enableUI();
|
|
203
|
+
};
|
|
194
204
|
})();
|
|
195
205
|
|
|
196
206
|
window.addEventListener('load', addSorting);
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* data-structure-typed
|
|
3
|
+
*
|
|
4
|
+
* @author Tyler Zeng
|
|
5
|
+
* @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
|
|
6
|
+
* @license MIT License
|
|
7
|
+
*/
|
|
8
|
+
import { BST, BSTNode } from './bst';
|
|
9
|
+
import type { AVLTreeNodeNested, AVLTreeOptions, BinaryTreeDeletedResult, BTNKey } from '../../types';
|
|
10
|
+
import { BTNCallback } from '../../types';
|
|
11
|
+
import { IBinaryTree } from '../../interfaces';
|
|
12
|
+
export declare class AVLTreeNode<V = any, N extends AVLTreeNode<V, N> = AVLTreeNodeNested<V>> extends BSTNode<V, N> {
|
|
13
|
+
height: number;
|
|
14
|
+
constructor(key: BTNKey, value?: V);
|
|
15
|
+
}
|
|
16
|
+
export declare class AVLTree<V = any, N extends AVLTreeNode<V, N> = AVLTreeNode<V, AVLTreeNodeNested<V>>> extends BST<V, N> implements IBinaryTree<V, N> {
|
|
17
|
+
/**
|
|
18
|
+
* This is a constructor function for an AVL tree data structure in TypeScript.
|
|
19
|
+
* @param {AVLTreeOptions} [options] - The `options` parameter is an optional object that can be passed to the
|
|
20
|
+
* constructor of the AVLTree class. It allows you to customize the behavior of the AVL tree by providing different
|
|
21
|
+
* options.
|
|
22
|
+
*/
|
|
23
|
+
constructor(options?: AVLTreeOptions);
|
|
24
|
+
/**
|
|
25
|
+
* The function creates a new AVL tree node with the specified key and value.
|
|
26
|
+
* @param {BTNKey} key - The key parameter is the key value that will be associated with
|
|
27
|
+
* the new node. It is used to determine the position of the node in the binary search tree.
|
|
28
|
+
* @param [value] - The parameter `value` is an optional value that can be assigned to the node. It is of
|
|
29
|
+
* type `V`, which means it can be any value that is assignable to the `value` property of the
|
|
30
|
+
* node type `N`.
|
|
31
|
+
* @returns a new AVLTreeNode object with the specified key and value.
|
|
32
|
+
*/
|
|
33
|
+
createNode(key: BTNKey, value?: V): N;
|
|
34
|
+
/**
|
|
35
|
+
* The function overrides the add method of a binary tree node and balances the tree after inserting
|
|
36
|
+
* a new node.
|
|
37
|
+
* @param {BTNKey | N | null} keyOrNode - The `keyOrNode` parameter can accept either a
|
|
38
|
+
* `BTNKey` or a `N` (which represents a node in the binary tree) or `null`.
|
|
39
|
+
* @param [value] - The `value` parameter is the value that you want to assign to the new node that you
|
|
40
|
+
* are adding to the binary search tree.
|
|
41
|
+
* @returns The method is returning the inserted node (`N`), `null`, or `undefined`.
|
|
42
|
+
*/
|
|
43
|
+
add(keyOrNode: BTNKey | N | null, value?: V): N | null | undefined;
|
|
44
|
+
/**
|
|
45
|
+
* The function overrides the delete method of a binary tree and balances the tree after deleting a
|
|
46
|
+
* node if necessary.
|
|
47
|
+
* @param {ReturnType<C>} identifier - The `identifier` parameter is either a
|
|
48
|
+
* `BTNKey` or a generic type `N`. It represents the property of the node that we are
|
|
49
|
+
* searching for. It can be a specific key value or any other property of the node.
|
|
50
|
+
* @param callback - The `callback` parameter is a function that takes a node as input and returns a
|
|
51
|
+
* value. This value is compared with the `identifier` parameter to determine if the node should be
|
|
52
|
+
* included in the result. The `callback` parameter has a default value of
|
|
53
|
+
* `((node: N) => node.key)`
|
|
54
|
+
* @returns The method is returning an array of `BinaryTreeDeletedResult<N>` objects.
|
|
55
|
+
*/
|
|
56
|
+
delete<C extends BTNCallback<N>>(identifier: ReturnType<C>, callback?: C): BinaryTreeDeletedResult<N>[];
|
|
57
|
+
/**
|
|
58
|
+
* The function swaps the key, value, and height properties between two nodes in a binary tree.
|
|
59
|
+
* @param {N} srcNode - The `srcNode` parameter represents the source node that needs to be swapped
|
|
60
|
+
* with the `destNode`.
|
|
61
|
+
* @param {N} destNode - The `destNode` parameter represents the destination node where the values
|
|
62
|
+
* from the source node (`srcNode`) will be swapped to.
|
|
63
|
+
* @returns The method is returning the `destNode` after swapping its properties with the `srcNode`.
|
|
64
|
+
*/
|
|
65
|
+
protected _swap(srcNode: N, destNode: N): N;
|
|
66
|
+
/**
|
|
67
|
+
* The function calculates the balance factor of a node in a binary tree.
|
|
68
|
+
* @param {N} node - The parameter "node" represents a node in a binary tree data structure.
|
|
69
|
+
* @returns the balance factor of a given node. The balance factor is calculated by subtracting the
|
|
70
|
+
* height of the left subtree from the height of the right subtree.
|
|
71
|
+
*/
|
|
72
|
+
protected _balanceFactor(node: N): number;
|
|
73
|
+
/**
|
|
74
|
+
* The function updates the height of a node in a binary tree based on the heights of its left and
|
|
75
|
+
* right children.
|
|
76
|
+
* @param {N} node - The parameter "node" represents a node in a binary tree data structure.
|
|
77
|
+
*/
|
|
78
|
+
protected _updateHeight(node: N): void;
|
|
79
|
+
/**
|
|
80
|
+
* The `_balancePath` function is used to update the heights of nodes and perform rotation operations
|
|
81
|
+
* to restore balance in an AVL tree after inserting a node.
|
|
82
|
+
* @param {N} node - The `node` parameter in the `_balancePath` function represents the node in the
|
|
83
|
+
* AVL tree that needs to be balanced.
|
|
84
|
+
*/
|
|
85
|
+
protected _balancePath(node: N): void;
|
|
86
|
+
/**
|
|
87
|
+
* The function `_balanceLL` performs a left-left rotation to balance a binary tree.
|
|
88
|
+
* @param {N} A - A is a node in a binary tree.
|
|
89
|
+
*/
|
|
90
|
+
protected _balanceLL(A: N): void;
|
|
91
|
+
/**
|
|
92
|
+
* The `_balanceLR` function performs a left-right rotation to balance a binary tree.
|
|
93
|
+
* @param {N} A - A is a node in a binary tree.
|
|
94
|
+
*/
|
|
95
|
+
protected _balanceLR(A: N): void;
|
|
96
|
+
/**
|
|
97
|
+
* The function `_balanceRR` performs a right-right rotation to balance a binary tree.
|
|
98
|
+
* @param {N} A - A is a node in a binary tree.
|
|
99
|
+
*/
|
|
100
|
+
protected _balanceRR(A: N): void;
|
|
101
|
+
/**
|
|
102
|
+
* The function `_balanceRL` performs a right-left rotation to balance a binary tree.
|
|
103
|
+
* @param {N} A - A is a node in a binary tree.
|
|
104
|
+
*/
|
|
105
|
+
protected _balanceRL(A: N): void;
|
|
106
|
+
}
|