data-structure-typed 1.17.4 → 1.18.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/dist/data-structures/binary-tree/avl-tree.js +4 -4
- package/dist/data-structures/binary-tree/binary-indexed-tree.d.ts +3 -1
- package/dist/data-structures/binary-tree/binary-indexed-tree.js +10 -0
- package/dist/data-structures/binary-tree/binary-tree.d.ts +41 -68
- package/dist/data-structures/binary-tree/binary-tree.js +126 -103
- package/dist/data-structures/binary-tree/bst.js +18 -19
- package/dist/data-structures/binary-tree/segment-tree.d.ts +17 -39
- package/dist/data-structures/binary-tree/segment-tree.js +34 -47
- package/dist/data-structures/graph/abstract-graph.d.ts +3 -16
- package/dist/data-structures/graph/abstract-graph.js +3 -24
- package/dist/data-structures/graph/directed-graph.d.ts +3 -11
- package/dist/data-structures/graph/directed-graph.js +2 -14
- package/dist/data-structures/graph/undirected-graph.d.ts +1 -5
- package/dist/data-structures/graph/undirected-graph.js +3 -9
- package/dist/data-structures/hash/coordinate-map.d.ts +1 -5
- package/dist/data-structures/hash/coordinate-map.js +3 -9
- package/dist/data-structures/hash/coordinate-set.d.ts +1 -5
- package/dist/data-structures/hash/coordinate-set.js +3 -9
- package/dist/data-structures/hash/hash-table.d.ts +2 -1
- package/dist/data-structures/hash/hash-table.js +7 -0
- package/dist/data-structures/hash/pair.d.ts +2 -1
- package/dist/data-structures/hash/pair.js +7 -0
- package/dist/data-structures/hash/tree-map.d.ts +2 -1
- package/dist/data-structures/hash/tree-map.js +7 -0
- package/dist/data-structures/hash/tree-set.d.ts +2 -1
- package/dist/data-structures/hash/tree-set.js +7 -0
- package/dist/data-structures/heap/heap.d.ts +0 -14
- package/dist/data-structures/heap/heap.js +3 -27
- package/dist/data-structures/linked-list/doubly-linked-list.d.ts +0 -2
- package/dist/data-structures/linked-list/doubly-linked-list.js +12 -18
- package/dist/data-structures/linked-list/singly-linked-list.d.ts +0 -1
- package/dist/data-structures/linked-list/singly-linked-list.js +12 -15
- package/dist/data-structures/tree/tree.d.ts +12 -4
- package/dist/data-structures/tree/tree.js +44 -12
- package/dist/data-structures/trie/trie.d.ts +3 -3
- package/dist/data-structures/trie/trie.js +10 -10
- package/dist/data-structures/types/doubly-linked-list.d.ts +1 -1
- package/docs/assets/search.js +1 -1
- package/docs/classes/AVLTree.html +370 -224
- package/docs/classes/AVLTreeNode.html +24 -202
- package/docs/classes/AaTree.html +5 -2
- package/docs/classes/AbstractEdge.html +32 -57
- package/docs/classes/AbstractGraph.html +35 -32
- package/docs/classes/AbstractVertex.html +10 -25
- package/docs/classes/ArrayDeque.html +18 -15
- package/docs/classes/BST.html +363 -217
- package/docs/classes/BSTNode.html +24 -202
- package/docs/classes/BTree.html +5 -2
- package/docs/classes/BinaryIndexedTree.html +43 -10
- package/docs/classes/BinaryTree.html +385 -182
- package/docs/classes/BinaryTreeNode.html +64 -165
- package/docs/classes/Character.html +8 -5
- package/docs/classes/CoordinateMap.html +36 -41
- package/docs/classes/CoordinateSet.html +35 -40
- package/docs/classes/Deque.html +38 -57
- package/docs/classes/DirectedEdge.html +44 -82
- package/docs/classes/DirectedGraph.html +50 -47
- package/docs/classes/DirectedVertex.html +10 -26
- package/docs/classes/DoublyLinkedList.html +41 -58
- package/docs/classes/DoublyLinkedListNode.html +15 -12
- package/docs/classes/HashTable.html +153 -0
- package/docs/classes/Heap.html +19 -97
- package/docs/classes/HeapItem.html +12 -9
- package/docs/classes/Matrix2D.html +20 -17
- package/docs/classes/MatrixNTI2D.html +8 -5
- package/docs/classes/MaxHeap.html +19 -102
- package/docs/classes/MaxPriorityQueue.html +38 -35
- package/docs/classes/MinHeap.html +19 -102
- package/docs/classes/MinPriorityQueue.html +38 -35
- package/docs/classes/Navigator.html +14 -11
- package/docs/classes/ObjectDeque.html +29 -26
- package/docs/classes/Pair.html +153 -0
- package/docs/classes/PriorityQueue.html +36 -33
- package/docs/classes/Queue.html +18 -15
- package/docs/classes/RBTree.html +5 -2
- package/docs/classes/SegmentTree.html +116 -46
- package/docs/classes/SegmentTreeNode.html +49 -129
- package/docs/classes/SinglyLinkedList.html +38 -45
- package/docs/classes/SinglyLinkedListNode.html +12 -9
- package/docs/classes/SkipLinkedList.html +5 -2
- package/docs/classes/SplayTree.html +5 -2
- package/docs/classes/Stack.html +16 -13
- package/docs/classes/TreeMap.html +153 -0
- package/docs/classes/TreeMultiSet.html +363 -217
- package/docs/classes/TreeNode.html +112 -24
- package/docs/classes/TreeSet.html +153 -0
- package/docs/classes/Trie.html +17 -14
- package/docs/classes/TrieNode.html +20 -17
- package/docs/classes/TwoThreeTree.html +5 -2
- package/docs/classes/UndirectedEdge.html +44 -56
- package/docs/classes/UndirectedGraph.html +49 -54
- package/docs/classes/UndirectedVertex.html +10 -26
- package/docs/classes/Vector2D.html +32 -29
- package/docs/enums/CP.html +8 -5
- package/docs/enums/FamilyPosition.html +8 -5
- package/docs/enums/LoopType.html +7 -4
- package/docs/index.html +8 -1
- package/docs/interfaces/AVLTreeDeleted.html +7 -4
- package/docs/interfaces/HeapOptions.html +6 -3
- package/docs/interfaces/IDirectedGraph.html +11 -8
- package/docs/interfaces/IGraph.html +23 -20
- package/docs/interfaces/NavigatorParams.html +9 -6
- package/docs/interfaces/PriorityQueueOptions.html +8 -5
- package/docs/modules.html +8 -2
- package/docs/types/BSTComparator.html +5 -2
- package/docs/types/BSTDeletedResult.html +5 -2
- package/docs/types/BinaryTreeDeleted.html +5 -2
- package/docs/types/BinaryTreeNodeId.html +5 -2
- package/docs/types/BinaryTreeNodePropertyName.html +5 -2
- package/docs/types/DFSOrderPattern.html +5 -2
- package/docs/types/DijkstraResult.html +5 -2
- package/docs/types/Direction.html +5 -2
- package/docs/types/NodeOrPropertyName.html +5 -2
- package/docs/types/PriorityQueueComparator.html +5 -2
- package/docs/types/PriorityQueueDFSOrderPattern.html +5 -2
- package/docs/types/ResultByProperty.html +5 -2
- package/docs/types/ResultsByProperty.html +5 -2
- package/docs/types/SegmentTreeNodeVal.html +5 -2
- package/docs/types/SpecifyOptional.html +5 -2
- package/docs/types/Thunk.html +5 -2
- package/docs/types/ToThunkFn.html +5 -2
- package/docs/types/TopologicalStatus.html +5 -2
- package/docs/types/TreeMultiSetDeletedResult.html +5 -2
- package/docs/types/TrlAsyncFn.html +5 -2
- package/docs/types/TrlFn.html +5 -2
- package/docs/types/Turning.html +5 -2
- package/docs/types/VertexId.html +5 -2
- package/notes/note.md +5 -1
- package/package.json +2 -2
- package/tsconfig.json +2 -2
- package/docs/types/DoublyLinkedListGetBy.html +0 -125
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export declare class TreeMap {
|
|
2
|
+
}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export declare class TreeSet {
|
|
2
|
+
}
|
|
@@ -25,27 +25,13 @@ export declare abstract class Heap<T = number> {
|
|
|
25
25
|
protected constructor(options?: HeapOptions<T>);
|
|
26
26
|
protected abstract _pq: PriorityQueue<HeapItem<T>>;
|
|
27
27
|
get pq(): PriorityQueue<HeapItem<T>>;
|
|
28
|
-
protected set pq(v: PriorityQueue<HeapItem<T>>);
|
|
29
28
|
protected _priorityCb: (val: T) => number;
|
|
30
29
|
get priorityCb(): (val: T) => number;
|
|
31
|
-
protected set priorityCb(v: (val: T) => number);
|
|
32
30
|
/**
|
|
33
31
|
* The function returns the size of a priority queue.
|
|
34
32
|
* @returns The size of the priority queue.
|
|
35
33
|
*/
|
|
36
34
|
get size(): number;
|
|
37
|
-
/**
|
|
38
|
-
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
|
|
39
|
-
*/
|
|
40
|
-
getPq(): PriorityQueue<HeapItem<T>>;
|
|
41
|
-
/**
|
|
42
|
-
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
|
|
43
|
-
*/
|
|
44
|
-
getPriorityCb(): (val: T) => number;
|
|
45
|
-
/**
|
|
46
|
-
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
|
|
47
|
-
*/
|
|
48
|
-
getSize(): number;
|
|
49
35
|
/**
|
|
50
36
|
* The function checks if a priority queue is empty.
|
|
51
37
|
* @returns {boolean} A boolean value indicating whether the size of the priority queue is less than 1.
|
|
@@ -53,9 +53,6 @@ var Heap = /** @class */ (function () {
|
|
|
53
53
|
get: function () {
|
|
54
54
|
return this._pq;
|
|
55
55
|
},
|
|
56
|
-
set: function (v) {
|
|
57
|
-
this._pq = v;
|
|
58
|
-
},
|
|
59
56
|
enumerable: false,
|
|
60
57
|
configurable: true
|
|
61
58
|
});
|
|
@@ -63,9 +60,6 @@ var Heap = /** @class */ (function () {
|
|
|
63
60
|
get: function () {
|
|
64
61
|
return this._priorityCb;
|
|
65
62
|
},
|
|
66
|
-
set: function (v) {
|
|
67
|
-
this._priorityCb = v;
|
|
68
|
-
},
|
|
69
63
|
enumerable: false,
|
|
70
64
|
configurable: true
|
|
71
65
|
});
|
|
@@ -80,24 +74,6 @@ var Heap = /** @class */ (function () {
|
|
|
80
74
|
enumerable: false,
|
|
81
75
|
configurable: true
|
|
82
76
|
});
|
|
83
|
-
/**
|
|
84
|
-
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
|
|
85
|
-
*/
|
|
86
|
-
Heap.prototype.getPq = function () {
|
|
87
|
-
return this._pq;
|
|
88
|
-
};
|
|
89
|
-
/**
|
|
90
|
-
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
|
|
91
|
-
*/
|
|
92
|
-
Heap.prototype.getPriorityCb = function () {
|
|
93
|
-
return this._priorityCb;
|
|
94
|
-
};
|
|
95
|
-
/**
|
|
96
|
-
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
|
|
97
|
-
*/
|
|
98
|
-
Heap.prototype.getSize = function () {
|
|
99
|
-
return this._pq.size;
|
|
100
|
-
};
|
|
101
77
|
/**
|
|
102
78
|
* The function checks if a priority queue is empty.
|
|
103
79
|
* @returns {boolean} A boolean value indicating whether the size of the priority queue is less than 1.
|
|
@@ -166,11 +142,11 @@ var Heap = /** @class */ (function () {
|
|
|
166
142
|
* @returns a boolean value.
|
|
167
143
|
*/
|
|
168
144
|
Heap.prototype.has = function (node) {
|
|
169
|
-
if (node instanceof
|
|
170
|
-
return this.
|
|
145
|
+
if (node instanceof HeapItem) {
|
|
146
|
+
return this.pq.getNodes().includes(node);
|
|
171
147
|
}
|
|
172
148
|
else {
|
|
173
|
-
return this.
|
|
149
|
+
return this.pq.getNodes().findIndex(function (item) {
|
|
174
150
|
return item.val === node;
|
|
175
151
|
}) !== -1;
|
|
176
152
|
}
|
|
@@ -35,7 +35,6 @@ export declare class DoublyLinkedList<T> {
|
|
|
35
35
|
set tail(value: DoublyLinkedListNode<T> | null);
|
|
36
36
|
private _length;
|
|
37
37
|
get length(): number;
|
|
38
|
-
protected set length(value: number);
|
|
39
38
|
/**
|
|
40
39
|
* The `fromArray` function creates a new instance of a DoublyLinkedList and populates it with the elements from the
|
|
41
40
|
* given array.
|
|
@@ -43,7 +42,6 @@ export declare class DoublyLinkedList<T> {
|
|
|
43
42
|
* @returns The `fromArray` function returns a DoublyLinkedList object.
|
|
44
43
|
*/
|
|
45
44
|
static fromArray<T>(data: T[]): DoublyLinkedList<T>;
|
|
46
|
-
getLength(): number;
|
|
47
45
|
/**
|
|
48
46
|
* The push function adds a new node with the given value to the end of the doubly linked list.
|
|
49
47
|
* @param {T} val - The value to be added to the linked list.
|
|
@@ -112,9 +112,6 @@ var DoublyLinkedList = /** @class */ (function () {
|
|
|
112
112
|
get: function () {
|
|
113
113
|
return this._length;
|
|
114
114
|
},
|
|
115
|
-
set: function (value) {
|
|
116
|
-
this._length = value;
|
|
117
|
-
},
|
|
118
115
|
enumerable: false,
|
|
119
116
|
configurable: true
|
|
120
117
|
});
|
|
@@ -142,9 +139,6 @@ var DoublyLinkedList = /** @class */ (function () {
|
|
|
142
139
|
}
|
|
143
140
|
return doublyLinkedList;
|
|
144
141
|
};
|
|
145
|
-
DoublyLinkedList.prototype.getLength = function () {
|
|
146
|
-
return this._length;
|
|
147
|
-
};
|
|
148
142
|
/**
|
|
149
143
|
* The push function adds a new node with the given value to the end of the doubly linked list.
|
|
150
144
|
* @param {T} val - The value to be added to the linked list.
|
|
@@ -160,7 +154,7 @@ var DoublyLinkedList = /** @class */ (function () {
|
|
|
160
154
|
this.tail.next = newNode;
|
|
161
155
|
this.tail = newNode;
|
|
162
156
|
}
|
|
163
|
-
this.
|
|
157
|
+
this._length++;
|
|
164
158
|
};
|
|
165
159
|
/**
|
|
166
160
|
* The `pop()` function removes and returns the value of the last node in a doubly linked list.
|
|
@@ -179,7 +173,7 @@ var DoublyLinkedList = /** @class */ (function () {
|
|
|
179
173
|
this.tail = removedNode.prev;
|
|
180
174
|
this.tail.next = null;
|
|
181
175
|
}
|
|
182
|
-
this.
|
|
176
|
+
this._length--;
|
|
183
177
|
return removedNode.val;
|
|
184
178
|
};
|
|
185
179
|
/**
|
|
@@ -199,7 +193,7 @@ var DoublyLinkedList = /** @class */ (function () {
|
|
|
199
193
|
this.head = removedNode.next;
|
|
200
194
|
this.head.prev = null;
|
|
201
195
|
}
|
|
202
|
-
this.
|
|
196
|
+
this._length--;
|
|
203
197
|
return removedNode.val;
|
|
204
198
|
};
|
|
205
199
|
/**
|
|
@@ -218,7 +212,7 @@ var DoublyLinkedList = /** @class */ (function () {
|
|
|
218
212
|
this.head.prev = newNode;
|
|
219
213
|
this.head = newNode;
|
|
220
214
|
}
|
|
221
|
-
this.
|
|
215
|
+
this._length++;
|
|
222
216
|
};
|
|
223
217
|
/**
|
|
224
218
|
* The `getAt` function returns the value at a specified index in a linked list, or null if the index is out of bounds.
|
|
@@ -297,7 +291,7 @@ var DoublyLinkedList = /** @class */ (function () {
|
|
|
297
291
|
newNode.next = nextNode;
|
|
298
292
|
prevNode.next = newNode;
|
|
299
293
|
nextNode.prev = newNode;
|
|
300
|
-
this.
|
|
294
|
+
this._length++;
|
|
301
295
|
return true;
|
|
302
296
|
};
|
|
303
297
|
/**
|
|
@@ -319,7 +313,7 @@ var DoublyLinkedList = /** @class */ (function () {
|
|
|
319
313
|
var nextNode = removedNode.next;
|
|
320
314
|
prevNode.next = nextNode;
|
|
321
315
|
nextNode.prev = prevNode;
|
|
322
|
-
this.
|
|
316
|
+
this._length--;
|
|
323
317
|
return removedNode.val;
|
|
324
318
|
};
|
|
325
319
|
/**
|
|
@@ -331,7 +325,7 @@ var DoublyLinkedList = /** @class */ (function () {
|
|
|
331
325
|
*/
|
|
332
326
|
DoublyLinkedList.prototype.delete = function (valOrNode) {
|
|
333
327
|
var node;
|
|
334
|
-
if (valOrNode instanceof
|
|
328
|
+
if (valOrNode instanceof DoublyLinkedListNode) {
|
|
335
329
|
node = valOrNode;
|
|
336
330
|
}
|
|
337
331
|
else {
|
|
@@ -349,7 +343,7 @@ var DoublyLinkedList = /** @class */ (function () {
|
|
|
349
343
|
var nextNode = node.next;
|
|
350
344
|
prevNode.next = nextNode;
|
|
351
345
|
nextNode.prev = prevNode;
|
|
352
|
-
this.
|
|
346
|
+
this._length--;
|
|
353
347
|
}
|
|
354
348
|
return true;
|
|
355
349
|
}
|
|
@@ -536,7 +530,7 @@ var DoublyLinkedList = /** @class */ (function () {
|
|
|
536
530
|
*/
|
|
537
531
|
DoublyLinkedList.prototype.insertAfter = function (existingValueOrNode, newValue) {
|
|
538
532
|
var existingNode;
|
|
539
|
-
if (existingValueOrNode instanceof
|
|
533
|
+
if (existingValueOrNode instanceof DoublyLinkedListNode) {
|
|
540
534
|
existingNode = existingValueOrNode;
|
|
541
535
|
}
|
|
542
536
|
else {
|
|
@@ -553,7 +547,7 @@ var DoublyLinkedList = /** @class */ (function () {
|
|
|
553
547
|
if (existingNode === this.tail) {
|
|
554
548
|
this.tail = newNode;
|
|
555
549
|
}
|
|
556
|
-
this.
|
|
550
|
+
this._length++;
|
|
557
551
|
return true;
|
|
558
552
|
}
|
|
559
553
|
return false;
|
|
@@ -570,7 +564,7 @@ var DoublyLinkedList = /** @class */ (function () {
|
|
|
570
564
|
*/
|
|
571
565
|
DoublyLinkedList.prototype.insertBefore = function (existingValueOrNode, newValue) {
|
|
572
566
|
var existingNode;
|
|
573
|
-
if (existingValueOrNode instanceof
|
|
567
|
+
if (existingValueOrNode instanceof DoublyLinkedListNode) {
|
|
574
568
|
existingNode = existingValueOrNode;
|
|
575
569
|
}
|
|
576
570
|
else {
|
|
@@ -587,7 +581,7 @@ var DoublyLinkedList = /** @class */ (function () {
|
|
|
587
581
|
if (existingNode === this.head) {
|
|
588
582
|
this.head = newNode;
|
|
589
583
|
}
|
|
590
|
-
this.
|
|
584
|
+
this._length++;
|
|
591
585
|
return true;
|
|
592
586
|
}
|
|
593
587
|
return false;
|
|
@@ -32,7 +32,6 @@ export declare class SinglyLinkedList<T> {
|
|
|
32
32
|
set tail(value: SinglyLinkedListNode<T> | null);
|
|
33
33
|
private _length;
|
|
34
34
|
get length(): number;
|
|
35
|
-
protected set length(value: number);
|
|
36
35
|
/**
|
|
37
36
|
* The `fromArray` function creates a new SinglyLinkedList instance and populates it with the elements from the given
|
|
38
37
|
* array.
|
|
@@ -101,9 +101,6 @@ var SinglyLinkedList = /** @class */ (function () {
|
|
|
101
101
|
get: function () {
|
|
102
102
|
return this._length;
|
|
103
103
|
},
|
|
104
|
-
set: function (value) {
|
|
105
|
-
this._length = value;
|
|
106
|
-
},
|
|
107
104
|
enumerable: false,
|
|
108
105
|
configurable: true
|
|
109
106
|
});
|
|
@@ -149,7 +146,7 @@ var SinglyLinkedList = /** @class */ (function () {
|
|
|
149
146
|
this.tail.next = newNode;
|
|
150
147
|
this.tail = newNode;
|
|
151
148
|
}
|
|
152
|
-
this.
|
|
149
|
+
this._length++;
|
|
153
150
|
};
|
|
154
151
|
/**
|
|
155
152
|
* The `pop()` function removes and returns the value of the last element in a linked list, updating the head and tail
|
|
@@ -164,7 +161,7 @@ var SinglyLinkedList = /** @class */ (function () {
|
|
|
164
161
|
var val_1 = this.head.val;
|
|
165
162
|
this.head = null;
|
|
166
163
|
this.tail = null;
|
|
167
|
-
this.
|
|
164
|
+
this._length--;
|
|
168
165
|
return val_1;
|
|
169
166
|
}
|
|
170
167
|
var current = this.head;
|
|
@@ -174,7 +171,7 @@ var SinglyLinkedList = /** @class */ (function () {
|
|
|
174
171
|
var val = this.tail.val;
|
|
175
172
|
current.next = null;
|
|
176
173
|
this.tail = current;
|
|
177
|
-
this.
|
|
174
|
+
this._length--;
|
|
178
175
|
return val;
|
|
179
176
|
};
|
|
180
177
|
/**
|
|
@@ -186,7 +183,7 @@ var SinglyLinkedList = /** @class */ (function () {
|
|
|
186
183
|
return null;
|
|
187
184
|
var removedNode = this.head;
|
|
188
185
|
this.head = this.head.next;
|
|
189
|
-
this.
|
|
186
|
+
this._length--;
|
|
190
187
|
return removedNode.val;
|
|
191
188
|
};
|
|
192
189
|
/**
|
|
@@ -204,7 +201,7 @@ var SinglyLinkedList = /** @class */ (function () {
|
|
|
204
201
|
newNode.next = this.head;
|
|
205
202
|
this.head = newNode;
|
|
206
203
|
}
|
|
207
|
-
this.
|
|
204
|
+
this._length++;
|
|
208
205
|
};
|
|
209
206
|
/**
|
|
210
207
|
* The function `getAt` returns the value at a specified index in a linked list, or null if the index is out of range.
|
|
@@ -253,7 +250,7 @@ var SinglyLinkedList = /** @class */ (function () {
|
|
|
253
250
|
var prevNode = this.getNodeAt(index - 1);
|
|
254
251
|
var removedNode = prevNode.next;
|
|
255
252
|
prevNode.next = removedNode.next;
|
|
256
|
-
this.
|
|
253
|
+
this._length--;
|
|
257
254
|
return removedNode.val;
|
|
258
255
|
};
|
|
259
256
|
/**
|
|
@@ -265,7 +262,7 @@ var SinglyLinkedList = /** @class */ (function () {
|
|
|
265
262
|
*/
|
|
266
263
|
SinglyLinkedList.prototype.delete = function (valueOrNode) {
|
|
267
264
|
var value;
|
|
268
|
-
if (valueOrNode instanceof
|
|
265
|
+
if (valueOrNode instanceof SinglyLinkedListNode) {
|
|
269
266
|
value = valueOrNode.val;
|
|
270
267
|
}
|
|
271
268
|
else {
|
|
@@ -286,7 +283,7 @@ var SinglyLinkedList = /** @class */ (function () {
|
|
|
286
283
|
this.tail = prev;
|
|
287
284
|
}
|
|
288
285
|
}
|
|
289
|
-
this.
|
|
286
|
+
this._length--;
|
|
290
287
|
return true;
|
|
291
288
|
}
|
|
292
289
|
prev = current;
|
|
@@ -318,7 +315,7 @@ var SinglyLinkedList = /** @class */ (function () {
|
|
|
318
315
|
var prevNode = this.getNodeAt(index - 1);
|
|
319
316
|
newNode.next = prevNode.next;
|
|
320
317
|
prevNode.next = newNode;
|
|
321
|
-
this.
|
|
318
|
+
this._length++;
|
|
322
319
|
return true;
|
|
323
320
|
};
|
|
324
321
|
/**
|
|
@@ -433,7 +430,7 @@ var SinglyLinkedList = /** @class */ (function () {
|
|
|
433
430
|
if (!this.head)
|
|
434
431
|
return false;
|
|
435
432
|
var existingValue;
|
|
436
|
-
if (existingValueOrNode instanceof
|
|
433
|
+
if (existingValueOrNode instanceof SinglyLinkedListNode) {
|
|
437
434
|
existingValue = existingValueOrNode.val;
|
|
438
435
|
}
|
|
439
436
|
else {
|
|
@@ -449,7 +446,7 @@ var SinglyLinkedList = /** @class */ (function () {
|
|
|
449
446
|
var newNode = new SinglyLinkedListNode(newValue);
|
|
450
447
|
newNode.next = current.next;
|
|
451
448
|
current.next = newNode;
|
|
452
|
-
this.
|
|
449
|
+
this._length++;
|
|
453
450
|
return true;
|
|
454
451
|
}
|
|
455
452
|
current = current.next;
|
|
@@ -479,7 +476,7 @@ var SinglyLinkedList = /** @class */ (function () {
|
|
|
479
476
|
if (existingNode === this.tail) {
|
|
480
477
|
this.tail = newNode;
|
|
481
478
|
}
|
|
482
|
-
this.
|
|
479
|
+
this._length++;
|
|
483
480
|
return true;
|
|
484
481
|
}
|
|
485
482
|
return false;
|
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
export declare class TreeNode<T = number> {
|
|
2
|
-
id: string;
|
|
3
|
-
name?: string | undefined;
|
|
4
|
-
value?: T | undefined;
|
|
5
|
-
children?: TreeNode<T>[] | undefined;
|
|
6
2
|
constructor(id: string, name?: string, value?: T, children?: TreeNode<T>[]);
|
|
3
|
+
private _id;
|
|
4
|
+
get id(): string;
|
|
5
|
+
set id(value: string);
|
|
6
|
+
private _name?;
|
|
7
|
+
get name(): string | undefined;
|
|
8
|
+
set name(value: string | undefined);
|
|
9
|
+
private _value?;
|
|
10
|
+
get value(): T | undefined;
|
|
11
|
+
set value(value: T | undefined);
|
|
12
|
+
private _children?;
|
|
13
|
+
get children(): TreeNode<T>[] | undefined;
|
|
14
|
+
set children(value: TreeNode<T>[] | undefined);
|
|
7
15
|
addChildren(children: TreeNode<T> | TreeNode<T>[]): void;
|
|
8
16
|
getHeight(): number;
|
|
9
17
|
}
|
|
@@ -3,19 +3,51 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.TreeNode = void 0;
|
|
4
4
|
var TreeNode = /** @class */ (function () {
|
|
5
5
|
function TreeNode(id, name, value, children) {
|
|
6
|
-
this.
|
|
7
|
-
this.
|
|
8
|
-
this.
|
|
9
|
-
this.
|
|
6
|
+
this._id = id;
|
|
7
|
+
this._name = name || '';
|
|
8
|
+
this._value = value || undefined;
|
|
9
|
+
this._children = children || [];
|
|
10
10
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
11
|
+
Object.defineProperty(TreeNode.prototype, "id", {
|
|
12
|
+
get: function () {
|
|
13
|
+
return this._id;
|
|
14
|
+
},
|
|
15
|
+
set: function (value) {
|
|
16
|
+
this._id = value;
|
|
17
|
+
},
|
|
18
|
+
enumerable: false,
|
|
19
|
+
configurable: true
|
|
20
|
+
});
|
|
21
|
+
Object.defineProperty(TreeNode.prototype, "name", {
|
|
22
|
+
get: function () {
|
|
23
|
+
return this._name;
|
|
24
|
+
},
|
|
25
|
+
set: function (value) {
|
|
26
|
+
this._name = value;
|
|
27
|
+
},
|
|
28
|
+
enumerable: false,
|
|
29
|
+
configurable: true
|
|
30
|
+
});
|
|
31
|
+
Object.defineProperty(TreeNode.prototype, "value", {
|
|
32
|
+
get: function () {
|
|
33
|
+
return this._value;
|
|
34
|
+
},
|
|
35
|
+
set: function (value) {
|
|
36
|
+
this._value = value;
|
|
37
|
+
},
|
|
38
|
+
enumerable: false,
|
|
39
|
+
configurable: true
|
|
40
|
+
});
|
|
41
|
+
Object.defineProperty(TreeNode.prototype, "children", {
|
|
42
|
+
get: function () {
|
|
43
|
+
return this._children;
|
|
44
|
+
},
|
|
45
|
+
set: function (value) {
|
|
46
|
+
this._children = value;
|
|
47
|
+
},
|
|
48
|
+
enumerable: false,
|
|
49
|
+
configurable: true
|
|
50
|
+
});
|
|
19
51
|
TreeNode.prototype.addChildren = function (children) {
|
|
20
52
|
if (!this.children) {
|
|
21
53
|
this.children = [];
|
|
@@ -6,16 +6,16 @@
|
|
|
6
6
|
* @license MIT License
|
|
7
7
|
*/
|
|
8
8
|
export declare class TrieNode {
|
|
9
|
-
protected _value: string;
|
|
10
9
|
constructor(v: string);
|
|
10
|
+
private _val;
|
|
11
|
+
get val(): string;
|
|
12
|
+
set val(v: string);
|
|
11
13
|
protected _children: Map<string, TrieNode>;
|
|
12
14
|
get children(): Map<string, TrieNode>;
|
|
13
15
|
set children(v: Map<string, TrieNode>);
|
|
14
16
|
protected _isEnd: boolean;
|
|
15
17
|
get isEnd(): boolean;
|
|
16
18
|
set isEnd(v: boolean);
|
|
17
|
-
get val(): string;
|
|
18
|
-
set val(v: string);
|
|
19
19
|
}
|
|
20
20
|
export declare class Trie {
|
|
21
21
|
constructor(words?: string[]);
|
|
@@ -21,36 +21,36 @@ exports.Trie = exports.TrieNode = void 0;
|
|
|
21
21
|
*/
|
|
22
22
|
var TrieNode = /** @class */ (function () {
|
|
23
23
|
function TrieNode(v) {
|
|
24
|
-
this.
|
|
24
|
+
this._val = v;
|
|
25
25
|
this._isEnd = false;
|
|
26
26
|
this._children = new Map();
|
|
27
27
|
}
|
|
28
|
-
Object.defineProperty(TrieNode.prototype, "
|
|
28
|
+
Object.defineProperty(TrieNode.prototype, "val", {
|
|
29
29
|
get: function () {
|
|
30
|
-
return this.
|
|
30
|
+
return this._val;
|
|
31
31
|
},
|
|
32
32
|
set: function (v) {
|
|
33
|
-
this.
|
|
33
|
+
this._val = v;
|
|
34
34
|
},
|
|
35
35
|
enumerable: false,
|
|
36
36
|
configurable: true
|
|
37
37
|
});
|
|
38
|
-
Object.defineProperty(TrieNode.prototype, "
|
|
38
|
+
Object.defineProperty(TrieNode.prototype, "children", {
|
|
39
39
|
get: function () {
|
|
40
|
-
return this.
|
|
40
|
+
return this._children;
|
|
41
41
|
},
|
|
42
42
|
set: function (v) {
|
|
43
|
-
this.
|
|
43
|
+
this._children = v;
|
|
44
44
|
},
|
|
45
45
|
enumerable: false,
|
|
46
46
|
configurable: true
|
|
47
47
|
});
|
|
48
|
-
Object.defineProperty(TrieNode.prototype, "
|
|
48
|
+
Object.defineProperty(TrieNode.prototype, "isEnd", {
|
|
49
49
|
get: function () {
|
|
50
|
-
return this.
|
|
50
|
+
return this._isEnd;
|
|
51
51
|
},
|
|
52
52
|
set: function (v) {
|
|
53
|
-
this.
|
|
53
|
+
this._isEnd = v;
|
|
54
54
|
},
|
|
55
55
|
enumerable: false,
|
|
56
56
|
configurable: true
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export {};
|