@stimulcross/ds-doubly-linked-list 0.0.1 → 0.1.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 +11 -1
- package/lib/addressable-doubly-linked-list.d.ts +129 -0
- package/lib/addressable-doubly-linked-list.d.ts.map +1 -0
- package/lib/addressable-doubly-linked-list.js +199 -0
- package/lib/addressable-doubly-linked-list.js.map +1 -0
- package/lib/doubly-linked-list.d.ts.map +1 -0
- package/lib/doubly-linked-list.js +17 -29
- package/lib/doubly-linked-list.js.map +1 -0
- package/lib/doubly-linked-node.d.ts.map +1 -0
- package/lib/doubly-linked-node.js.map +1 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -0
- package/package.json +56 -55
package/README.md
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
1
|
# Doubly Linked List
|
|
2
2
|
|
|
3
|
-
A doubly linked list
|
|
3
|
+
A TypeScript package with two doubly linked list implementations.
|
|
4
|
+
|
|
5
|
+
- `DoublyLinkedList` provides the standard list API, including indexed access
|
|
6
|
+
and value-based search and removal.
|
|
7
|
+
- `AddressableDoublyLinkedList` returns a unique handle for each insertion.
|
|
8
|
+
Insert at either end, remove from either end, or remove a specific entry by
|
|
9
|
+
handle in O(1). Duplicate values can be removed independently.
|
|
10
|
+
|
|
11
|
+
The addressable list keeps an index of live nodes and detaches removed nodes.
|
|
12
|
+
Its `clear()` invalidates handles and takes O(n). Its iterators support removing
|
|
13
|
+
the entry just yielded, then continue with its former successor.
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
declare const handleBrand: unique symbol;
|
|
2
|
+
/**
|
|
3
|
+
* Identifies one insertion into an {@link AddressableDoublyLinkedList}.
|
|
4
|
+
*/
|
|
5
|
+
export type DoublyLinkedListHandle = symbol & {
|
|
6
|
+
readonly [handleBrand]: true;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Doubly linked list with constant-time removal by handle.
|
|
10
|
+
*
|
|
11
|
+
* Each insertion receives a distinct handle, including insertions of duplicate
|
|
12
|
+
* values. Removed nodes are disconnected from their neighbors.
|
|
13
|
+
*
|
|
14
|
+
* @template T The type of values stored in the list.
|
|
15
|
+
*/
|
|
16
|
+
export declare class AddressableDoublyLinkedList<T = unknown> {
|
|
17
|
+
private _head;
|
|
18
|
+
private _tail;
|
|
19
|
+
private _nodes;
|
|
20
|
+
/**
|
|
21
|
+
* The number of values in the list.
|
|
22
|
+
*
|
|
23
|
+
* Complexity: **O(1)**.
|
|
24
|
+
*/
|
|
25
|
+
get size(): number;
|
|
26
|
+
/**
|
|
27
|
+
* Checks whether the list is empty.
|
|
28
|
+
*
|
|
29
|
+
* Complexity: **O(1)**.
|
|
30
|
+
*/
|
|
31
|
+
get isEmpty(): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* The first value in the list, or null if the list is empty.
|
|
34
|
+
*
|
|
35
|
+
* Check isEmpty to distinguish an empty list from a stored null.
|
|
36
|
+
*
|
|
37
|
+
* Complexity: **O(1)**.
|
|
38
|
+
*/
|
|
39
|
+
get head(): T | null;
|
|
40
|
+
/**
|
|
41
|
+
* The last value in the list, or null if the list is empty.
|
|
42
|
+
*
|
|
43
|
+
* Check isEmpty to distinguish an empty list from a stored null.
|
|
44
|
+
*
|
|
45
|
+
* Complexity: **O(1)**.
|
|
46
|
+
*/
|
|
47
|
+
get tail(): T | null;
|
|
48
|
+
/**
|
|
49
|
+
* Adds a value to the end of the list and returns its handle.
|
|
50
|
+
*
|
|
51
|
+
* Complexity: **O(1)**, amortized for index growth.
|
|
52
|
+
*
|
|
53
|
+
* @param value The value to add.
|
|
54
|
+
* @returns A unique handle for the inserted entry.
|
|
55
|
+
*/
|
|
56
|
+
push(value: T): DoublyLinkedListHandle;
|
|
57
|
+
/**
|
|
58
|
+
* Adds a value to the beginning of the list and returns its handle.
|
|
59
|
+
*
|
|
60
|
+
* Complexity: **O(1)**, amortized for index growth.
|
|
61
|
+
*
|
|
62
|
+
* @param value The value to add.
|
|
63
|
+
* @returns A unique handle for the inserted entry.
|
|
64
|
+
*/
|
|
65
|
+
unshift(value: T): DoublyLinkedListHandle;
|
|
66
|
+
/**
|
|
67
|
+
* Removes and returns the last value in the list.
|
|
68
|
+
*
|
|
69
|
+
* Returns null if the list is empty. Check isEmpty to distinguish an empty
|
|
70
|
+
* list from a stored null.
|
|
71
|
+
*
|
|
72
|
+
* Complexity: **O(1)**.
|
|
73
|
+
*/
|
|
74
|
+
pop(): T | null;
|
|
75
|
+
/**
|
|
76
|
+
* Removes and returns the first value in the list.
|
|
77
|
+
*
|
|
78
|
+
* Returns null if the list is empty. Check isEmpty to distinguish an empty
|
|
79
|
+
* list from a stored null.
|
|
80
|
+
*
|
|
81
|
+
* Complexity: **O(1)**.
|
|
82
|
+
*/
|
|
83
|
+
shift(): T | null;
|
|
84
|
+
/**
|
|
85
|
+
* Removes the entry identified by a live handle.
|
|
86
|
+
*
|
|
87
|
+
* A foreign or expired handle returns false and leaves the list unchanged.
|
|
88
|
+
*
|
|
89
|
+
* Complexity: **O(1)**.
|
|
90
|
+
*
|
|
91
|
+
* @param handle Handle returned by push or unshift.
|
|
92
|
+
* @returns True if the entry was removed, otherwise false.
|
|
93
|
+
*/
|
|
94
|
+
remove(handle: DoublyLinkedListHandle): boolean;
|
|
95
|
+
/**
|
|
96
|
+
* Removes all entries, detaches every node, and invalidates all handles.
|
|
97
|
+
*
|
|
98
|
+
* Complexity: **O(n)**, where n is the number of entries.
|
|
99
|
+
*/
|
|
100
|
+
clear(): void;
|
|
101
|
+
/**
|
|
102
|
+
* Returns an iterator over values from the head to the tail.
|
|
103
|
+
*
|
|
104
|
+
* The entry just yielded may be removed before requesting the next value.
|
|
105
|
+
* The iterator then continues with that entry's former successor. Other
|
|
106
|
+
* mutations during iteration have unspecified effects.
|
|
107
|
+
*
|
|
108
|
+
* Complexity: **O(1)** per step.
|
|
109
|
+
*
|
|
110
|
+
* @returns An iterator over list values.
|
|
111
|
+
*/
|
|
112
|
+
[Symbol.iterator](): IterableIterator<T>;
|
|
113
|
+
/**
|
|
114
|
+
* Returns an iterator over handle/value pairs from the head to the tail.
|
|
115
|
+
*
|
|
116
|
+
* The entry just yielded may be removed before requesting the next pair.
|
|
117
|
+
* The iterator then continues with that entry's former successor. Other
|
|
118
|
+
* mutations during iteration have unspecified effects.
|
|
119
|
+
*
|
|
120
|
+
* Complexity: **O(1)** per step.
|
|
121
|
+
*
|
|
122
|
+
* @returns An iterator over handle/value pairs.
|
|
123
|
+
*/
|
|
124
|
+
entries(): IterableIterator<[DoublyLinkedListHandle, T]>;
|
|
125
|
+
private _insert;
|
|
126
|
+
private _unlink;
|
|
127
|
+
}
|
|
128
|
+
export {};
|
|
129
|
+
//# sourceMappingURL=addressable-doubly-linked-list.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"addressable-doubly-linked-list.d.ts","sourceRoot":"","sources":["../src/addressable-doubly-linked-list.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,WAAW,EAAE,OAAO,MAAM,CAAA;AAExC;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,CAAC,WAAW,CAAC,EAAE,IAAI,CAAA;CAAE,CAAA;AAS9E;;;;;;;GAOG;AACH,qBAAa,2BAA2B,CAAC,CAAC,GAAG,OAAO;IACnD,OAAO,CAAC,KAAK,CAA4B;IACzC,OAAO,CAAC,KAAK,CAA4B;IACzC,OAAO,CAAC,MAAM,CAAkD;IAEhE;;;;OAIG;IACH,IAAW,IAAI,IAAI,MAAM,CAExB;IAED;;;;OAIG;IACH,IAAW,OAAO,IAAI,OAAO,CAE5B;IAED;;;;;;OAMG;IACH,IAAW,IAAI,IAAI,CAAC,GAAG,IAAI,CAE1B;IAED;;;;;;OAMG;IACH,IAAW,IAAI,IAAI,CAAC,GAAG,IAAI,CAE1B;IAED;;;;;;;OAOG;IACI,IAAI,CAAC,KAAK,EAAE,CAAC,GAAG,sBAAsB;IAI7C;;;;;;;OAOG;IACI,OAAO,CAAC,KAAK,EAAE,CAAC,GAAG,sBAAsB;IAIhD;;;;;;;OAOG;IACI,GAAG,IAAI,CAAC,GAAG,IAAI;IAMtB;;;;;;;OAOG;IACI,KAAK,IAAI,CAAC,GAAG,IAAI;IAMxB;;;;;;;;;OASG;IACI,MAAM,CAAC,MAAM,EAAE,sBAAsB,GAAG,OAAO;IAWtD;;;;OAIG;IACI,KAAK,IAAI,IAAI;IAepB;;;;;;;;;;OAUG;IACK,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,gBAAgB,CAAC,CAAC,CAAC;IAUhD;;;;;;;;;;OAUG;IACK,OAAO,IAAI,gBAAgB,CAAC,CAAC,sBAAsB,EAAE,CAAC,CAAC,CAAC;IAUhE,OAAO,CAAC,OAAO;IAuBf,OAAO,CAAC,OAAO;CAmBf"}
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Doubly linked list with constant-time removal by handle.
|
|
3
|
+
*
|
|
4
|
+
* Each insertion receives a distinct handle, including insertions of duplicate
|
|
5
|
+
* values. Removed nodes are disconnected from their neighbors.
|
|
6
|
+
*
|
|
7
|
+
* @template T The type of values stored in the list.
|
|
8
|
+
*/
|
|
9
|
+
export class AddressableDoublyLinkedList {
|
|
10
|
+
_head = null;
|
|
11
|
+
_tail = null;
|
|
12
|
+
_nodes = new Map();
|
|
13
|
+
/**
|
|
14
|
+
* The number of values in the list.
|
|
15
|
+
*
|
|
16
|
+
* Complexity: **O(1)**.
|
|
17
|
+
*/
|
|
18
|
+
get size() {
|
|
19
|
+
return this._nodes.size;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Checks whether the list is empty.
|
|
23
|
+
*
|
|
24
|
+
* Complexity: **O(1)**.
|
|
25
|
+
*/
|
|
26
|
+
get isEmpty() {
|
|
27
|
+
return this.size === 0;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The first value in the list, or null if the list is empty.
|
|
31
|
+
*
|
|
32
|
+
* Check isEmpty to distinguish an empty list from a stored null.
|
|
33
|
+
*
|
|
34
|
+
* Complexity: **O(1)**.
|
|
35
|
+
*/
|
|
36
|
+
get head() {
|
|
37
|
+
return this._head ? this._head.value : null;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* The last value in the list, or null if the list is empty.
|
|
41
|
+
*
|
|
42
|
+
* Check isEmpty to distinguish an empty list from a stored null.
|
|
43
|
+
*
|
|
44
|
+
* Complexity: **O(1)**.
|
|
45
|
+
*/
|
|
46
|
+
get tail() {
|
|
47
|
+
return this._tail ? this._tail.value : null;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Adds a value to the end of the list and returns its handle.
|
|
51
|
+
*
|
|
52
|
+
* Complexity: **O(1)**, amortized for index growth.
|
|
53
|
+
*
|
|
54
|
+
* @param value The value to add.
|
|
55
|
+
* @returns A unique handle for the inserted entry.
|
|
56
|
+
*/
|
|
57
|
+
push(value) {
|
|
58
|
+
return this._insert(value, this._tail, null);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Adds a value to the beginning of the list and returns its handle.
|
|
62
|
+
*
|
|
63
|
+
* Complexity: **O(1)**, amortized for index growth.
|
|
64
|
+
*
|
|
65
|
+
* @param value The value to add.
|
|
66
|
+
* @returns A unique handle for the inserted entry.
|
|
67
|
+
*/
|
|
68
|
+
unshift(value) {
|
|
69
|
+
return this._insert(value, null, this._head);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Removes and returns the last value in the list.
|
|
73
|
+
*
|
|
74
|
+
* Returns null if the list is empty. Check isEmpty to distinguish an empty
|
|
75
|
+
* list from a stored null.
|
|
76
|
+
*
|
|
77
|
+
* Complexity: **O(1)**.
|
|
78
|
+
*/
|
|
79
|
+
pop() {
|
|
80
|
+
return this._tail
|
|
81
|
+
? this._unlink(this._tail)
|
|
82
|
+
: null;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Removes and returns the first value in the list.
|
|
86
|
+
*
|
|
87
|
+
* Returns null if the list is empty. Check isEmpty to distinguish an empty
|
|
88
|
+
* list from a stored null.
|
|
89
|
+
*
|
|
90
|
+
* Complexity: **O(1)**.
|
|
91
|
+
*/
|
|
92
|
+
shift() {
|
|
93
|
+
return this._head
|
|
94
|
+
? this._unlink(this._head)
|
|
95
|
+
: null;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Removes the entry identified by a live handle.
|
|
99
|
+
*
|
|
100
|
+
* A foreign or expired handle returns false and leaves the list unchanged.
|
|
101
|
+
*
|
|
102
|
+
* Complexity: **O(1)**.
|
|
103
|
+
*
|
|
104
|
+
* @param handle Handle returned by push or unshift.
|
|
105
|
+
* @returns True if the entry was removed, otherwise false.
|
|
106
|
+
*/
|
|
107
|
+
remove(handle) {
|
|
108
|
+
const node = this._nodes.get(handle);
|
|
109
|
+
if (!node)
|
|
110
|
+
return false;
|
|
111
|
+
this._unlink(node);
|
|
112
|
+
return true;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Removes all entries, detaches every node, and invalidates all handles.
|
|
116
|
+
*
|
|
117
|
+
* Complexity: **O(n)**, where n is the number of entries.
|
|
118
|
+
*/
|
|
119
|
+
clear() {
|
|
120
|
+
let node = this._head;
|
|
121
|
+
while (node) {
|
|
122
|
+
const next = node.next;
|
|
123
|
+
node.prev = null;
|
|
124
|
+
node.next = null;
|
|
125
|
+
node = next;
|
|
126
|
+
}
|
|
127
|
+
this._head = null;
|
|
128
|
+
this._tail = null;
|
|
129
|
+
this._nodes = new Map();
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Returns an iterator over values from the head to the tail.
|
|
133
|
+
*
|
|
134
|
+
* The entry just yielded may be removed before requesting the next value.
|
|
135
|
+
* The iterator then continues with that entry's former successor. Other
|
|
136
|
+
* mutations during iteration have unspecified effects.
|
|
137
|
+
*
|
|
138
|
+
* Complexity: **O(1)** per step.
|
|
139
|
+
*
|
|
140
|
+
* @returns An iterator over list values.
|
|
141
|
+
*/
|
|
142
|
+
*[Symbol.iterator]() {
|
|
143
|
+
let next = this._head;
|
|
144
|
+
while (next) {
|
|
145
|
+
const { value } = next;
|
|
146
|
+
next = next.next;
|
|
147
|
+
yield value;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Returns an iterator over handle/value pairs from the head to the tail.
|
|
152
|
+
*
|
|
153
|
+
* The entry just yielded may be removed before requesting the next pair.
|
|
154
|
+
* The iterator then continues with that entry's former successor. Other
|
|
155
|
+
* mutations during iteration have unspecified effects.
|
|
156
|
+
*
|
|
157
|
+
* Complexity: **O(1)** per step.
|
|
158
|
+
*
|
|
159
|
+
* @returns An iterator over handle/value pairs.
|
|
160
|
+
*/
|
|
161
|
+
*entries() {
|
|
162
|
+
let next = this._head;
|
|
163
|
+
while (next) {
|
|
164
|
+
const { handle, value } = next;
|
|
165
|
+
next = next.next;
|
|
166
|
+
yield [handle, value];
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
_insert(value, prev, next) {
|
|
170
|
+
const handle = Symbol('DoublyLinkedListHandle');
|
|
171
|
+
const node = { handle, value, prev, next };
|
|
172
|
+
if (prev)
|
|
173
|
+
prev.next = node;
|
|
174
|
+
else
|
|
175
|
+
this._head = node;
|
|
176
|
+
if (next)
|
|
177
|
+
next.prev = node;
|
|
178
|
+
else
|
|
179
|
+
this._tail = node;
|
|
180
|
+
this._nodes.set(handle, node);
|
|
181
|
+
return handle;
|
|
182
|
+
}
|
|
183
|
+
_unlink(node) {
|
|
184
|
+
const { prev, next } = node;
|
|
185
|
+
if (prev)
|
|
186
|
+
prev.next = next;
|
|
187
|
+
else
|
|
188
|
+
this._head = next;
|
|
189
|
+
if (next)
|
|
190
|
+
next.prev = prev;
|
|
191
|
+
else
|
|
192
|
+
this._tail = prev;
|
|
193
|
+
node.prev = null;
|
|
194
|
+
node.next = null;
|
|
195
|
+
this._nodes.delete(node.handle);
|
|
196
|
+
return node.value;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
//# sourceMappingURL=addressable-doubly-linked-list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"addressable-doubly-linked-list.js","sourceRoot":"","sources":["../src/addressable-doubly-linked-list.ts"],"names":[],"mappings":"AAcA;;;;;;;GAOG;AACH,MAAM,OAAO,2BAA2B;IAC/B,KAAK,GAAwB,IAAI,CAAA;IACjC,KAAK,GAAwB,IAAI,CAAA;IACjC,MAAM,GAAG,IAAI,GAAG,EAAwC,CAAA;IAEhE;;;;OAIG;IACH,IAAW,IAAI;QACd,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAA;IACxB,CAAC;IAED;;;;OAIG;IACH,IAAW,OAAO;QACjB,OAAO,IAAI,CAAC,IAAI,KAAK,CAAC,CAAA;IACvB,CAAC;IAED;;;;;;OAMG;IACH,IAAW,IAAI;QACd,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAA;IAC5C,CAAC;IAED;;;;;;OAMG;IACH,IAAW,IAAI;QACd,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAA;IAC5C,CAAC;IAED;;;;;;;OAOG;IACI,IAAI,CAAC,KAAQ;QACnB,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;IAC7C,CAAC;IAED;;;;;;;OAOG;IACI,OAAO,CAAC,KAAQ;QACtB,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,CAAA;IAC7C,CAAC;IAED;;;;;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G,OAAO;IAgC/C;;;;;;;;OAQG;IACI,MAAM,CAAC,KAAK,EAAE,CAAC,GAAG,OAAO;IAgChC;;;;;;;;OAQG;IACI,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,CAAC,GAAG,IAAI;IAyB7C;;;;;;;;OAQG;IACI,IAAI,CAAC,SAAS,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,GAAG,CAAC,GAAG,IAAI;IAavD;;;;OAIG;IACI,OAAO,IAAI,CAAC,EAAE;IAIrB;;;;OAIG;IACI,eAAe,IAAI,CAAC,EAAE;IAM7B;;OAEG;IACK,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,gBAAgB,CAAC,CAAC,CAAC;IAShD;;OAEG;IACK,OAAO,IAAI,gBAAgB,CAAC,CAAC,CAAC;IAStC,OAAO,CAAC,QAAQ;CA6BhB"}
|
|
@@ -19,9 +19,8 @@ export class DoublyLinkedList {
|
|
|
19
19
|
*/
|
|
20
20
|
static from(iterable) {
|
|
21
21
|
const list = new DoublyLinkedList();
|
|
22
|
-
for (const value of iterable)
|
|
22
|
+
for (const value of iterable)
|
|
23
23
|
list.push(value);
|
|
24
|
-
}
|
|
25
24
|
return list;
|
|
26
25
|
}
|
|
27
26
|
/**
|
|
@@ -84,9 +83,8 @@ export class DoublyLinkedList {
|
|
|
84
83
|
* @returns The value removed from the end of the doubly linked list, or `null` if the list is empty.
|
|
85
84
|
*/
|
|
86
85
|
pop() {
|
|
87
|
-
if (!this._tail)
|
|
86
|
+
if (!this._tail)
|
|
88
87
|
return null;
|
|
89
|
-
}
|
|
90
88
|
const value = this._tail.value;
|
|
91
89
|
if (this._head === this._tail) {
|
|
92
90
|
this._head = null;
|
|
@@ -127,9 +125,8 @@ export class DoublyLinkedList {
|
|
|
127
125
|
* @returns The value removed from the beginning of the doubly linked list, or `null` if the list is empty.
|
|
128
126
|
*/
|
|
129
127
|
shift() {
|
|
130
|
-
if (!this._head)
|
|
128
|
+
if (!this._head)
|
|
131
129
|
return null;
|
|
132
|
-
}
|
|
133
130
|
const value = this._head.value;
|
|
134
131
|
if (this._head === this._tail) {
|
|
135
132
|
this._head = null;
|
|
@@ -161,9 +158,8 @@ export class DoublyLinkedList {
|
|
|
161
158
|
*/
|
|
162
159
|
contains(value) {
|
|
163
160
|
for (const item of this) {
|
|
164
|
-
if (item === value)
|
|
161
|
+
if (item === value)
|
|
165
162
|
return true;
|
|
166
|
-
}
|
|
167
163
|
}
|
|
168
164
|
return false;
|
|
169
165
|
}
|
|
@@ -177,9 +173,8 @@ export class DoublyLinkedList {
|
|
|
177
173
|
indexOf(value) {
|
|
178
174
|
let index = 0;
|
|
179
175
|
for (const item of this) {
|
|
180
|
-
if (item === value)
|
|
176
|
+
if (item === value)
|
|
181
177
|
return index;
|
|
182
|
-
}
|
|
183
178
|
index += 1;
|
|
184
179
|
}
|
|
185
180
|
return -1;
|
|
@@ -195,9 +190,8 @@ export class DoublyLinkedList {
|
|
|
195
190
|
* @returns `true` if the value was inserted, `false` otherwise.
|
|
196
191
|
*/
|
|
197
192
|
insert(index, value) {
|
|
198
|
-
if (index < 0 || index > this._size)
|
|
193
|
+
if (index < 0 || index > this._size)
|
|
199
194
|
return false;
|
|
200
|
-
}
|
|
201
195
|
if (index === 0) {
|
|
202
196
|
this.unshift(value);
|
|
203
197
|
return true;
|
|
@@ -231,18 +225,14 @@ export class DoublyLinkedList {
|
|
|
231
225
|
if (current.value === value) {
|
|
232
226
|
const prevNode = current.prev;
|
|
233
227
|
const nextNode = current.next;
|
|
234
|
-
if (prevNode)
|
|
228
|
+
if (prevNode)
|
|
235
229
|
prevNode.next = nextNode;
|
|
236
|
-
|
|
237
|
-
else {
|
|
230
|
+
else
|
|
238
231
|
this._head = nextNode;
|
|
239
|
-
|
|
240
|
-
if (nextNode) {
|
|
232
|
+
if (nextNode)
|
|
241
233
|
nextNode.prev = prevNode;
|
|
242
|
-
|
|
243
|
-
else {
|
|
234
|
+
else
|
|
244
235
|
this._tail = prevNode;
|
|
245
|
-
}
|
|
246
236
|
current.prev = null;
|
|
247
237
|
current.next = null;
|
|
248
238
|
this._size -= 1;
|
|
@@ -262,15 +252,12 @@ export class DoublyLinkedList {
|
|
|
262
252
|
* @returns The value removed from the list, or `null` if the list is empty or index is out of bounds.
|
|
263
253
|
*/
|
|
264
254
|
removeByIndex(index) {
|
|
265
|
-
if (index < 0 || index >= this._size)
|
|
255
|
+
if (index < 0 || index >= this._size)
|
|
266
256
|
return null;
|
|
267
|
-
|
|
268
|
-
if (index === 0) {
|
|
257
|
+
if (index === 0)
|
|
269
258
|
return this.shift();
|
|
270
|
-
|
|
271
|
-
if (index === this._size - 1) {
|
|
259
|
+
if (index === this._size - 1)
|
|
272
260
|
return this.pop();
|
|
273
|
-
}
|
|
274
261
|
const node = this._getNode(index);
|
|
275
262
|
const prevNode = node.prev;
|
|
276
263
|
const nextNode = node.next;
|
|
@@ -293,9 +280,8 @@ export class DoublyLinkedList {
|
|
|
293
280
|
find(predicate) {
|
|
294
281
|
let current = this._head;
|
|
295
282
|
while (current) {
|
|
296
|
-
if (predicate(current.value))
|
|
283
|
+
if (predicate(current.value))
|
|
297
284
|
return current.value;
|
|
298
|
-
}
|
|
299
285
|
current = current.next;
|
|
300
286
|
}
|
|
301
287
|
return null;
|
|
@@ -314,7 +300,9 @@ export class DoublyLinkedList {
|
|
|
314
300
|
* Complexity: **O(n)**.
|
|
315
301
|
*/
|
|
316
302
|
toReversedArray() {
|
|
317
|
-
return [
|
|
303
|
+
return [
|
|
304
|
+
...this.reverse(),
|
|
305
|
+
];
|
|
318
306
|
}
|
|
319
307
|
/**
|
|
320
308
|
* Returns an iterator that iterates over the values in the doubly linked list.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"doubly-linked-list.js","sourceRoot":"","sources":["../src/doubly-linked-list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAE1D;;;;GAIG;AACH,MAAM,OA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":"doubly-linked-node.d.ts","sourceRoot":"","sources":["../src/doubly-linked-node.ts"],"names":[],"mappings":"AAAA,gBAAgB;AAChB,qBAAa,gBAAgB,CAAC,CAAC,GAAG,OAAO;IAIrB,KAAK,EAAE,CAAC;IAHpB,IAAI,EAAE,gBAAgB,CAAC,CAAC,CAAC,GAAG,IAAI,CAAO;IACvC,IAAI,EAAE,gBAAgB,CAAC,CAAC,CAAC,GAAG,IAAI,CAAO;gBAE3B,KAAK,EAAE,CAAC;CAC3B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"doubly-linked-node.js","sourceRoot":"","sources":["../src/doubly-linked-node.ts"],"names":[],"mappings":"AAAA,gBAAgB;AAChB,MAAM,OAAO,gBAAgB;IAIT;IAHZ,IAAI,GAA+B,IAAI,CAAA;IACvC,IAAI,GAA+B,IAAI,CAAA;IAE9C,YAAmB,KAAQ;QAAR,UAAK,GAAL,KAAK,CAAG;IAAG,CAAC;CAC/B"}
|
package/lib/index.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,2BAA2B,EAC3B,KAAK,sBAAsB,GAC3B,MAAM,qCAAqC,CAAA;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA"}
|
package/lib/index.js
CHANGED
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,2BAA2B,GAE3B,MAAM,qCAAqC,CAAA;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,56 +1,57 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
2
|
+
"name": "@stimulcross/ds-doubly-linked-list",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"packageManager": "pnpm@12.18.0",
|
|
6
|
+
"description": "Doubly linked list implementation for TypeScript.",
|
|
7
|
+
"author": "StimulCross <stimulcross@gmail.com>",
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"homepage": "https://github.com/StimulCross/data-structures/tree/main/packages/doubly-linked-list#readme",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/StimulCross/data-structures.git",
|
|
13
|
+
"directory": "packages/doubly-linked-list"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"data-structure",
|
|
17
|
+
"doubly-linked-list",
|
|
18
|
+
"linked-list"
|
|
19
|
+
],
|
|
20
|
+
"publishConfig": {
|
|
21
|
+
"access": "public"
|
|
22
|
+
},
|
|
23
|
+
"sideEffects": false,
|
|
24
|
+
"exports": {
|
|
25
|
+
".": {
|
|
26
|
+
"types": "./lib/index.d.ts",
|
|
27
|
+
"default": "./lib/index.js"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"main": "./lib/index.js",
|
|
31
|
+
"types": "./lib/index.d.ts",
|
|
32
|
+
"files": [
|
|
33
|
+
"!lib/**/*.d.ts.map",
|
|
34
|
+
"!lib/**/*.js.map",
|
|
35
|
+
"LICENSE",
|
|
36
|
+
"README.md",
|
|
37
|
+
"lib"
|
|
38
|
+
],
|
|
39
|
+
"engines": {
|
|
40
|
+
"node": ">=22.13.0"
|
|
41
|
+
},
|
|
42
|
+
"scripts": {
|
|
43
|
+
"build": "tsc -p tsconfig.json",
|
|
44
|
+
"rebuild": "pnpm run clean && pnpm run build",
|
|
45
|
+
"clean": "del-cli lib *.tsbuildinfo",
|
|
46
|
+
"lint": "eslint src tests",
|
|
47
|
+
"lint:fix": "eslint src tests --fix",
|
|
48
|
+
"check-types": "tsc -p tsconfig.json --noEmit && tsc -p tests/tsconfig.json",
|
|
49
|
+
"preversion": "pnpm run rebuild && pnpm run lint",
|
|
50
|
+
"prepublishOnly": "pnpm run rebuild && pnpm run lint",
|
|
51
|
+
"watch": "turbo watch build --filter=@stimulcross/ds-doubly-linked-list... --continue=dependencies-successful"
|
|
52
|
+
},
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"eslint-config": "workspace:*",
|
|
55
|
+
"typescript-config": "workspace:*"
|
|
56
|
+
}
|
|
57
|
+
}
|