data-structure-typed 1.15.2 → 1.17.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 +24 -24
- package/dist/data-structures/heap/heap.d.ts +30 -15
- package/dist/data-structures/heap/heap.js +60 -15
- package/dist/data-structures/heap/max-heap.d.ts +3 -3
- package/dist/data-structures/heap/min-heap.d.ts +3 -3
- package/dist/data-structures/index.d.ts +1 -0
- package/dist/data-structures/index.js +1 -0
- package/dist/data-structures/linked-list/doubly-linked-list.d.ts +195 -68
- package/dist/data-structures/linked-list/doubly-linked-list.js +456 -244
- package/dist/data-structures/linked-list/singly-linked-list.d.ts +126 -241
- package/dist/data-structures/linked-list/singly-linked-list.js +331 -628
- package/dist/data-structures/priority-queue/max-priority-queue.d.ts +4 -5
- package/dist/data-structures/priority-queue/max-priority-queue.js +30 -6
- package/dist/data-structures/priority-queue/min-priority-queue.d.ts +4 -5
- package/dist/data-structures/priority-queue/min-priority-queue.js +31 -6
- package/dist/data-structures/priority-queue/priority-queue.d.ts +13 -2
- package/dist/data-structures/priority-queue/priority-queue.js +28 -22
- 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 +9 -0
- package/dist/data-structures/tree/tree.js +52 -0
- package/dist/data-structures/types/binary-tree.d.ts +0 -5
- package/dist/data-structures/types/heap.d.ts +0 -4
- package/dist/utils/types/utils.d.ts +1 -0
- package/docs/.nojekyll +1 -0
- package/docs/assets/highlight.css +92 -0
- package/docs/assets/main.js +58 -0
- package/docs/assets/search.js +1 -0
- package/docs/assets/style.css +1367 -0
- package/docs/classes/AVLTree.html +2191 -0
- package/docs/classes/AVLTreeNode.html +573 -0
- package/docs/classes/AaTree.html +149 -0
- package/docs/classes/AbstractEdge.html +268 -0
- package/docs/classes/AbstractGraph.html +926 -0
- package/docs/classes/AbstractVertex.html +214 -0
- package/docs/classes/ArrayDeque.html +416 -0
- package/docs/classes/BST.html +2037 -0
- package/docs/classes/BSTNode.html +569 -0
- package/docs/classes/BTree.html +149 -0
- package/docs/classes/BinaryIndexedTree.html +288 -0
- package/docs/classes/BinaryTree.html +1826 -0
- package/docs/classes/BinaryTreeNode.html +532 -0
- package/docs/classes/Character.html +197 -0
- package/docs/classes/CoordinateMap.html +468 -0
- package/docs/classes/CoordinateSet.html +429 -0
- package/docs/classes/Deque.html +897 -0
- package/docs/classes/DirectedEdge.html +353 -0
- package/docs/classes/DirectedGraph.html +1242 -0
- package/docs/classes/DirectedVertex.html +225 -0
- package/docs/classes/DoublyLinkedList.html +891 -0
- package/docs/classes/DoublyLinkedListNode.html +274 -0
- package/docs/classes/Heap.html +481 -0
- package/docs/classes/HeapItem.html +232 -0
- package/docs/classes/Matrix2D.html +479 -0
- package/docs/classes/MatrixNTI2D.html +217 -0
- package/docs/classes/MaxHeap.html +499 -0
- package/docs/classes/MaxPriorityQueue.html +808 -0
- package/docs/classes/MinHeap.html +500 -0
- package/docs/classes/MinPriorityQueue.html +810 -0
- package/docs/classes/Navigator.html +290 -0
- package/docs/classes/ObjectDeque.html +422 -0
- package/docs/classes/PriorityQueue.html +732 -0
- package/docs/classes/Queue.html +369 -0
- package/docs/classes/RBTree.html +149 -0
- package/docs/classes/SegmentTree.html +344 -0
- package/docs/classes/SegmentTreeNode.html +417 -0
- package/docs/classes/SinglyLinkedList.html +718 -0
- package/docs/classes/SinglyLinkedListNode.html +247 -0
- package/docs/classes/SplayTree.html +149 -0
- package/docs/classes/Stack.html +345 -0
- package/docs/classes/TreeMultiSet.html +2035 -0
- package/docs/classes/TreeNode.html +235 -0
- package/docs/classes/Trie.html +349 -0
- package/docs/classes/TrieNode.html +257 -0
- package/docs/classes/TwoThreeTree.html +149 -0
- package/docs/classes/UndirectedEdge.html +312 -0
- package/docs/classes/UndirectedGraph.html +1079 -0
- package/docs/classes/UndirectedVertex.html +225 -0
- package/docs/classes/Vector2D.html +782 -0
- package/docs/enums/CP.html +158 -0
- package/docs/enums/FamilyPosition.html +158 -0
- package/docs/enums/LoopType.html +159 -0
- package/docs/index.html +493 -0
- package/docs/interfaces/AVLTreeDeleted.html +160 -0
- package/docs/interfaces/HeapOptions.html +166 -0
- package/docs/interfaces/IDirectedGraph.html +242 -0
- package/docs/interfaces/IGraph.html +426 -0
- package/docs/interfaces/NavigatorParams.html +196 -0
- package/docs/interfaces/PriorityQueueOptions.html +167 -0
- package/docs/modules.html +216 -0
- package/docs/types/BSTComparator.html +139 -0
- package/docs/types/BSTDeletedResult.html +136 -0
- package/docs/types/BinaryTreeDeleted.html +136 -0
- package/docs/types/BinaryTreeNodeId.html +124 -0
- package/docs/types/BinaryTreeNodePropertyName.html +124 -0
- package/docs/types/DFSOrderPattern.html +124 -0
- package/docs/types/DijkstraResult.html +144 -0
- package/docs/types/Direction.html +124 -0
- package/docs/types/DoublyLinkedListGetBy.html +124 -0
- package/docs/types/NodeOrPropertyName.html +124 -0
- package/docs/types/PriorityQueueComparator.html +144 -0
- package/docs/types/PriorityQueueDFSOrderPattern.html +124 -0
- package/docs/types/ResultByProperty.html +129 -0
- package/docs/types/ResultsByProperty.html +129 -0
- package/docs/types/SegmentTreeNodeVal.html +124 -0
- package/docs/types/SpecifyOptional.html +131 -0
- package/docs/types/Thunk.html +132 -0
- package/docs/types/ToThunkFn.html +132 -0
- package/docs/types/TopologicalStatus.html +124 -0
- package/docs/types/TreeMultiSetDeletedResult.html +136 -0
- package/docs/types/TrlAsyncFn.html +137 -0
- package/docs/types/TrlFn.html +137 -0
- package/docs/types/Turning.html +124 -0
- package/docs/types/VertexId.html +124 -0
- package/{tests/unit/data-structures/binary-tree → notes}/bst.test.ts +37 -50
- package/notes/note.md +23 -0
- package/package.json +1 -3
- package/.idea/data-structure-typed.iml +0 -14
- package/.idea/modules.xml +0 -8
- package/.idea/vcs.xml +0 -6
- package/src/assets/complexities-diff.jpg +0 -0
- package/src/assets/data-structure-complexities.jpg +0 -0
- package/src/assets/logo.png +0 -0
- package/src/assets/overview-diagram-of-data-structures.png +0 -0
- package/src/data-structures/binary-tree/aa-tree.ts +0 -3
- package/src/data-structures/binary-tree/avl-tree.ts +0 -293
- package/src/data-structures/binary-tree/b-tree.ts +0 -3
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +0 -69
- package/src/data-structures/binary-tree/binary-tree.ts +0 -1492
- package/src/data-structures/binary-tree/bst.ts +0 -497
- package/src/data-structures/binary-tree/diagrams/avl-tree-inserting.gif +0 -0
- package/src/data-structures/binary-tree/diagrams/bst-rotation.gif +0 -0
- package/src/data-structures/binary-tree/diagrams/segment-tree.png +0 -0
- package/src/data-structures/binary-tree/index.ts +0 -11
- package/src/data-structures/binary-tree/rb-tree.ts +0 -3
- package/src/data-structures/binary-tree/segment-tree.ts +0 -267
- package/src/data-structures/binary-tree/splay-tree.ts +0 -3
- package/src/data-structures/binary-tree/tree-multiset.ts +0 -53
- package/src/data-structures/binary-tree/two-three-tree.ts +0 -3
- package/src/data-structures/diagrams/README.md +0 -5
- package/src/data-structures/graph/abstract-graph.ts +0 -958
- package/src/data-structures/graph/diagrams/adjacency-list-pros-cons.jpg +0 -0
- package/src/data-structures/graph/diagrams/adjacency-list.jpg +0 -0
- package/src/data-structures/graph/diagrams/adjacency-matrix-pros-cons.jpg +0 -0
- package/src/data-structures/graph/diagrams/adjacency-matrix.jpg +0 -0
- package/src/data-structures/graph/diagrams/dfs-can-do.jpg +0 -0
- package/src/data-structures/graph/diagrams/edge-list-pros-cons.jpg +0 -0
- package/src/data-structures/graph/diagrams/edge-list.jpg +0 -0
- package/src/data-structures/graph/diagrams/max-flow.jpg +0 -0
- package/src/data-structures/graph/diagrams/mst.jpg +0 -0
- package/src/data-structures/graph/diagrams/tarjan-articulation-point-bridge.png +0 -0
- package/src/data-structures/graph/diagrams/tarjan-complicate-simple.png +0 -0
- package/src/data-structures/graph/diagrams/tarjan-strongly-connected-component.png +0 -0
- package/src/data-structures/graph/diagrams/tarjan.mp4 +0 -0
- package/src/data-structures/graph/diagrams/tarjan.webp +0 -0
- package/src/data-structures/graph/directed-graph.ts +0 -429
- package/src/data-structures/graph/index.ts +0 -3
- package/src/data-structures/graph/undirected-graph.ts +0 -259
- package/src/data-structures/hash/coordinate-map.ts +0 -74
- package/src/data-structures/hash/coordinate-set.ts +0 -63
- package/src/data-structures/hash/hash-table.ts +0 -1
- package/src/data-structures/hash/index.ts +0 -6
- package/src/data-structures/hash/pair.ts +0 -1
- package/src/data-structures/hash/tree-map.ts +0 -1
- package/src/data-structures/hash/tree-set.ts +0 -1
- package/src/data-structures/heap/heap.ts +0 -162
- package/src/data-structures/heap/index.ts +0 -3
- package/src/data-structures/heap/max-heap.ts +0 -31
- package/src/data-structures/heap/min-heap.ts +0 -34
- package/src/data-structures/index.ts +0 -13
- package/src/data-structures/linked-list/doubly-linked-list.ts +0 -365
- package/src/data-structures/linked-list/index.ts +0 -2
- package/src/data-structures/linked-list/singly-linked-list.ts +0 -757
- package/src/data-structures/linked-list/skip-linked-list.ts +0 -1
- package/src/data-structures/matrix/index.ts +0 -4
- package/src/data-structures/matrix/matrix.ts +0 -27
- package/src/data-structures/matrix/matrix2d.ts +0 -208
- package/src/data-structures/matrix/navigator.ts +0 -122
- package/src/data-structures/matrix/vector2d.ts +0 -316
- package/src/data-structures/priority-queue/index.ts +0 -3
- package/src/data-structures/priority-queue/max-priority-queue.ts +0 -24
- package/src/data-structures/priority-queue/min-priority-queue.ts +0 -24
- package/src/data-structures/priority-queue/priority-queue.ts +0 -349
- package/src/data-structures/queue/deque.ts +0 -251
- package/src/data-structures/queue/index.ts +0 -2
- package/src/data-structures/queue/queue.ts +0 -120
- package/src/data-structures/stack/index.ts +0 -1
- package/src/data-structures/stack/stack.ts +0 -98
- package/src/data-structures/trie/index.ts +0 -1
- package/src/data-structures/trie/trie.ts +0 -225
- package/src/data-structures/types/abstract-graph.ts +0 -51
- package/src/data-structures/types/avl-tree.ts +0 -6
- package/src/data-structures/types/binary-tree.ts +0 -15
- package/src/data-structures/types/bst.ts +0 -5
- package/src/data-structures/types/directed-graph.ts +0 -18
- package/src/data-structures/types/doubly-linked-list.ts +0 -1
- package/src/data-structures/types/heap.ts +0 -8
- package/src/data-structures/types/index.ts +0 -13
- package/src/data-structures/types/navigator.ts +0 -13
- package/src/data-structures/types/priority-queue.ts +0 -9
- package/src/data-structures/types/segment-tree.ts +0 -1
- package/src/data-structures/types/singly-linked-list.ts +0 -1
- package/src/data-structures/types/tree-multiset.ts +0 -3
- package/src/index.ts +0 -1
- package/src/utils/index.ts +0 -2
- package/src/utils/types/index.ts +0 -1
- package/src/utils/types/utils.ts +0 -4
- package/src/utils/utils.ts +0 -78
- package/tests/unit/data-structures/graph/abstract-graph.ts +0 -0
- package/tests/unit/data-structures/graph/directed-graph.test.ts +0 -492
- package/tests/unit/data-structures/graph/index.ts +0 -3
- package/tests/unit/data-structures/graph/undirected-graph.ts +0 -0
|
@@ -5,290 +5,175 @@
|
|
|
5
5
|
* @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
|
|
6
6
|
* @license MIT License
|
|
7
7
|
*/
|
|
8
|
-
export declare class SinglyLinkedListNode<
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
set list(value: SinglyLinkedList<NodeVal> | null);
|
|
22
|
-
get index(): number | undefined;
|
|
23
|
-
/**
|
|
24
|
-
* The `insertBefore` function inserts a new node with the given value before the current node in a singly linked list.
|
|
25
|
-
* @param {NodeVal} val - The parameter "val" is of type "NodeVal". It represents the value of the node that you want
|
|
26
|
-
* to insert before the current node.
|
|
27
|
-
* @returns The method is returning a SinglyLinkedList<NodeVal>.
|
|
28
|
-
*/
|
|
29
|
-
insertBefore(val: NodeVal): SinglyLinkedList<NodeVal>;
|
|
30
|
-
/**
|
|
31
|
-
* The function inserts a new node with the given value after the current node in a singly linked list.
|
|
32
|
-
* @param {NodeVal} val - The parameter `val` is the value of the node that you want to insert after the current node.
|
|
33
|
-
* @returns The method is returning a SinglyLinkedList<NodeVal>.
|
|
34
|
-
*/
|
|
35
|
-
insertAfter(val: NodeVal): SinglyLinkedList<NodeVal>;
|
|
36
|
-
/**
|
|
37
|
-
* The `remove()` function removes a node from a singly linked list.
|
|
38
|
-
* @returns The remove() method is returning a SinglyLinkedListNode<NodeVal> object.
|
|
39
|
-
*/
|
|
40
|
-
remove(): SinglyLinkedListNode<NodeVal>;
|
|
8
|
+
export declare class SinglyLinkedListNode<T = number> {
|
|
9
|
+
/**
|
|
10
|
+
* The constructor function initializes an instance of a class with a given value and sets the next property to null.
|
|
11
|
+
* @param {T} val - The "val" parameter is of type T, which means it can be any data type. It represents the value that
|
|
12
|
+
* will be stored in the node of a linked list.
|
|
13
|
+
*/
|
|
14
|
+
constructor(val: T);
|
|
15
|
+
private _val;
|
|
16
|
+
get val(): T;
|
|
17
|
+
set val(value: T);
|
|
18
|
+
private _next;
|
|
19
|
+
get next(): SinglyLinkedListNode<T> | null;
|
|
20
|
+
set next(value: SinglyLinkedListNode<T> | null);
|
|
41
21
|
}
|
|
42
|
-
export declare class SinglyLinkedList<
|
|
43
|
-
/**
|
|
44
|
-
* The constructor initializes a linked list with the given arguments as nodes.
|
|
45
|
-
* @param {NodeVal[]} args - args is a rest parameter that allows the constructor to accept an arbitrary number of
|
|
46
|
-
* arguments of type NodeVal.
|
|
47
|
-
*/
|
|
48
|
-
constructor(...args: NodeVal[]);
|
|
49
|
-
protected _head: SinglyLinkedListNode<NodeVal> | null;
|
|
50
|
-
get head(): SinglyLinkedListNode<NodeVal> | null;
|
|
51
|
-
set head(value: SinglyLinkedListNode<NodeVal> | null);
|
|
52
|
-
protected _tail: SinglyLinkedListNode<NodeVal> | null;
|
|
53
|
-
get tail(): SinglyLinkedListNode<NodeVal> | null;
|
|
54
|
-
set tail(value: SinglyLinkedListNode<NodeVal> | null);
|
|
55
|
-
protected _size: number;
|
|
56
|
-
get size(): number;
|
|
57
|
-
set size(value: number);
|
|
58
|
-
/**
|
|
59
|
-
* The `from` function in TypeScript creates a new SinglyLinkedList instance from an iterable object.
|
|
60
|
-
* @param iterable - The `iterable` parameter is an object that can be iterated over, such as an array or a string. It
|
|
61
|
-
* contains a collection of elements of type `T`.
|
|
62
|
-
* @returns The method is returning a new instance of the SinglyLinkedList class.
|
|
63
|
-
*/
|
|
64
|
-
static from<T>(iterable: Iterable<T>): SinglyLinkedList<T>;
|
|
65
|
-
/**
|
|
66
|
-
* The `get` function returns the value of a node at a given index in a data structure.
|
|
67
|
-
* @param {number} index - The index parameter is a number that represents the position of the node in the data
|
|
68
|
-
* structure.
|
|
69
|
-
* @returns The method is returning the value of the node at the specified index if the node exists, otherwise it
|
|
70
|
-
* returns undefined.
|
|
71
|
-
*/
|
|
72
|
-
get(index: number): NodeVal | undefined;
|
|
73
|
-
/**
|
|
74
|
-
* The function `getNode` returns the node at a given index in a singly linked list.
|
|
75
|
-
* @param {number} index - The `index` parameter is a number that represents the position of the node we want to
|
|
76
|
-
* retrieve from the linked list.
|
|
77
|
-
* @returns a SinglyLinkedListNode<NodeVal> object or undefined.
|
|
78
|
-
*/
|
|
79
|
-
getNode(index: number): SinglyLinkedListNode<NodeVal> | undefined;
|
|
22
|
+
export declare class SinglyLinkedList<T> {
|
|
80
23
|
/**
|
|
81
|
-
* The
|
|
82
|
-
* returns its index and the node itself.
|
|
83
|
-
* @param callbackFn - The callbackFn parameter is a function that takes three arguments: data, index, and list. It is
|
|
84
|
-
* used to determine whether a node in the singly linked list matches a certain condition. The function should return a
|
|
85
|
-
* boolean value indicating whether the condition is met for the given node.
|
|
86
|
-
* @returns The function `findNodeIndex` returns an object with two properties: `node` and `index`. The `node` property
|
|
87
|
-
* contains the node that matches the condition specified in the `callbackFn` function, and the `index` property
|
|
88
|
-
* contains the index of that node in the linked list. If no node matches the condition, the function returns
|
|
89
|
-
* `undefined`.
|
|
24
|
+
* The constructor initializes the linked list with an empty head, tail, and length.
|
|
90
25
|
*/
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
26
|
+
constructor();
|
|
27
|
+
private _head;
|
|
28
|
+
get head(): SinglyLinkedListNode<T> | null;
|
|
29
|
+
set head(value: SinglyLinkedListNode<T> | null);
|
|
30
|
+
private _tail;
|
|
31
|
+
get tail(): SinglyLinkedListNode<T> | null;
|
|
32
|
+
set tail(value: SinglyLinkedListNode<T> | null);
|
|
33
|
+
private _length;
|
|
34
|
+
get length(): number;
|
|
35
|
+
protected set length(value: number);
|
|
95
36
|
/**
|
|
96
|
-
* The
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
* @returns The
|
|
100
|
-
* specified by the `callbackFn` is found in the linked list. If no such node is found, it returns `undefined`.
|
|
37
|
+
* The `fromArray` function creates a new SinglyLinkedList instance and populates it with the elements from the given
|
|
38
|
+
* array.
|
|
39
|
+
* @param {T[]} data - The `data` parameter is an array of elements of type `T`.
|
|
40
|
+
* @returns The `fromArray` function returns a `SinglyLinkedList` object.
|
|
101
41
|
*/
|
|
102
|
-
|
|
42
|
+
static fromArray<T>(data: T[]): SinglyLinkedList<T>;
|
|
43
|
+
getLength(): number;
|
|
103
44
|
/**
|
|
104
|
-
* The `
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
* value indicating whether the condition is met for a particular node in the linked list.
|
|
108
|
-
* @returns The method `find` returns the `NodeVal` value of the first node in the linked list that satisfies the
|
|
109
|
-
* condition specified by the `callbackFn` function. If no node satisfies the condition, it returns `undefined`.
|
|
45
|
+
* The `push` function adds a new node with the given data to the end of a singly linked list.
|
|
46
|
+
* @param {T} data - The "data" parameter represents the value that you want to add to the linked list. It can be of
|
|
47
|
+
* any type (T) as specified in the generic type declaration of the class or function.
|
|
110
48
|
*/
|
|
111
|
-
|
|
49
|
+
push(data: T): void;
|
|
112
50
|
/**
|
|
113
|
-
* The
|
|
114
|
-
*
|
|
115
|
-
* @
|
|
116
|
-
*
|
|
117
|
-
* @returns The method `findIndex` returns a number.
|
|
51
|
+
* The `pop()` function removes and returns the value of the last element in a linked list, updating the head and tail
|
|
52
|
+
* pointers accordingly.
|
|
53
|
+
* @returns The method `pop()` returns the value of the node that is being removed from the end of the linked list. If
|
|
54
|
+
* the linked list is empty, it returns `null`.
|
|
118
55
|
*/
|
|
119
|
-
|
|
120
|
-
append(...args: NodeVal[]): SinglyLinkedList<NodeVal>;
|
|
56
|
+
pop(): T | null;
|
|
121
57
|
/**
|
|
122
|
-
* The
|
|
123
|
-
*
|
|
124
|
-
* @param {NodeVal[]} args - args is a rest parameter of type NodeVal[]. It allows the function to accept any number
|
|
125
|
-
* of arguments of type NodeVal.
|
|
126
|
-
* @returns The size of the data structure after the nodes are appended.
|
|
58
|
+
* The `shift()` function removes and returns the value of the first node in a linked list.
|
|
59
|
+
* @returns The value of the node that is being removed from the beginning of the linked list.
|
|
127
60
|
*/
|
|
128
|
-
|
|
61
|
+
shift(): T | null;
|
|
129
62
|
/**
|
|
130
|
-
* The
|
|
131
|
-
* @param {
|
|
132
|
-
* @returns The `prepend` method is returning the updated `SinglyLinkedList` object.
|
|
133
|
-
*/
|
|
134
|
-
prepend(...args: NodeVal[]): SinglyLinkedList<NodeVal>;
|
|
135
|
-
/**
|
|
136
|
-
* The `insertAt` function inserts a value at a specified index in a singly linked list.
|
|
137
|
-
* @param {number} index - The index parameter is a number that represents the position at which the new node should be
|
|
138
|
-
* inserted in the linked list.
|
|
139
|
-
* @param {NodeVal} val - The `val` parameter represents the value of the node that you want to insert into the linked
|
|
140
|
-
* list.
|
|
141
|
-
* @returns The method `insertAt` returns the updated `SinglyLinkedList` object.
|
|
142
|
-
*/
|
|
143
|
-
insertAt(index: number, val: NodeVal): SinglyLinkedList<NodeVal>;
|
|
144
|
-
/**
|
|
145
|
-
* The removeNode function removes a node from a singly linked list and updates the head, tail, and size properties
|
|
146
|
-
* accordingly.
|
|
147
|
-
* @param node - The `node` parameter is of type `SinglyLinkedListNode<NodeVal>`, which represents a node in a singly
|
|
63
|
+
* The unshift function adds a new node with the given value to the beginning of a singly linked list.
|
|
64
|
+
* @param {T} val - The parameter "val" represents the value of the new node that will be added to the beginning of the
|
|
148
65
|
* linked list.
|
|
149
|
-
* @returns the removed node.
|
|
150
66
|
*/
|
|
151
|
-
|
|
67
|
+
unshift(val: T): void;
|
|
152
68
|
/**
|
|
153
|
-
* The `
|
|
154
|
-
* @param {number} index - The index parameter is a number that represents the position of the
|
|
155
|
-
*
|
|
156
|
-
* @returns The method `
|
|
157
|
-
*
|
|
69
|
+
* The function `getAt` returns the value at a specified index in a linked list, or null if the index is out of range.
|
|
70
|
+
* @param {number} index - The index parameter is a number that represents the position of the element we want to
|
|
71
|
+
* retrieve from the list.
|
|
72
|
+
* @returns The method `getAt(index: number): T | null` returns the value at the specified index in the linked list, or
|
|
73
|
+
* `null` if the index is out of bounds.
|
|
158
74
|
*/
|
|
159
|
-
|
|
75
|
+
getAt(index: number): T | null;
|
|
160
76
|
/**
|
|
161
|
-
* The `
|
|
162
|
-
*
|
|
163
|
-
*
|
|
164
|
-
*
|
|
165
|
-
*
|
|
166
|
-
* @returns The method is returning the updated SinglyLinkedList object.
|
|
77
|
+
* The function `getNodeAt` returns the node at a given index in a singly linked list.
|
|
78
|
+
* @param {number} index - The `index` parameter is a number that represents the position of the node we want to
|
|
79
|
+
* retrieve from the linked list. It indicates the zero-based index of the node we want to access.
|
|
80
|
+
* @returns The method `getNodeAt(index: number)` returns a `SinglyLinkedListNode<T>` object if the node at the
|
|
81
|
+
* specified index exists, or `null` if the index is out of bounds.
|
|
167
82
|
*/
|
|
168
|
-
|
|
83
|
+
getNodeAt(index: number): SinglyLinkedListNode<T> | null;
|
|
169
84
|
/**
|
|
170
|
-
* The `
|
|
171
|
-
*
|
|
172
|
-
*
|
|
173
|
-
* @
|
|
174
|
-
*
|
|
175
|
-
* @returns The `sort` method is returning the sorted `SinglyLinkedList` object.
|
|
85
|
+
* The `deleteAt` function removes an element at a specified index from a linked list and returns the removed element.
|
|
86
|
+
* @param {number} index - The index parameter represents the position of the element that needs to be deleted in the
|
|
87
|
+
* data structure. It is of type number.
|
|
88
|
+
* @returns The method `deleteAt` returns the value of the node that was deleted, or `null` if the index is out of
|
|
89
|
+
* bounds.
|
|
176
90
|
*/
|
|
177
|
-
|
|
91
|
+
deleteAt(index: number): T | null;
|
|
178
92
|
/**
|
|
179
|
-
* The `
|
|
93
|
+
* The `delete` function removes a specified value from a linked list and returns true if the value was found and
|
|
94
|
+
* removed, otherwise it returns false.
|
|
95
|
+
* @param {T} value - The value parameter represents the value of the node that needs to be deleted from the linked
|
|
180
96
|
* list.
|
|
181
|
-
* @
|
|
182
|
-
*
|
|
183
|
-
* @returns The `insertAfter` method is returning the updated `SinglyLinkedList` object.
|
|
97
|
+
* @returns The `delete` method returns a boolean value. It returns `true` if the value was successfully deleted from
|
|
98
|
+
* the linked list, and `false` if the value was not found in the linked list.
|
|
184
99
|
*/
|
|
185
|
-
|
|
100
|
+
delete(value: T): boolean;
|
|
186
101
|
/**
|
|
187
|
-
* The `
|
|
188
|
-
* @
|
|
102
|
+
* The `insert` function inserts a value at a specified index in a singly linked list.
|
|
103
|
+
* @param {number} index - The index parameter represents the position at which the new value should be inserted in the
|
|
104
|
+
* linked list. It is of type number.
|
|
105
|
+
* @param {T} val - The `val` parameter represents the value that you want to insert into the linked list at the
|
|
106
|
+
* specified index.
|
|
107
|
+
* @returns The `insert` method returns a boolean value. It returns `true` if the insertion is successful, and `false`
|
|
108
|
+
* if the index is out of bounds.
|
|
189
109
|
*/
|
|
190
|
-
|
|
110
|
+
insert(index: number, val: T): boolean;
|
|
191
111
|
/**
|
|
192
|
-
* The
|
|
193
|
-
*
|
|
194
|
-
|
|
195
|
-
pop(): NodeVal | undefined;
|
|
196
|
-
/**
|
|
197
|
-
* The merge function merges two singly linked lists by updating the next and prev pointers, as well as the head, tail,
|
|
198
|
-
* and size properties.
|
|
199
|
-
* @param list - The parameter "list" is a SinglyLinkedList object that contains nodes with data of type NodeVal.
|
|
200
|
-
*/
|
|
201
|
-
merge(list: SinglyLinkedList<NodeVal>): void;
|
|
202
|
-
/**
|
|
203
|
-
* The clear() function resets the linked list by setting the head and tail to null and the size to 0.
|
|
204
|
-
* @returns The "this" object is being returned.
|
|
205
|
-
*/
|
|
206
|
-
clear(): this;
|
|
207
|
-
/**
|
|
208
|
-
* The `slice` function returns a new SinglyLinkedList containing a portion of the original list, starting from the
|
|
209
|
-
* specified index and ending at the optional end index.
|
|
210
|
-
* @param {number} start - The `start` parameter is a number that represents the index at which to start slicing the
|
|
211
|
-
* linked list.
|
|
212
|
-
* @param {number} [end] - The `end` parameter is an optional number that specifies the index at which to end the
|
|
213
|
-
* slicing. If no value is provided for `end`, or if the provided value is less than the `start` index, the slicing
|
|
214
|
-
* will continue until the end of the list.
|
|
215
|
-
* @returns a new SinglyLinkedList containing the sliced elements from the original list.
|
|
112
|
+
* The function checks if the length of a data structure is equal to zero and returns a boolean value indicating
|
|
113
|
+
* whether it is empty or not.
|
|
114
|
+
* @returns A boolean value indicating whether the length of the object is equal to 0.
|
|
216
115
|
*/
|
|
217
|
-
|
|
116
|
+
isEmpty(): boolean;
|
|
218
117
|
/**
|
|
219
|
-
* The
|
|
220
|
-
* @returns The reverse() method is returning the reversed SinglyLinkedList.
|
|
118
|
+
* The `clear` function resets the linked list by setting the head, tail, and length to null and 0 respectively.
|
|
221
119
|
*/
|
|
222
|
-
|
|
120
|
+
clear(): void;
|
|
223
121
|
/**
|
|
224
|
-
* The `
|
|
225
|
-
*
|
|
226
|
-
* @param callbackFn - A callback function that will be called for each element in the linked list. It takes three
|
|
227
|
-
* parameters:
|
|
228
|
-
* @param [reverse=false] - A boolean value indicating whether to iterate over the linked list in reverse order. If set
|
|
229
|
-
* to true, the iteration will start from the tail of the linked list and move towards the head. If set to false
|
|
230
|
-
* (default), the iteration will start from the head and move towards the tail.
|
|
122
|
+
* The `toArray` function converts a linked list into an array.
|
|
123
|
+
* @returns The `toArray()` method is returning an array of type `T[]`.
|
|
231
124
|
*/
|
|
232
|
-
|
|
125
|
+
toArray(): T[];
|
|
233
126
|
/**
|
|
234
|
-
* The
|
|
235
|
-
*
|
|
236
|
-
* @param callbackFn - A callback function that will be applied to each element in the linked list. It takes three
|
|
237
|
-
* parameters:
|
|
238
|
-
* @param [reverse=false] - The `reverse` parameter is a boolean value that determines whether the mapping should be
|
|
239
|
-
* done in reverse order or not. If `reverse` is set to `true`, the mapping will be done in reverse order. If `reverse`
|
|
240
|
-
* is set to `false` or not provided, the mapping will be
|
|
241
|
-
* @returns The `map` function is returning a new `SinglyLinkedList` object.
|
|
127
|
+
* The `reverse` function reverses the order of the nodes in a singly linked list.
|
|
128
|
+
* @returns The reverse() method does not return anything. It has a return type of void.
|
|
242
129
|
*/
|
|
243
|
-
|
|
130
|
+
reverse(): void;
|
|
244
131
|
/**
|
|
245
|
-
* The `
|
|
246
|
-
* @param
|
|
247
|
-
*
|
|
248
|
-
* @
|
|
249
|
-
*
|
|
250
|
-
* to `false` or not provided, the filtered list will be in
|
|
251
|
-
* @returns The `filter` method is returning a new `SinglyLinkedList` object.
|
|
132
|
+
* The `find` function iterates through a linked list and returns the first element that satisfies a given condition.
|
|
133
|
+
* @param callback - A function that takes a value of type T as its parameter and returns a boolean value. This
|
|
134
|
+
* function is used to determine whether a particular value in the linked list satisfies a certain condition.
|
|
135
|
+
* @returns The method `find` returns the first element in the linked list that satisfies the condition specified by
|
|
136
|
+
* the callback function. If no element satisfies the condition, it returns `null`.
|
|
252
137
|
*/
|
|
253
|
-
|
|
138
|
+
find(callback: (val: T) => boolean): T | null;
|
|
254
139
|
/**
|
|
255
|
-
* The `
|
|
256
|
-
*
|
|
257
|
-
* @
|
|
258
|
-
*
|
|
259
|
-
* @param {any} [start] - The `start` parameter is an optional initial value for the accumulator. If provided, the
|
|
260
|
-
* `reduce` function will start accumulating from this value. If not provided, the `reduce` function will use the value
|
|
261
|
-
* of the first element in the linked list as the initial value.
|
|
262
|
-
* @param [reverse=false] - A boolean value indicating whether to iterate over the linked list in reverse order. If set
|
|
263
|
-
* to true, the iteration will start from the tail of the linked list and move towards the head. If set to false
|
|
264
|
-
* (default), the iteration will start from the head and move towards the tail.
|
|
265
|
-
* @returns The `reduce` method returns the accumulated value after applying the callback function to each element in
|
|
266
|
-
* the linked list.
|
|
140
|
+
* The `indexOf` function returns the index of the first occurrence of a given value in a linked list.
|
|
141
|
+
* @param {T} value - The value parameter is the value that you want to find the index of in the linked list.
|
|
142
|
+
* @returns The method is returning the index of the first occurrence of the specified value in the linked list. If the
|
|
143
|
+
* value is not found, it returns -1.
|
|
267
144
|
*/
|
|
268
|
-
|
|
145
|
+
indexOf(value: T): number;
|
|
269
146
|
/**
|
|
270
|
-
* The
|
|
271
|
-
*
|
|
147
|
+
* The function finds a node in a singly linked list by its value and returns the node if found, otherwise returns
|
|
148
|
+
* null.
|
|
149
|
+
* @param {T} value - The value parameter is the value that we want to search for in the linked list.
|
|
150
|
+
* @returns a `SinglyLinkedListNode<T>` if a node with the specified value is found in the linked list. If no node with
|
|
151
|
+
* the specified value is found, the function returns `null`.
|
|
272
152
|
*/
|
|
273
|
-
|
|
153
|
+
findNode(value: T): SinglyLinkedListNode<T> | null;
|
|
274
154
|
/**
|
|
275
|
-
* The `
|
|
276
|
-
*
|
|
277
|
-
*
|
|
278
|
-
*
|
|
279
|
-
*
|
|
280
|
-
*
|
|
155
|
+
* The `insertBefore` function inserts a new value before an existing value in a singly linked list.
|
|
156
|
+
* @param {T} existingValue - The existing value is the value that already exists in the linked list and before which
|
|
157
|
+
* we want to insert a new value.
|
|
158
|
+
* @param {T} newValue - The `newValue` parameter represents the value that you want to insert into the linked list.
|
|
159
|
+
* @returns The `insertBefore` function returns a boolean value. It returns `true` if the `newValue` is successfully
|
|
160
|
+
* inserted before the first occurrence of `existingValue` in the linked list. It returns `false` if the
|
|
161
|
+
* `existingValue` is not found in the linked list.
|
|
281
162
|
*/
|
|
282
|
-
|
|
163
|
+
insertBefore(existingValue: T, newValue: T): boolean;
|
|
283
164
|
/**
|
|
284
|
-
* The function
|
|
165
|
+
* The function inserts a new value after an existing value in a singly linked list.
|
|
166
|
+
* @param {T} existingValue - The existing value is the value of the node after which we want to insert the new value.
|
|
167
|
+
* @param {T} newValue - The `newValue` parameter represents the value that you want to insert into the linked list
|
|
168
|
+
* after the node with the `existingValue`.
|
|
169
|
+
* @returns The method is returning a boolean value. It returns true if the insertion is successful and false if the
|
|
170
|
+
* existing value is not found in the linked list.
|
|
285
171
|
*/
|
|
286
|
-
|
|
172
|
+
insertAfter(existingValue: T, newValue: T): boolean;
|
|
287
173
|
/**
|
|
288
|
-
* The function
|
|
289
|
-
* @param {
|
|
290
|
-
*
|
|
291
|
-
* @returns The value of the removed node if the node is not null, otherwise undefined.
|
|
174
|
+
* The function counts the number of occurrences of a given value in a linked list.
|
|
175
|
+
* @param {T} value - The value parameter is the value that you want to count the occurrences of in the linked list.
|
|
176
|
+
* @returns The count of occurrences of the given value in the linked list.
|
|
292
177
|
*/
|
|
293
|
-
|
|
178
|
+
countOccurrences(value: T): number;
|
|
294
179
|
}
|