data-structure-typed 1.17.0 → 1.17.3
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/dist/data-structures/linked-list/doubly-linked-list.d.ts +7 -26
- package/dist/data-structures/linked-list/doubly-linked-list.js +59 -40
- package/dist/data-structures/linked-list/index.d.ts +1 -0
- package/dist/data-structures/linked-list/index.js +1 -0
- package/dist/data-structures/linked-list/singly-linked-list.d.ts +7 -29
- package/dist/data-structures/linked-list/singly-linked-list.js +42 -26
- package/dist/data-structures/linked-list/skip-linked-list.d.ts +2 -1
- package/dist/data-structures/linked-list/skip-linked-list.js +7 -0
- package/dist/data-structures/matrix/vector2d.js +2 -2
- package/docs/assets/search.js +1 -1
- package/docs/classes/AVLTree.html +94 -93
- package/docs/classes/AVLTreeNode.html +37 -36
- package/docs/classes/AaTree.html +2 -1
- package/docs/classes/AbstractEdge.html +12 -11
- package/docs/classes/AbstractGraph.html +30 -29
- package/docs/classes/AbstractVertex.html +7 -6
- package/docs/classes/ArrayDeque.html +15 -14
- package/docs/classes/BST.html +87 -86
- package/docs/classes/BSTNode.html +37 -36
- package/docs/classes/BTree.html +2 -1
- package/docs/classes/BinaryIndexedTree.html +8 -7
- package/docs/classes/BinaryTree.html +83 -82
- package/docs/classes/BinaryTreeNode.html +37 -36
- package/docs/classes/Character.html +5 -4
- package/docs/classes/CoordinateMap.html +11 -10
- package/docs/classes/CoordinateSet.html +10 -9
- package/docs/classes/Deque.html +145 -67
- package/docs/classes/DirectedEdge.html +18 -17
- package/docs/classes/DirectedGraph.html +42 -41
- package/docs/classes/DirectedVertex.html +7 -6
- package/docs/classes/DoublyLinkedList.html +143 -68
- package/docs/classes/DoublyLinkedListNode.html +12 -11
- package/docs/classes/Heap.html +21 -20
- package/docs/classes/HeapItem.html +9 -8
- package/docs/classes/Matrix2D.html +17 -16
- package/docs/classes/MatrixNTI2D.html +5 -4
- package/docs/classes/MaxHeap.html +21 -20
- package/docs/classes/MaxPriorityQueue.html +35 -34
- package/docs/classes/MinHeap.html +21 -20
- package/docs/classes/MinPriorityQueue.html +35 -34
- package/docs/classes/Navigator.html +11 -10
- package/docs/classes/ObjectDeque.html +26 -25
- package/docs/classes/PriorityQueue.html +33 -32
- package/docs/classes/Queue.html +15 -14
- package/docs/classes/RBTree.html +2 -1
- package/docs/classes/SegmentTree.html +13 -12
- package/docs/classes/SegmentTreeNode.html +27 -26
- package/docs/classes/SinglyLinkedList.html +128 -70
- package/docs/classes/SinglyLinkedListNode.html +9 -8
- package/docs/classes/SkipLinkedList.html +150 -0
- package/docs/classes/SplayTree.html +2 -1
- package/docs/classes/Stack.html +13 -12
- package/docs/classes/TreeMultiSet.html +87 -86
- package/docs/classes/TreeNode.html +9 -8
- package/docs/classes/Trie.html +14 -13
- package/docs/classes/TrieNode.html +12 -11
- package/docs/classes/TwoThreeTree.html +2 -1
- package/docs/classes/UndirectedEdge.html +14 -13
- package/docs/classes/UndirectedGraph.html +36 -35
- package/docs/classes/UndirectedVertex.html +7 -6
- package/docs/classes/Vector2D.html +29 -28
- package/docs/enums/CP.html +5 -4
- package/docs/enums/FamilyPosition.html +5 -4
- package/docs/enums/LoopType.html +4 -3
- package/docs/index.html +1 -0
- package/docs/interfaces/AVLTreeDeleted.html +4 -3
- package/docs/interfaces/HeapOptions.html +3 -2
- package/docs/interfaces/IDirectedGraph.html +8 -7
- package/docs/interfaces/IGraph.html +20 -19
- package/docs/interfaces/NavigatorParams.html +6 -5
- package/docs/interfaces/PriorityQueueOptions.html +5 -4
- package/docs/modules.html +2 -0
- package/docs/types/BSTComparator.html +2 -1
- package/docs/types/BSTDeletedResult.html +2 -1
- package/docs/types/BinaryTreeDeleted.html +2 -1
- package/docs/types/BinaryTreeNodeId.html +2 -1
- package/docs/types/BinaryTreeNodePropertyName.html +2 -1
- package/docs/types/DFSOrderPattern.html +2 -1
- package/docs/types/DijkstraResult.html +2 -1
- package/docs/types/Direction.html +2 -1
- package/docs/types/DoublyLinkedListGetBy.html +2 -1
- package/docs/types/NodeOrPropertyName.html +2 -1
- package/docs/types/PriorityQueueComparator.html +2 -1
- package/docs/types/PriorityQueueDFSOrderPattern.html +2 -1
- package/docs/types/ResultByProperty.html +2 -1
- package/docs/types/ResultsByProperty.html +2 -1
- package/docs/types/SegmentTreeNodeVal.html +2 -1
- package/docs/types/SpecifyOptional.html +2 -1
- package/docs/types/Thunk.html +2 -1
- package/docs/types/ToThunkFn.html +2 -1
- package/docs/types/TopologicalStatus.html +2 -1
- package/docs/types/TreeMultiSetDeletedResult.html +2 -1
- package/docs/types/TrlAsyncFn.html +2 -1
- package/docs/types/TrlFn.html +2 -1
- package/docs/types/Turning.html +2 -1
- package/docs/types/VertexId.html +2 -1
- package/package.json +1 -1
|
@@ -101,7 +101,7 @@ export declare class DoublyLinkedList<T> {
|
|
|
101
101
|
* @returns The `insert` method returns a boolean value. It returns `true` if the insertion is successful, and `false`
|
|
102
102
|
* if the index is out of bounds.
|
|
103
103
|
*/
|
|
104
|
-
|
|
104
|
+
insertAt(index: number, val: T): boolean;
|
|
105
105
|
/**
|
|
106
106
|
* The `deleteAt` function removes an element at a specified index from a linked list and returns the removed element.
|
|
107
107
|
* @param {number} index - The index parameter represents the position of the element that needs to be deleted in the
|
|
@@ -110,13 +110,8 @@ export declare class DoublyLinkedList<T> {
|
|
|
110
110
|
* bounds.
|
|
111
111
|
*/
|
|
112
112
|
deleteAt(index: number): T | null;
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
* @param {T} val - The `val` parameter represents the value that you want to delete from the linked list.
|
|
116
|
-
* @returns The `delete` method returns a boolean value. It returns `true` if the value `val` is found and deleted from
|
|
117
|
-
* the linked list, and `false` if the value is not found in the linked list.
|
|
118
|
-
*/
|
|
119
|
-
delete(val: T): boolean;
|
|
113
|
+
delete(valOrNode: T): boolean;
|
|
114
|
+
delete(valOrNode: DoublyLinkedListNode<T>): boolean;
|
|
120
115
|
/**
|
|
121
116
|
* The `toArray` function converts a linked list into an array.
|
|
122
117
|
* @returns The `toArray()` method is returning an array of type `T[]`.
|
|
@@ -195,22 +190,8 @@ export declare class DoublyLinkedList<T> {
|
|
|
195
190
|
* elements in the linked list.
|
|
196
191
|
*/
|
|
197
192
|
reduce<U>(callback: (accumulator: U, val: T) => U, initialValue: U): U;
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
* the existing node.
|
|
203
|
-
* @returns The method is returning a boolean value. It returns true if the insertion is successful and false if the
|
|
204
|
-
* existing value is not found in the linked list.
|
|
205
|
-
*/
|
|
206
|
-
insertAfter(existingValue: T, newValue: T): boolean;
|
|
207
|
-
/**
|
|
208
|
-
* The `insertBefore` function inserts a new value before an existing value in a doubly linked list.
|
|
209
|
-
* @param {T} existingValue - The existing value is the value of the node that you want to insert the new value before.
|
|
210
|
-
* @param {T} newValue - The `newValue` parameter represents the value of the new node that you want to insert before
|
|
211
|
-
* the existing node.
|
|
212
|
-
* @returns The method is returning a boolean value. It returns true if the insertion is successful and false if the
|
|
213
|
-
* existing value is not found in the linked list.
|
|
214
|
-
*/
|
|
215
|
-
insertBefore(existingValue: T, newValue: T): boolean;
|
|
193
|
+
insertAfter(existingValueOrNode: T, newValue: T): boolean;
|
|
194
|
+
insertAfter(existingValueOrNode: DoublyLinkedListNode<T>, newValue: T): boolean;
|
|
195
|
+
insertBefore(existingValueOrNode: T, newValue: T): boolean;
|
|
196
|
+
insertBefore(existingValueOrNode: DoublyLinkedListNode<T>, newValue: T): boolean;
|
|
216
197
|
}
|
|
@@ -279,7 +279,7 @@ var DoublyLinkedList = /** @class */ (function () {
|
|
|
279
279
|
* @returns The `insert` method returns a boolean value. It returns `true` if the insertion is successful, and `false`
|
|
280
280
|
* if the index is out of bounds.
|
|
281
281
|
*/
|
|
282
|
-
DoublyLinkedList.prototype.
|
|
282
|
+
DoublyLinkedList.prototype.insertAt = function (index, val) {
|
|
283
283
|
if (index < 0 || index > this.length)
|
|
284
284
|
return false;
|
|
285
285
|
if (index === 0) {
|
|
@@ -323,31 +323,35 @@ var DoublyLinkedList = /** @class */ (function () {
|
|
|
323
323
|
return removedNode.val;
|
|
324
324
|
};
|
|
325
325
|
/**
|
|
326
|
-
* The `delete` function removes a node
|
|
327
|
-
* @param {T}
|
|
328
|
-
*
|
|
329
|
-
*
|
|
326
|
+
* The `delete` function removes a node from a doubly linked list based on either the node itself or its value.
|
|
327
|
+
* @param {T | DoublyLinkedListNode<T>} valOrNode - The `valOrNode` parameter can accept either a value of type `T` or
|
|
328
|
+
* a `DoublyLinkedListNode<T>` object.
|
|
329
|
+
* @returns The `delete` method returns a boolean value. It returns `true` if the value or node was successfully
|
|
330
|
+
* deleted from the doubly linked list, and `false` if the value or node was not found in the list.
|
|
330
331
|
*/
|
|
331
|
-
DoublyLinkedList.prototype.delete = function (
|
|
332
|
-
var
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
var prevNode = current.prev;
|
|
343
|
-
var nextNode = current.next;
|
|
344
|
-
prevNode.next = nextNode;
|
|
345
|
-
nextNode.prev = prevNode;
|
|
346
|
-
this.length--;
|
|
347
|
-
}
|
|
348
|
-
return true;
|
|
332
|
+
DoublyLinkedList.prototype.delete = function (valOrNode) {
|
|
333
|
+
var node;
|
|
334
|
+
if (valOrNode instanceof (DoublyLinkedListNode)) {
|
|
335
|
+
node = valOrNode;
|
|
336
|
+
}
|
|
337
|
+
else {
|
|
338
|
+
node = this.findNode(valOrNode);
|
|
339
|
+
}
|
|
340
|
+
if (node) {
|
|
341
|
+
if (node === this.head) {
|
|
342
|
+
this.shift();
|
|
349
343
|
}
|
|
350
|
-
|
|
344
|
+
else if (node === this.tail) {
|
|
345
|
+
this.pop();
|
|
346
|
+
}
|
|
347
|
+
else {
|
|
348
|
+
var prevNode = node.prev;
|
|
349
|
+
var nextNode = node.next;
|
|
350
|
+
prevNode.next = nextNode;
|
|
351
|
+
nextNode.prev = prevNode;
|
|
352
|
+
this.length--;
|
|
353
|
+
}
|
|
354
|
+
return true;
|
|
351
355
|
}
|
|
352
356
|
return false;
|
|
353
357
|
};
|
|
@@ -522,15 +526,22 @@ var DoublyLinkedList = /** @class */ (function () {
|
|
|
522
526
|
return accumulator;
|
|
523
527
|
};
|
|
524
528
|
/**
|
|
525
|
-
* The function inserts a new value after an existing
|
|
526
|
-
* @param {T}
|
|
527
|
-
*
|
|
528
|
-
*
|
|
529
|
-
* @
|
|
530
|
-
*
|
|
529
|
+
* The `insertAfter` function inserts a new node with a given value after an existing node in a doubly linked list.
|
|
530
|
+
* @param {T | DoublyLinkedListNode<T>} existingValueOrNode - The existing value or node in the doubly linked list
|
|
531
|
+
* after which the new value will be inserted. It can be either the value of the existing node or the existing node
|
|
532
|
+
* itself.
|
|
533
|
+
* @param {T} newValue - The value that you want to insert into the doubly linked list.
|
|
534
|
+
* @returns The method returns a boolean value. It returns true if the insertion is successful, and false if the
|
|
535
|
+
* existing value or node is not found in the doubly linked list.
|
|
531
536
|
*/
|
|
532
|
-
DoublyLinkedList.prototype.insertAfter = function (
|
|
533
|
-
var existingNode
|
|
537
|
+
DoublyLinkedList.prototype.insertAfter = function (existingValueOrNode, newValue) {
|
|
538
|
+
var existingNode;
|
|
539
|
+
if (existingValueOrNode instanceof (DoublyLinkedListNode)) {
|
|
540
|
+
existingNode = existingValueOrNode;
|
|
541
|
+
}
|
|
542
|
+
else {
|
|
543
|
+
existingNode = this.findNode(existingValueOrNode);
|
|
544
|
+
}
|
|
534
545
|
if (existingNode) {
|
|
535
546
|
var newNode = new DoublyLinkedListNode(newValue);
|
|
536
547
|
newNode.next = existingNode.next;
|
|
@@ -548,15 +559,23 @@ var DoublyLinkedList = /** @class */ (function () {
|
|
|
548
559
|
return false;
|
|
549
560
|
};
|
|
550
561
|
/**
|
|
551
|
-
* The `insertBefore` function inserts a new value before an existing value in a doubly linked list.
|
|
552
|
-
* @param {T}
|
|
553
|
-
*
|
|
554
|
-
*
|
|
555
|
-
* @
|
|
556
|
-
*
|
|
562
|
+
* The `insertBefore` function inserts a new value before an existing value or node in a doubly linked list.
|
|
563
|
+
* @param {T | DoublyLinkedListNode<T>} existingValueOrNode - The existing value or node in the doubly linked list
|
|
564
|
+
* before which the new value will be inserted. It can be either the value of the existing node or the existing node
|
|
565
|
+
* itself.
|
|
566
|
+
* @param {T} newValue - The `newValue` parameter represents the value that you want to insert into the doubly linked
|
|
567
|
+
* list.
|
|
568
|
+
* @returns The method returns a boolean value. It returns `true` if the insertion is successful, and `false` if the
|
|
569
|
+
* insertion fails.
|
|
557
570
|
*/
|
|
558
|
-
DoublyLinkedList.prototype.insertBefore = function (
|
|
559
|
-
var existingNode
|
|
571
|
+
DoublyLinkedList.prototype.insertBefore = function (existingValueOrNode, newValue) {
|
|
572
|
+
var existingNode;
|
|
573
|
+
if (existingValueOrNode instanceof (DoublyLinkedListNode)) {
|
|
574
|
+
existingNode = existingValueOrNode;
|
|
575
|
+
}
|
|
576
|
+
else {
|
|
577
|
+
existingNode = this.findNode(existingValueOrNode);
|
|
578
|
+
}
|
|
560
579
|
if (existingNode) {
|
|
561
580
|
var newNode = new DoublyLinkedListNode(newValue);
|
|
562
581
|
newNode.prev = existingNode.prev;
|
|
@@ -16,3 +16,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./singly-linked-list"), exports);
|
|
18
18
|
__exportStar(require("./doubly-linked-list"), exports);
|
|
19
|
+
__exportStar(require("./skip-linked-list"), exports);
|
|
@@ -89,17 +89,10 @@ export declare class SinglyLinkedList<T> {
|
|
|
89
89
|
* bounds.
|
|
90
90
|
*/
|
|
91
91
|
deleteAt(index: number): T | null;
|
|
92
|
+
delete(valueOrNode: T): boolean;
|
|
93
|
+
delete(valueOrNode: SinglyLinkedListNode<T>): boolean;
|
|
92
94
|
/**
|
|
93
|
-
* The `
|
|
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
|
|
96
|
-
* list.
|
|
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.
|
|
99
|
-
*/
|
|
100
|
-
delete(value: T): boolean;
|
|
101
|
-
/**
|
|
102
|
-
* The `insert` function inserts a value at a specified index in a singly linked list.
|
|
95
|
+
* The `insertAt` function inserts a value at a specified index in a singly linked list.
|
|
103
96
|
* @param {number} index - The index parameter represents the position at which the new value should be inserted in the
|
|
104
97
|
* linked list. It is of type number.
|
|
105
98
|
* @param {T} val - The `val` parameter represents the value that you want to insert into the linked list at the
|
|
@@ -107,7 +100,7 @@ export declare class SinglyLinkedList<T> {
|
|
|
107
100
|
* @returns The `insert` method returns a boolean value. It returns `true` if the insertion is successful, and `false`
|
|
108
101
|
* if the index is out of bounds.
|
|
109
102
|
*/
|
|
110
|
-
|
|
103
|
+
insertAt(index: number, val: T): boolean;
|
|
111
104
|
/**
|
|
112
105
|
* The function checks if the length of a data structure is equal to zero and returns a boolean value indicating
|
|
113
106
|
* whether it is empty or not.
|
|
@@ -151,25 +144,10 @@ export declare class SinglyLinkedList<T> {
|
|
|
151
144
|
* the specified value is found, the function returns `null`.
|
|
152
145
|
*/
|
|
153
146
|
findNode(value: T): SinglyLinkedListNode<T> | null;
|
|
154
|
-
/**
|
|
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.
|
|
162
|
-
*/
|
|
163
147
|
insertBefore(existingValue: T, newValue: T): boolean;
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
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.
|
|
171
|
-
*/
|
|
172
|
-
insertAfter(existingValue: T, newValue: T): boolean;
|
|
148
|
+
insertBefore(existingValue: SinglyLinkedListNode<T>, newValue: T): boolean;
|
|
149
|
+
insertAfter(existingValueOrNode: T, newValue: T): boolean;
|
|
150
|
+
insertAfter(existingValueOrNode: SinglyLinkedListNode<T>, newValue: T): boolean;
|
|
173
151
|
/**
|
|
174
152
|
* The function counts the number of occurrences of a given value in a linked list.
|
|
175
153
|
* @param {T} value - The value parameter is the value that you want to count the occurrences of in the linked list.
|
|
@@ -257,16 +257,21 @@ var SinglyLinkedList = /** @class */ (function () {
|
|
|
257
257
|
return removedNode.val;
|
|
258
258
|
};
|
|
259
259
|
/**
|
|
260
|
-
* The
|
|
261
|
-
*
|
|
262
|
-
*
|
|
263
|
-
*
|
|
264
|
-
*
|
|
265
|
-
* the linked list, and `false` if the value was not found in the linked list.
|
|
260
|
+
* The delete function removes a node with a specific value from a singly linked list.
|
|
261
|
+
* @param {T | SinglyLinkedListNode<T>} valueOrNode - The `valueOrNode` parameter can accept either a value of type `T`
|
|
262
|
+
* or a `SinglyLinkedListNode<T>` object.
|
|
263
|
+
* @returns The `delete` method returns a boolean value. It returns `true` if the value or node is found and
|
|
264
|
+
* successfully deleted from the linked list, and `false` if the value or node is not found in the linked list.
|
|
266
265
|
*/
|
|
267
|
-
SinglyLinkedList.prototype.delete = function (
|
|
268
|
-
var
|
|
269
|
-
|
|
266
|
+
SinglyLinkedList.prototype.delete = function (valueOrNode) {
|
|
267
|
+
var value;
|
|
268
|
+
if (valueOrNode instanceof (SinglyLinkedListNode)) {
|
|
269
|
+
value = valueOrNode.val;
|
|
270
|
+
}
|
|
271
|
+
else {
|
|
272
|
+
value = valueOrNode;
|
|
273
|
+
}
|
|
274
|
+
var current = this.head, prev = null;
|
|
270
275
|
while (current) {
|
|
271
276
|
if (current.val === value) {
|
|
272
277
|
if (prev === null) {
|
|
@@ -290,7 +295,7 @@ var SinglyLinkedList = /** @class */ (function () {
|
|
|
290
295
|
return false;
|
|
291
296
|
};
|
|
292
297
|
/**
|
|
293
|
-
* The `
|
|
298
|
+
* The `insertAt` function inserts a value at a specified index in a singly linked list.
|
|
294
299
|
* @param {number} index - The index parameter represents the position at which the new value should be inserted in the
|
|
295
300
|
* linked list. It is of type number.
|
|
296
301
|
* @param {T} val - The `val` parameter represents the value that you want to insert into the linked list at the
|
|
@@ -298,7 +303,7 @@ var SinglyLinkedList = /** @class */ (function () {
|
|
|
298
303
|
* @returns The `insert` method returns a boolean value. It returns `true` if the insertion is successful, and `false`
|
|
299
304
|
* if the index is out of bounds.
|
|
300
305
|
*/
|
|
301
|
-
SinglyLinkedList.prototype.
|
|
306
|
+
SinglyLinkedList.prototype.insertAt = function (index, val) {
|
|
302
307
|
if (index < 0 || index > this.length)
|
|
303
308
|
return false;
|
|
304
309
|
if (index === 0) {
|
|
@@ -418,16 +423,21 @@ var SinglyLinkedList = /** @class */ (function () {
|
|
|
418
423
|
};
|
|
419
424
|
/**
|
|
420
425
|
* The `insertBefore` function inserts a new value before an existing value in a singly linked list.
|
|
421
|
-
* @param {T}
|
|
422
|
-
*
|
|
426
|
+
* @param {T | SinglyLinkedListNode<T>} existingValueOrNode - The existing value or node that you want to insert the
|
|
427
|
+
* new value before. It can be either the value itself or a node containing the value in the linked list.
|
|
423
428
|
* @param {T} newValue - The `newValue` parameter represents the value that you want to insert into the linked list.
|
|
424
|
-
* @returns The `insertBefore`
|
|
425
|
-
* inserted before the
|
|
426
|
-
* `existingValue` is not found in the linked list.
|
|
429
|
+
* @returns The method `insertBefore` returns a boolean value. It returns `true` if the new value was successfully
|
|
430
|
+
* inserted before the existing value, and `false` otherwise.
|
|
427
431
|
*/
|
|
428
|
-
SinglyLinkedList.prototype.insertBefore = function (
|
|
429
|
-
if (!this.head)
|
|
432
|
+
SinglyLinkedList.prototype.insertBefore = function (existingValueOrNode, newValue) {
|
|
433
|
+
if (!this.head)
|
|
430
434
|
return false;
|
|
435
|
+
var existingValue;
|
|
436
|
+
if (existingValueOrNode instanceof (SinglyLinkedListNode)) {
|
|
437
|
+
existingValue = existingValueOrNode.val;
|
|
438
|
+
}
|
|
439
|
+
else {
|
|
440
|
+
existingValue = existingValueOrNode;
|
|
431
441
|
}
|
|
432
442
|
if (this.head.val === existingValue) {
|
|
433
443
|
this.unshift(newValue);
|
|
@@ -447,15 +457,21 @@ var SinglyLinkedList = /** @class */ (function () {
|
|
|
447
457
|
return false;
|
|
448
458
|
};
|
|
449
459
|
/**
|
|
450
|
-
* The function inserts a new value after an existing
|
|
451
|
-
* @param {T}
|
|
452
|
-
*
|
|
453
|
-
*
|
|
454
|
-
* @returns The method
|
|
455
|
-
* existing value
|
|
460
|
+
* The `insertAfter` function inserts a new node with a given value after an existing node in a singly linked list.
|
|
461
|
+
* @param {T | SinglyLinkedListNode<T>} existingValueOrNode - The existing value or node in the linked list after which
|
|
462
|
+
* the new value will be inserted. It can be either the value of the existing node or the existing node itself.
|
|
463
|
+
* @param {T} newValue - The value that you want to insert into the linked list after the existing value or node.
|
|
464
|
+
* @returns The method returns a boolean value. It returns true if the new value was successfully inserted after the
|
|
465
|
+
* existing value or node, and false if the existing value or node was not found in the linked list.
|
|
456
466
|
*/
|
|
457
|
-
SinglyLinkedList.prototype.insertAfter = function (
|
|
458
|
-
var existingNode
|
|
467
|
+
SinglyLinkedList.prototype.insertAfter = function (existingValueOrNode, newValue) {
|
|
468
|
+
var existingNode;
|
|
469
|
+
if (existingValueOrNode instanceof SinglyLinkedListNode) {
|
|
470
|
+
existingNode = existingValueOrNode;
|
|
471
|
+
}
|
|
472
|
+
else {
|
|
473
|
+
existingNode = this.findNode(existingValueOrNode);
|
|
474
|
+
}
|
|
459
475
|
if (existingNode) {
|
|
460
476
|
var newNode = new SinglyLinkedListNode(newValue);
|
|
461
477
|
newNode.next = existingNode.next;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export declare class SkipLinkedList {
|
|
2
|
+
}
|
|
@@ -1,2 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SkipLinkedList = void 0;
|
|
4
|
+
var SkipLinkedList = /** @class */ (function () {
|
|
5
|
+
function SkipLinkedList() {
|
|
6
|
+
}
|
|
7
|
+
return SkipLinkedList;
|
|
8
|
+
}());
|
|
9
|
+
exports.SkipLinkedList = SkipLinkedList;
|
|
@@ -221,14 +221,14 @@ var Vector2D = /** @class */ (function () {
|
|
|
221
221
|
// * Transform vectors based on the current tranformation matrices: translation, rotation and scale
|
|
222
222
|
// * @param vectors The vectors to transform
|
|
223
223
|
// */
|
|
224
|
-
//
|
|
224
|
+
// static transform(vector: Vector2D, transformation: Matrix2D): Vector2D {
|
|
225
225
|
// return Matrix2D.multiplyByVector(transformation, vector)
|
|
226
226
|
// }
|
|
227
227
|
// /**
|
|
228
228
|
// * Transform vectors based on the current tranformation matrices: translation, rotation and scale
|
|
229
229
|
// * @param vectors The vectors to transform
|
|
230
230
|
// */
|
|
231
|
-
//
|
|
231
|
+
// static transformList(vectors: Vector2D[], transformation: Matrix2D): Vector2D[] {
|
|
232
232
|
// return vectors.map(vector => Matrix2D.multiplyByVector(transformation, vector))
|
|
233
233
|
// }
|
|
234
234
|
/**
|