min-heap-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/.dependency-cruiser.js +422 -422
- package/.eslintrc.js +59 -59
- package/.prettierrc.js +14 -14
- package/README.md +20 -3
- package/coverage/clover.xml +11 -7
- package/coverage/coverage-final.json +95 -1
- package/coverage/coverage-summary.json +59 -2
- package/coverage/lcov-report/base.css +278 -99
- package/coverage/lcov-report/index.html +69 -65
- package/coverage/lcov-report/index.ts.html +36 -35
- package/coverage/lcov-report/sorter.js +15 -5
- 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/jest.config.js +6 -6
- 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/tsconfig.json +1 -2
|
@@ -0,0 +1,232 @@
|
|
|
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
|
+
export declare class SinglyLinkedListNode<E = any> {
|
|
9
|
+
value: E;
|
|
10
|
+
next: SinglyLinkedListNode<E> | null;
|
|
11
|
+
/**
|
|
12
|
+
* The constructor function initializes an instance of a class with a given value and sets the next property to null.
|
|
13
|
+
* @param {E} value - The "value" parameter is of type E, which means it can be any data type. It represents the value that
|
|
14
|
+
* will be stored in the node of a linked list.
|
|
15
|
+
*/
|
|
16
|
+
constructor(value: E);
|
|
17
|
+
}
|
|
18
|
+
export declare class SinglyLinkedList<E = any> {
|
|
19
|
+
/**
|
|
20
|
+
* The constructor initializes the linked list with an empty head, tail, and length.
|
|
21
|
+
*/
|
|
22
|
+
constructor();
|
|
23
|
+
protected _head: SinglyLinkedListNode<E> | null;
|
|
24
|
+
get head(): SinglyLinkedListNode<E> | null;
|
|
25
|
+
protected _tail: SinglyLinkedListNode<E> | null;
|
|
26
|
+
get tail(): SinglyLinkedListNode<E> | null;
|
|
27
|
+
protected _length: number;
|
|
28
|
+
get length(): number;
|
|
29
|
+
/**
|
|
30
|
+
* The `fromArray` function creates a new SinglyLinkedList instance and populates it with the elements from the given
|
|
31
|
+
* array.
|
|
32
|
+
* @param {E[]} data - The `data` parameter is an array of elements of type `E`.
|
|
33
|
+
* @returns The `fromArray` function returns a `SinglyLinkedList` object.
|
|
34
|
+
*/
|
|
35
|
+
static fromArray<E>(data: E[]): SinglyLinkedList<E>;
|
|
36
|
+
/**
|
|
37
|
+
* The `push` function adds a new node with the given value to the end of a singly linked list.
|
|
38
|
+
* @param {E} value - The "value" parameter represents the value that you want to add to the linked list. It can be of
|
|
39
|
+
* any type (E) as specified in the generic type declaration of the class or function.
|
|
40
|
+
*/
|
|
41
|
+
push(value: E): void;
|
|
42
|
+
/**
|
|
43
|
+
* The `push` function adds a new node with the given value to the end of a singly linked list.
|
|
44
|
+
* @param {E} value - The "value" parameter represents the value that you want to add to the linked list. It can be of
|
|
45
|
+
* any type (E) as specified in the generic type declaration of the class or function.
|
|
46
|
+
*/
|
|
47
|
+
addLast(value: E): void;
|
|
48
|
+
/**
|
|
49
|
+
* The `pop()` function removes and returns the value of the last element in a linked list, updating the head and tail
|
|
50
|
+
* pointers accordingly.
|
|
51
|
+
* @returns The method `pop()` returns the value of the node that is being removed from the end of the linked list. If
|
|
52
|
+
* the linked list is empty, it returns `null`.
|
|
53
|
+
*/
|
|
54
|
+
pop(): E | undefined;
|
|
55
|
+
/**
|
|
56
|
+
* The `popLast()` function removes and returns the value of the last element in a linked list, updating the head and tail
|
|
57
|
+
* pointers accordingly.
|
|
58
|
+
* @returns The method `pop()` returns the value of the node that is being removed from the end of the linked list. If
|
|
59
|
+
* the linked list is empty, it returns `null`.
|
|
60
|
+
*/
|
|
61
|
+
popLast(): E | undefined;
|
|
62
|
+
/**
|
|
63
|
+
* The `shift()` function removes and returns the value of the first node in a linked list.
|
|
64
|
+
* @returns The value of the node that is being removed from the beginning of the linked list.
|
|
65
|
+
*/
|
|
66
|
+
shift(): E | undefined;
|
|
67
|
+
/**
|
|
68
|
+
* The `popFirst()` function removes and returns the value of the first node in a linked list.
|
|
69
|
+
* @returns The value of the node that is being removed from the beginning of the linked list.
|
|
70
|
+
*/
|
|
71
|
+
popFirst(): E | undefined;
|
|
72
|
+
/**
|
|
73
|
+
* The unshift function adds a new node with the given value to the beginning of a singly linked list.
|
|
74
|
+
* @param {E} value - The parameter "value" represents the value of the new node that will be added to the beginning of the
|
|
75
|
+
* linked list.
|
|
76
|
+
*/
|
|
77
|
+
unshift(value: E): void;
|
|
78
|
+
/**
|
|
79
|
+
* The addFirst function adds a new node with the given value to the beginning of a singly linked list.
|
|
80
|
+
* @param {E} value - The parameter "value" represents the value of the new node that will be added to the beginning of the
|
|
81
|
+
* linked list.
|
|
82
|
+
*/
|
|
83
|
+
addFirst(value: E): void;
|
|
84
|
+
/**
|
|
85
|
+
* The function `getAt` returns the value at a specified index in a linked list, or null if the index is out of range.
|
|
86
|
+
* @param {number} index - The index parameter is a number that represents the position of the element we want to
|
|
87
|
+
* retrieve from the list.
|
|
88
|
+
* @returns The method `getAt(index: number): E | null` returns the value at the specified index in the linked list, or
|
|
89
|
+
* `null` if the index is out of bounds.
|
|
90
|
+
*/
|
|
91
|
+
getAt(index: number): E | undefined;
|
|
92
|
+
/**
|
|
93
|
+
* The function `getNodeAt` returns the node at a given index in a singly linked list.
|
|
94
|
+
* @param {number} index - The `index` parameter is a number that represents the position of the node we want to
|
|
95
|
+
* retrieve from the linked list. It indicates the zero-based index of the node we want to access.
|
|
96
|
+
* @returns The method `getNodeAt(index: number)` returns a `SinglyLinkedListNode<E>` object if the node at the
|
|
97
|
+
* specified index exists, or `null` if the index is out of bounds.
|
|
98
|
+
*/
|
|
99
|
+
getNodeAt(index: number): SinglyLinkedListNode<E> | null;
|
|
100
|
+
/**
|
|
101
|
+
* The `deleteAt` function removes an element at a specified index from a linked list and returns the removed element.
|
|
102
|
+
* @param {number} index - The index parameter represents the position of the element that needs to be deleted in the
|
|
103
|
+
* data structure. It is of type number.
|
|
104
|
+
* @returns The method `deleteAt` returns the value of the node that was deleted, or `null` if the index is out of
|
|
105
|
+
* bounds.
|
|
106
|
+
*/
|
|
107
|
+
deleteAt(index: number): E | undefined;
|
|
108
|
+
/**
|
|
109
|
+
* The delete function removes a node with a specific value from a singly linked list.
|
|
110
|
+
* @param {E | SinglyLinkedListNode<E>} valueOrNode - The `valueOrNode` parameter can accept either a value of type `E`
|
|
111
|
+
* or a `SinglyLinkedListNode<E>` object.
|
|
112
|
+
* @returns The `delete` method returns a boolean value. It returns `true` if the value or node is found and
|
|
113
|
+
* successfully deleted from the linked list, and `false` if the value or node is not found in the linked list.
|
|
114
|
+
*/
|
|
115
|
+
delete(valueOrNode: E | SinglyLinkedListNode<E> | null | undefined): boolean;
|
|
116
|
+
/**
|
|
117
|
+
* The `insertAt` function inserts a value at a specified index in a singly linked list.
|
|
118
|
+
* @param {number} index - The index parameter represents the position at which the new value should be inserted in the
|
|
119
|
+
* linked list. It is of type number.
|
|
120
|
+
* @param {E} value - The `value` parameter represents the value that you want to insert into the linked list at the
|
|
121
|
+
* specified index.
|
|
122
|
+
* @returns The `insert` method returns a boolean value. It returns `true` if the insertion is successful, and `false`
|
|
123
|
+
* if the index is out of bounds.
|
|
124
|
+
*/
|
|
125
|
+
insertAt(index: number, value: E): boolean;
|
|
126
|
+
/**
|
|
127
|
+
* The function checks if the length of a data structure is equal to zero and returns a boolean value indicating
|
|
128
|
+
* whether it is empty or not.
|
|
129
|
+
* @returns A boolean value indicating whether the length of the object is equal to 0.
|
|
130
|
+
*/
|
|
131
|
+
isEmpty(): boolean;
|
|
132
|
+
/**
|
|
133
|
+
* The `clear` function resets the linked list by setting the head, tail, and length to null and 0 respectively.
|
|
134
|
+
*/
|
|
135
|
+
clear(): void;
|
|
136
|
+
/**
|
|
137
|
+
* The `toArray` function converts a linked list into an array.
|
|
138
|
+
* @returns The `toArray()` method is returning an array of type `E[]`.
|
|
139
|
+
*/
|
|
140
|
+
toArray(): E[];
|
|
141
|
+
/**
|
|
142
|
+
* The `reverse` function reverses the order of the nodes in a singly linked list.
|
|
143
|
+
* @returns The reverse() method does not return anything. It has a return type of void.
|
|
144
|
+
*/
|
|
145
|
+
reverse(): void;
|
|
146
|
+
/**
|
|
147
|
+
* The `find` function iterates through a linked list and returns the first element that satisfies a given condition.
|
|
148
|
+
* @param callback - A function that takes a value of type E as its parameter and returns a boolean value. This
|
|
149
|
+
* function is used to determine whether a particular value in the linked list satisfies a certain condition.
|
|
150
|
+
* @returns The method `find` returns the first element in the linked list that satisfies the condition specified by
|
|
151
|
+
* the callback function. If no element satisfies the condition, it returns `null`.
|
|
152
|
+
*/
|
|
153
|
+
find(callback: (value: E) => boolean): E | null;
|
|
154
|
+
/**
|
|
155
|
+
* The `indexOf` function returns the index of the first occurrence of a given value in a linked list.
|
|
156
|
+
* @param {E} value - The value parameter is the value that you want to find the index of in the linked list.
|
|
157
|
+
* @returns The method is returning the index of the first occurrence of the specified value in the linked list. If the
|
|
158
|
+
* value is not found, it returns -1.
|
|
159
|
+
*/
|
|
160
|
+
indexOf(value: E): number;
|
|
161
|
+
/**
|
|
162
|
+
* The function finds a node in a singly linked list by its value and returns the node if found, otherwise returns
|
|
163
|
+
* null.
|
|
164
|
+
* @param {E} value - The value parameter is the value that we want to search for in the linked list.
|
|
165
|
+
* @returns a `SinglyLinkedListNode<E>` if a node with the specified value is found in the linked list. If no node with
|
|
166
|
+
* the specified value is found, the function returns `null`.
|
|
167
|
+
*/
|
|
168
|
+
getNode(value: E): SinglyLinkedListNode<E> | null;
|
|
169
|
+
/**
|
|
170
|
+
* The `insertBefore` function inserts a new value before an existing value in a singly linked list.
|
|
171
|
+
* @param {E | SinglyLinkedListNode<E>} existingValueOrNode - The existing value or node that you want to insert the
|
|
172
|
+
* new value before. It can be either the value itself or a node containing the value in the linked list.
|
|
173
|
+
* @param {E} newValue - The `newValue` parameter represents the value that you want to insert into the linked list.
|
|
174
|
+
* @returns The method `insertBefore` returns a boolean value. It returns `true` if the new value was successfully
|
|
175
|
+
* inserted before the existing value, and `false` otherwise.
|
|
176
|
+
*/
|
|
177
|
+
insertBefore(existingValueOrNode: E | SinglyLinkedListNode<E>, newValue: E): boolean;
|
|
178
|
+
/**
|
|
179
|
+
* The `insertAfter` function inserts a new node with a given value after an existing node in a singly linked list.
|
|
180
|
+
* @param {E | SinglyLinkedListNode<E>} existingValueOrNode - The existing value or node in the linked list after which
|
|
181
|
+
* the new value will be inserted. It can be either the value of the existing node or the existing node itself.
|
|
182
|
+
* @param {E} newValue - The value that you want to insert into the linked list after the existing value or node.
|
|
183
|
+
* @returns The method returns a boolean value. It returns true if the new value was successfully inserted after the
|
|
184
|
+
* existing value or node, and false if the existing value or node was not found in the linked list.
|
|
185
|
+
*/
|
|
186
|
+
insertAfter(existingValueOrNode: E | SinglyLinkedListNode<E>, newValue: E): boolean;
|
|
187
|
+
/**
|
|
188
|
+
* The function counts the number of occurrences of a given value in a linked list.
|
|
189
|
+
* @param {E} value - The value parameter is the value that you want to count the occurrences of in the linked list.
|
|
190
|
+
* @returns The count of occurrences of the given value in the linked list.
|
|
191
|
+
*/
|
|
192
|
+
countOccurrences(value: E): number;
|
|
193
|
+
/**
|
|
194
|
+
* The `forEach` function iterates over each element in a linked list and applies a callback function to each element.
|
|
195
|
+
* @param callback - The callback parameter is a function that takes two arguments: value and index. The value argument
|
|
196
|
+
* represents the value of the current node in the linked list, and the index argument represents the index of the
|
|
197
|
+
* current node in the linked list.
|
|
198
|
+
*/
|
|
199
|
+
forEach(callback: (value: E, index: number) => void): void;
|
|
200
|
+
/**
|
|
201
|
+
* The `map` function takes a callback function and applies it to each element in the SinglyLinkedList, returning a new
|
|
202
|
+
* SinglyLinkedList with the transformed values.
|
|
203
|
+
* @param callback - The callback parameter is a function that takes a value of type E (the type of values stored in
|
|
204
|
+
* the original SinglyLinkedList) and returns a value of type U (the type of values that will be stored in the mapped
|
|
205
|
+
* SinglyLinkedList).
|
|
206
|
+
* @returns The `map` function is returning a new instance of `SinglyLinkedList<U>` that contains the mapped values.
|
|
207
|
+
*/
|
|
208
|
+
map<U>(callback: (value: E) => U): SinglyLinkedList<U>;
|
|
209
|
+
/**
|
|
210
|
+
* The `filter` function iterates through a SinglyLinkedList and returns a new SinglyLinkedList containing only the
|
|
211
|
+
* elements that satisfy the given callback function.
|
|
212
|
+
* @param callback - The `callback` parameter is a function that takes a value of type `E` and returns a boolean value.
|
|
213
|
+
* It is used to determine whether a value should be included in the filtered list or not.
|
|
214
|
+
* @returns The filtered list, which is an instance of the SinglyLinkedList class.
|
|
215
|
+
*/
|
|
216
|
+
filter(callback: (value: E) => boolean): SinglyLinkedList<E>;
|
|
217
|
+
/**
|
|
218
|
+
* The `reduce` function iterates over a linked list and applies a callback function to each element, accumulating a
|
|
219
|
+
* single value.
|
|
220
|
+
* @param callback - The `callback` parameter is a function that takes two arguments: `accumulator` and `value`. It is
|
|
221
|
+
* used to perform a specific operation on each element of the linked list.
|
|
222
|
+
* @param {U} initialValue - The `initialValue` parameter is the initial value of the accumulator. It is the starting
|
|
223
|
+
* point for the reduction operation.
|
|
224
|
+
* @returns The `reduce` method is returning the final value of the accumulator after iterating through all the
|
|
225
|
+
* elements in the linked list.
|
|
226
|
+
*/
|
|
227
|
+
reduce<U>(callback: (accumulator: U, value: E) => U, initialValue: U): U;
|
|
228
|
+
/**
|
|
229
|
+
* The function returns an iterator that iterates over the values of a linked list.
|
|
230
|
+
*/
|
|
231
|
+
[Symbol.iterator](): Generator<E, void, unknown>;
|
|
232
|
+
}
|