solists 0.2.0 → 1.0.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/LICENSE +22 -0
- package/README.md +184 -150
- package/dist/DoublyLinkedList.d.ts +67 -50
- package/dist/DoublyLinkedList.js +379 -301
- package/dist/FrequencyCountSoList.d.ts +4 -5
- package/dist/FrequencyCountSoList.js +2 -5
- package/dist/KInARowSoList.d.ts +10 -0
- package/dist/KInARowSoList.js +30 -0
- package/dist/MoveAheadKSoList.d.ts +8 -0
- package/dist/MoveAheadKSoList.js +22 -0
- package/dist/MoveToFrontSoList.d.ts +4 -5
- package/dist/MoveToFrontSoList.js +3 -6
- package/dist/Node.d.ts +6 -6
- package/dist/TransposeSoList.d.ts +4 -5
- package/dist/TransposeSoList.js +1 -4
- package/dist/index.d.ts +7 -4
- package/dist/index.js +5 -1
- package/package.json +22 -12
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Copyright (c) 2023 Emmanuel Ferdman
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person
|
|
4
|
+
obtaining a copy of this software and associated documentation
|
|
5
|
+
files (the "Software"), to deal in the Software without
|
|
6
|
+
restriction, including without limitation the rights to use,
|
|
7
|
+
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
copies of the Software, and to permit persons to whom the
|
|
9
|
+
Software is furnished to do so, subject to the following
|
|
10
|
+
conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be
|
|
13
|
+
included in all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
16
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
17
|
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
18
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
19
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
20
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
21
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
22
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,179 +1,213 @@
|
|
|
1
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://github.com/emmanuel-ferdman/solists">
|
|
3
|
+
<picture>
|
|
4
|
+
<img src="https://raw.githubusercontent.com/emmanuel-ferdman/solists/main/img/logo.png" height="128">
|
|
5
|
+
</picture>
|
|
6
|
+
</a>
|
|
7
|
+
</p>
|
|
8
|
+
|
|
9
|
+
<p align="center">
|
|
10
|
+
A TypeScript implementation of <a href="https://en.wikipedia.org/wiki/Self-organizing_list">self-organizing lists</a> with native Array methods.
|
|
11
|
+
</p>
|
|
12
|
+
|
|
13
|
+
<p align="center">
|
|
14
|
+
<a href="https://www.npmjs.com/package/solists"><img src="https://img.shields.io/npm/v/solists.svg" alt="npm version"></a>
|
|
15
|
+
<a href="https://www.npmjs.com/package/solists"><img src="https://img.shields.io/npm/dm/solists.svg" alt="npm downloads"></a>
|
|
16
|
+
<a href="https://github.com/emmanuel-ferdman/solists/actions"><img src="https://github.com/emmanuel-ferdman/solists/workflows/CI/badge.svg" alt="CI"></a>
|
|
17
|
+
<a href="https://codecov.io/gh/emmanuel-ferdman/solists"><img src="https://codecov.io/gh/emmanuel-ferdman/solists/graph/badge.svg" alt="Coverage"></a>
|
|
18
|
+
<a href="https://github.com/emmanuel-ferdman/solists/blob/main/LICENSE"><img src="https://img.shields.io/npm/l/solists.svg" alt="License"></a>
|
|
19
|
+
</p>
|
|
2
20
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
## Introduction
|
|
21
|
+
## Installation
|
|
6
22
|
|
|
7
|
-
|
|
23
|
+
```sh
|
|
24
|
+
npm install solists
|
|
25
|
+
```
|
|
8
26
|
|
|
9
|
-
|
|
27
|
+
## Example
|
|
10
28
|
|
|
11
|
-
|
|
29
|
+
<table width="100%">
|
|
30
|
+
<tr>
|
|
31
|
+
<th align="left">Code</th>
|
|
32
|
+
<th align="left">Visualization</th>
|
|
33
|
+
</tr>
|
|
34
|
+
<tr>
|
|
35
|
+
<td>
|
|
12
36
|
|
|
13
|
-
|
|
37
|
+
```javascript
|
|
38
|
+
const { FrequencyCountSoList } = require("solists");
|
|
14
39
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
count(i) = count(i) + 1
|
|
21
|
-
rearrange items based on count
|
|
40
|
+
const l = new FrequencyCountSoList(["A", "B", "C", "D", "E"]);
|
|
41
|
+
l.includes("D"); // D(1) -> front
|
|
42
|
+
l.includes("B"); // B(1) -> #2
|
|
43
|
+
l.includes("B"); // B(2) overtakes D
|
|
44
|
+
// Result: ["B", "D", "A", "C", "E"]
|
|
22
45
|
```
|
|
23
46
|
|
|
24
|
-
|
|
47
|
+
</td>
|
|
48
|
+
<td align="center" valign="middle">
|
|
49
|
+
<img src="https://raw.githubusercontent.com/emmanuel-ferdman/solists/main/img/frequency-count.gif" width="400">
|
|
50
|
+
</td>
|
|
51
|
+
</tr>
|
|
52
|
+
<tr>
|
|
53
|
+
<td>
|
|
25
54
|
|
|
26
|
-
|
|
55
|
+
```javascript
|
|
56
|
+
const { KInARowSoList } = require("solists");
|
|
27
57
|
|
|
28
|
-
|
|
58
|
+
const l = new KInARowSoList(["A", "B", "C", "D", "E"], { k: 2 });
|
|
59
|
+
l.includes("D"); // D: 1st access, no move
|
|
60
|
+
l.includes("D"); // D: 2nd access, -> front
|
|
61
|
+
l.includes("B"); // B: 1st access, no move
|
|
62
|
+
// Result: ["D", "A", "B", "C", "E"]
|
|
29
63
|
```
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
64
|
+
|
|
65
|
+
</td>
|
|
66
|
+
<td align="center" valign="middle">
|
|
67
|
+
<img src="https://raw.githubusercontent.com/emmanuel-ferdman/solists/main/img/k-in-a-row.gif" width="400">
|
|
68
|
+
</td>
|
|
69
|
+
</tr>
|
|
70
|
+
<tr>
|
|
71
|
+
<td>
|
|
72
|
+
|
|
73
|
+
```javascript
|
|
74
|
+
const { MoveAheadKSoList } = require("solists");
|
|
75
|
+
|
|
76
|
+
const l = new MoveAheadKSoList(["A", "B", "C", "D", "E"], { k: 2 });
|
|
77
|
+
l.includes("D"); // D moves 2 ahead
|
|
78
|
+
l.includes("E"); // E moves 2 ahead
|
|
79
|
+
l.includes("B"); // B moves 2 ahead
|
|
80
|
+
// Result: ["A", "B", "D", "E", "C"]
|
|
33
81
|
```
|
|
34
82
|
|
|
35
|
-
|
|
83
|
+
</td>
|
|
84
|
+
<td align="center" valign="middle">
|
|
85
|
+
<img src="https://raw.githubusercontent.com/emmanuel-ferdman/solists/main/img/move-ahead-k.gif" width="400">
|
|
86
|
+
</td>
|
|
87
|
+
</tr>
|
|
88
|
+
<tr>
|
|
89
|
+
<td>
|
|
36
90
|
|
|
37
|
-
|
|
91
|
+
```javascript
|
|
92
|
+
const { MoveToFrontSoList } = require("solists");
|
|
38
93
|
|
|
39
|
-
|
|
94
|
+
const l = new MoveToFrontSoList(["A", "B", "C", "D", "E"]);
|
|
95
|
+
l.includes("D"); // D -> front
|
|
96
|
+
l.includes("B"); // B -> front
|
|
97
|
+
l.includes("C"); // C -> front
|
|
98
|
+
// Result: ["C", "B", "D", "A", "E"]
|
|
40
99
|
```
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
100
|
+
|
|
101
|
+
</td>
|
|
102
|
+
<td align="center" valign="middle">
|
|
103
|
+
<img src="https://raw.githubusercontent.com/emmanuel-ferdman/solists/main/img/move-to-front.gif" width="400">
|
|
104
|
+
</td>
|
|
105
|
+
</tr>
|
|
106
|
+
<tr>
|
|
107
|
+
<td>
|
|
108
|
+
|
|
109
|
+
```javascript
|
|
110
|
+
const { TransposeSoList } = require("solists");
|
|
111
|
+
|
|
112
|
+
const l = new TransposeSoList(["A", "B", "C", "D", "E"]);
|
|
113
|
+
l.includes("D"); // D swaps with C
|
|
114
|
+
l.includes("E"); // E swaps with C
|
|
115
|
+
l.includes("B"); // B swaps with A
|
|
116
|
+
// Result: ["B", "A", "D", "E", "C"]
|
|
45
117
|
```
|
|
46
118
|
|
|
47
|
-
|
|
48
|
-
|
|
119
|
+
</td>
|
|
120
|
+
<td align="center" valign="middle">
|
|
121
|
+
<img src="https://raw.githubusercontent.com/emmanuel-ferdman/solists/main/img/transpose.gif" width="400">
|
|
122
|
+
</td>
|
|
123
|
+
</tr>
|
|
124
|
+
</table>
|
|
49
125
|
|
|
50
|
-
|
|
126
|
+
## How It Works
|
|
51
127
|
|
|
52
|
-
|
|
53
|
-
- Rearrange upon search: `at()`, `find()`, `findIndex()`, `findLast()`, `findLastIndex()`, `includes()`, `indexOf()` and `lastIndexOf`.
|
|
54
|
-
- Rearrange upon creation: `constructor` (initialization from an iterable), `insert()`, `push()` and `unshift()`.
|
|
128
|
+
A self-organizing list (or _SoList_) reorders elements based on access patterns to improve search efficiency. Frequently accessed items move toward the head, achieving near constant-time access in the best case.
|
|
55
129
|
|
|
56
|
-
|
|
57
|
-
```
|
|
58
|
-
npm install solists
|
|
59
|
-
```
|
|
130
|
+
**Supported heuristics:**
|
|
60
131
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
fcList1.includes(2);
|
|
71
|
-
fcList1.includes(4);
|
|
72
|
-
console.log(fcList1.toString()); // 2,4,1,3,5
|
|
73
|
-
|
|
74
|
-
// Example of SoList with Move to Front heuristic
|
|
75
|
-
const mtfList1 = new MoveToFrontSoList(false,[1,2,3,4,5]);
|
|
76
|
-
console.log(mtfList1.toString()); // 1,2,3,4,5
|
|
77
|
-
mtfList1.includes(2);
|
|
78
|
-
mtfList1.includes(4);
|
|
79
|
-
console.log(mtfList1.toString()); // 4,2,1,3,5
|
|
80
|
-
|
|
81
|
-
// Example of SoList with Transpose heuristic
|
|
82
|
-
const tList1 = new TransposeSoList(false,[1,2,3,4,5]);
|
|
83
|
-
console.log(tList1.toString()); // 1,2,3,4,5
|
|
84
|
-
tList1.includes(2);
|
|
85
|
-
tList1.includes(4);
|
|
86
|
-
console.log(tList1.toString()); // 2,1,4,3,5
|
|
87
|
-
|
|
88
|
-
/** Examples of SoList with rearrange upon creation **/
|
|
89
|
-
|
|
90
|
-
// Example of SoList with Frequency Count heuristic
|
|
91
|
-
const fcList2 = new FrequencyCountSoList(true,[1,2,3,4,5]);
|
|
92
|
-
console.log(fcList2.toString()); // 1,2,3,4,5
|
|
93
|
-
fcList2.includes(2);
|
|
94
|
-
fcList2.includes(4);
|
|
95
|
-
console.log(fcList2.toString()); // 2,4,1,3,5
|
|
96
|
-
|
|
97
|
-
// Example of SoList with Move to Front heuristic
|
|
98
|
-
const mtfList2 = new MoveToFrontSoList(true,[1,2,3,4,5]);
|
|
99
|
-
console.log(mtfList2.toString()); // 5,4,3,2,1
|
|
100
|
-
mtfList2.includes(2);
|
|
101
|
-
mtfList2.includes(4);
|
|
102
|
-
console.log(mtfList2.toString()); // 4,2,5,3,1
|
|
103
|
-
|
|
104
|
-
// Example of SoList with Transpose heuristic
|
|
105
|
-
const tList2 = new TransposeSoList(true,[1,2,3,4,5]);
|
|
106
|
-
console.log(tList2.toString()); // 2,3,4,5,1
|
|
107
|
-
tList2.includes(2);
|
|
108
|
-
tList2.includes(4);
|
|
109
|
-
console.log(tList2.toString()); // 2,4,3,5,1
|
|
132
|
+
- **Frequency Count** - Accessed elements ordered by access count
|
|
133
|
+
- **k-in-a-Row** - Accessed element moves to front after k consecutive accesses
|
|
134
|
+
- **Move-Ahead-k** - Accessed element moves k positions toward the head
|
|
135
|
+
- **Move to Front** - Accessed element moves directly to the head
|
|
136
|
+
- **Transpose** - Accessed element swaps with its predecessor
|
|
137
|
+
|
|
138
|
+
### Access Only Mode
|
|
139
|
+
|
|
140
|
+
By default (`accessOnly: true`), the list only rearranges on search operations. To also rearrange when adding elements, set `accessOnly: false`:
|
|
110
141
|
|
|
142
|
+
```javascript
|
|
143
|
+
const l = new MoveToFrontSoList([1, 2, 3], { accessOnly: false });
|
|
111
144
|
```
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
| Name
|
|
123
|
-
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
145
|
+
|
|
146
|
+
**Methods that trigger rearrangement:**
|
|
147
|
+
|
|
148
|
+
- Always: `at()`, `find()`, `findIndex()`, `findLast()`, `findLastIndex()`, `includes()`, `indexOf()`, `lastIndexOf()`
|
|
149
|
+
- When `accessOnly: false`: `push()`, `unshift()`, `insert()`
|
|
150
|
+
|
|
151
|
+
## API
|
|
152
|
+
|
|
153
|
+
**Properties:**
|
|
154
|
+
|
|
155
|
+
| Name | Description |
|
|
156
|
+
| :------- | :----------------------------- |
|
|
157
|
+
| `length` | Number of elements in the list |
|
|
158
|
+
|
|
159
|
+
**Methods:**
|
|
160
|
+
|
|
161
|
+
| Name | Description |
|
|
162
|
+
| :-------------------- | :------------------------------------------------------------ |
|
|
163
|
+
| `[Symbol.iterator]()` | Returns an iterator that yields each value |
|
|
164
|
+
| `at()` | Returns the value at a given index |
|
|
165
|
+
| `concat()` | Returns a new SoList merged with given iterables |
|
|
166
|
+
| `copyWithin()` | Shallow copies part of list to another location |
|
|
167
|
+
| `entries()` | Returns an iterator of key/value pairs |
|
|
168
|
+
| `every()` | Checks if every element satisfies a predicate |
|
|
169
|
+
| `fill()` | Changes all elements to a static value |
|
|
170
|
+
| `filter()` | Creates a new SoList with elements satisfying a predicate |
|
|
171
|
+
| `find()` | Returns the first element satisfying a predicate |
|
|
172
|
+
| `findIndex()` | Returns the index of the first element satisfying a predicate |
|
|
173
|
+
| `findLast()` | Returns the last element satisfying a predicate |
|
|
174
|
+
| `findLastIndex()` | Returns the index of the last element satisfying a predicate |
|
|
175
|
+
| `flat()` | Creates a new SoList with sub-lists flattened |
|
|
176
|
+
| `flatMap()` | Maps then flattens the result by one level |
|
|
177
|
+
| `forEach()` | Executes a function for each element |
|
|
178
|
+
| `includes()` | Determines whether a value exists in the list |
|
|
179
|
+
| `indexOf()` | Returns the first index of a given element |
|
|
180
|
+
| `insert()` | Adds an element at a specific index |
|
|
181
|
+
| `isEmpty()` | Checks if the list contains no elements |
|
|
182
|
+
| `isEqual()` | Checks if the list equals a given iterable |
|
|
183
|
+
| `join()` | Joins all elements into a string |
|
|
184
|
+
| `keys()` | Returns an iterator of keys |
|
|
185
|
+
| `lastIndexOf()` | Returns the last index of a given element |
|
|
186
|
+
| `map()` | Creates a new SoList with mapped values |
|
|
187
|
+
| `pop()` | Removes and returns the last element |
|
|
188
|
+
| `push()` | Adds elements to the end |
|
|
189
|
+
| `reduce()` | Reduces values to a single value (left-to-right) |
|
|
190
|
+
| `reduceRight()` | Reduces values to a single value (right-to-left) |
|
|
191
|
+
| `remove()` | Removes the element at a specific index |
|
|
192
|
+
| `reverse()` | Reverses the order of elements |
|
|
193
|
+
| `shift()` | Removes and returns the first element |
|
|
194
|
+
| `slice()` | Returns a shallow copy of a portion |
|
|
195
|
+
| `some()` | Checks if any element satisfies a predicate |
|
|
196
|
+
| `sort()` | Sorts the elements |
|
|
197
|
+
| `splice()` | Adds/removes elements |
|
|
198
|
+
| `toLocaleString()` | Returns a localized string representation |
|
|
199
|
+
| `toReversed()` | Returns a reversed copy |
|
|
200
|
+
| `toSorted()` | Returns a sorted copy |
|
|
201
|
+
| `toSpliced()` | Returns a spliced copy |
|
|
202
|
+
| `toString()` | Returns a string representation |
|
|
203
|
+
| `unshift()` | Adds elements to the beginning |
|
|
204
|
+
| `values()` | Returns an iterator of values |
|
|
205
|
+
| `with()` | Returns copy with element at index replaced |
|
|
170
206
|
|
|
171
207
|
## Contributing
|
|
172
208
|
|
|
173
|
-
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
|
|
209
|
+
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. For contribution guidelines, see [CONTRIBUTING.md](CONTRIBUTING.md).
|
|
174
210
|
|
|
175
|
-
|
|
211
|
+
## License
|
|
176
212
|
|
|
177
|
-
|
|
178
|
-
npm run test
|
|
179
|
-
```
|
|
213
|
+
The library is freely distributable under the terms of the [MIT license](LICENSE).
|
|
@@ -1,66 +1,83 @@
|
|
|
1
|
-
import { Node } from
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
protected
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
1
|
+
import { Node } from "./Node";
|
|
2
|
+
export interface SoListOptions {
|
|
3
|
+
accessOnly?: boolean;
|
|
4
|
+
}
|
|
5
|
+
export declare class DoublyLinkedList<T, O extends SoListOptions = SoListOptions> {
|
|
6
|
+
protected _accessOnly: boolean;
|
|
7
|
+
protected _head: Node<T> | null;
|
|
8
|
+
protected _options: O;
|
|
9
|
+
protected _tail: Node<T> | null;
|
|
10
|
+
private _length;
|
|
11
|
+
constructor(iterable?: Iterable<T> | null, options?: O);
|
|
12
|
+
[Symbol.iterator](): Generator<T>;
|
|
13
|
+
at(index: number): T | undefined;
|
|
14
|
+
concat(...items: (T | ConcatArray<T>)[]): DoublyLinkedList<T>;
|
|
15
|
+
copyWithin(target: number, start: number, end?: number): this;
|
|
16
|
+
entries(): Generator<[number, T]>;
|
|
17
|
+
every(predicate: (value: T, index: number, list: DoublyLinkedList<T>) => unknown, thisArg?: any): boolean;
|
|
18
|
+
fill(value: T, start?: number, end?: number): this;
|
|
19
|
+
filter(predicate: (value: T, index: number, list: DoublyLinkedList<T>) => unknown, thisArg?: any): DoublyLinkedList<T>;
|
|
20
|
+
find(predicate: (value: T, index: number, list: DoublyLinkedList<T>) => unknown, thisArg?: any): T | undefined;
|
|
21
|
+
findIndex(predicate: (value: T, index: number, list: DoublyLinkedList<T>) => unknown, thisArg?: any): number;
|
|
22
|
+
findLast(predicate: (value: T, index: number, list: DoublyLinkedList<T>) => unknown, thisArg?: any): T | undefined;
|
|
23
|
+
findLastIndex(predicate: (value: T, index: number, list: DoublyLinkedList<T>) => unknown, thisArg?: any): number;
|
|
24
|
+
flat<D extends number = 1>(depth?: D): DoublyLinkedList<unknown>;
|
|
25
|
+
flatMap<U>(callback: (value: T, index: number, list: DoublyLinkedList<T>) => U | ReadonlyArray<U>, thisArg?: any): DoublyLinkedList<U>;
|
|
26
|
+
forEach(callbackfn: (value: T, index: number, list: DoublyLinkedList<T>) => void, thisArg?: any): void;
|
|
27
|
+
includes(searchElement: T, fromIndex?: number): boolean;
|
|
28
|
+
indexOf(searchElement: T, fromIndex?: number): number;
|
|
29
|
+
join(separator?: string): string;
|
|
26
30
|
keys(): Generator<number>;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
31
|
+
get length(): number;
|
|
32
|
+
lastIndexOf(searchElement: T, fromIndex?: any): number;
|
|
33
|
+
map<U>(callbackfn: (value: T, index: number, list: DoublyLinkedList<T>) => U, thisArg?: any): DoublyLinkedList<U>;
|
|
34
|
+
pop(): T | undefined;
|
|
35
|
+
push(...items: T[]): number;
|
|
36
|
+
reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, list: DoublyLinkedList<T>) => T): T;
|
|
37
|
+
reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, list: DoublyLinkedList<T>) => T, initialValue: T): T;
|
|
38
|
+
reduce<U>(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, list: DoublyLinkedList<T>) => U, initialValue: U): U;
|
|
39
|
+
reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, list: DoublyLinkedList<T>) => T): T;
|
|
40
|
+
reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, list: DoublyLinkedList<T>) => T, initialValue: T): T;
|
|
41
|
+
reduceRight<U>(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, list: DoublyLinkedList<T>) => U, initialValue: U): U;
|
|
42
|
+
reverse(): this;
|
|
43
|
+
shift(): T | undefined;
|
|
44
|
+
slice(start?: any, end?: any): DoublyLinkedList<T>;
|
|
45
|
+
some(predicate: (value: T, index: number, list: DoublyLinkedList<T>) => unknown, thisArg?: any): boolean;
|
|
46
|
+
sort(compareFn?: (a: T, b: T) => number): this;
|
|
47
|
+
splice(start?: any, deleteCount?: any, ...items: T[]): DoublyLinkedList<T>;
|
|
48
|
+
toLocaleString(locales?: string | string[], options?: Intl.NumberFormatOptions & Intl.DateTimeFormatOptions): string;
|
|
49
|
+
toReversed(): DoublyLinkedList<T>;
|
|
50
|
+
toSorted(compareFn?: (a: T, b: T) => number): DoublyLinkedList<T>;
|
|
51
|
+
toSpliced(start?: any, deleteCount?: any, ...items: T[]): DoublyLinkedList<T>;
|
|
40
52
|
toString(): string;
|
|
41
|
-
unshift(...
|
|
42
|
-
values(): Generator<
|
|
43
|
-
|
|
53
|
+
unshift(...items: T[]): number;
|
|
54
|
+
values(): Generator<T>;
|
|
55
|
+
with(index: number, value: T): DoublyLinkedList<T>;
|
|
56
|
+
insert(index: any, value: T): number | undefined;
|
|
44
57
|
isEmpty(): boolean;
|
|
45
|
-
isEqual(
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
protected
|
|
50
|
-
protected
|
|
51
|
-
protected
|
|
52
|
-
protected
|
|
53
|
-
protected
|
|
58
|
+
isEqual(other: Iterable<T> & {
|
|
59
|
+
length: number;
|
|
60
|
+
}): boolean;
|
|
61
|
+
remove(index: number): T | undefined;
|
|
62
|
+
protected _getIndexByNode(node: Node<T>): number;
|
|
63
|
+
protected _getNode(index: number): Node<T> | null;
|
|
64
|
+
protected _insertFirst(newNode: Node<T>): void;
|
|
65
|
+
protected _insertBefore(existingNode: Node<T>, newNode: Node<T>): void;
|
|
66
|
+
protected _insertAfter(existingNode: Node<T>, newNode: Node<T>): void;
|
|
67
|
+
protected _rearrange(_node: Node<T>): number | undefined;
|
|
68
|
+
protected _remove(node: Node<T>): void;
|
|
54
69
|
protected _removeLast(): void;
|
|
55
70
|
private _entries;
|
|
56
71
|
private _extend;
|
|
57
72
|
private _getSortCompare;
|
|
58
73
|
private _isCallable;
|
|
74
|
+
private _aCallable;
|
|
59
75
|
private _isIterable;
|
|
60
76
|
private _isStrictlyEqual;
|
|
61
77
|
private _keys;
|
|
62
78
|
private _merge;
|
|
63
79
|
private _mergeSort;
|
|
80
|
+
private _insertionSort;
|
|
64
81
|
private _nodes;
|
|
65
82
|
private _nodesReverse;
|
|
66
83
|
private _sameValue;
|