solists 0.3.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/README.md CHANGED
@@ -1,189 +1,213 @@
1
1
  <p align="center">
2
2
  <a href="https://github.com/emmanuel-ferdman/solists">
3
3
  <picture>
4
- <img src="img/logo.png" height="128">
4
+ <img src="https://raw.githubusercontent.com/emmanuel-ferdman/solists/main/img/logo.png" height="128">
5
5
  </picture>
6
6
  </a>
7
7
  </p>
8
8
 
9
- The library provides a powerful and flexible implementation of the [self-organizing list](https://en.wikipedia.org/wiki/Self-organizing_list) data structure written in TypeScript. It offers support for multiple heuristic algorithms such as [Frequency Count](#Frequency-Count), [Move to Front](#Move-to-Front) and [Transpose](#Transpose). In addition to custom methods, the data structure also includes a selection of methods with behavior equivalent to that of JavaScript's built-in [Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array) data structure.
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>
10
12
 
11
- ## Introduction
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>
12
20
 
13
- A *self-organizing list* (aka *SoList*) is a list that reorders its elements based on some self-organizing heuristic to improve average access time. The aim of a self-organizing list is to improve efficiency of linear search by moving more frequently accessed items towards the head of the list. A self-organizing list achieves near constant time for element access in the best case. A self-organizing list uses a reorganizing algorithm to adapt to various query distributions at runtime.
21
+ ## Installation
14
22
 
15
- ### Self-organizing techniques
23
+ ```sh
24
+ npm install solists
25
+ ```
16
26
 
17
- #### Frequency Count
27
+ ## Example
18
28
 
19
- This technique involves counting the number of times each node is searched for, by keeping a separate counter variable for each node that is incremented every time the node is accessed.
29
+ <table width="100%">
30
+ <tr>
31
+ <th align="left">Code</th>
32
+ <th align="left">Visualization</th>
33
+ </tr>
34
+ <tr>
35
+ <td>
20
36
 
21
- Pseudocode:
22
- ```
23
- init: count(i) = 0 for each item i
24
- At t-th item selection:
25
- if item i is searched:
26
- count(i) = count(i) + 1
27
- rearrange items based on count
37
+ ```javascript
38
+ const { FrequencyCountSoList } = require("solists");
39
+
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"]
28
45
  ```
29
46
 
30
- #### Move to Front
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>
31
54
 
32
- This technique moves the node which is accessed to the head of the list.
55
+ ```javascript
56
+ const { KInARowSoList } = require("solists");
33
57
 
34
- Pseudocode:
35
- ```
36
- At the t-th item selection:
37
- if item i is selected:
38
- move item i to head of the list
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"]
39
63
  ```
40
64
 
41
- #### Transpose
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>
42
72
 
43
- This technique involves swapping an accessed node with its predecessor.
73
+ ```javascript
74
+ const { MoveAheadKSoList } = require("solists");
44
75
 
45
- Pseudocode:
46
- ```
47
- At the t-th item selection:
48
- if item i is selected:
49
- if i is not the head of list:
50
- swap item i with item (i - 1)
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"]
51
81
  ```
52
82
 
53
- ### Rearrange upon creation
54
- In literature, some self-organizing list implementations activate a heuristic after every creation operation (like `insert()`, `push()`, `unshift()`, etc.). This means that immediately after a new node is added to the list, the relevant heuristic is triggered and the list is rearranged.
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>
55
90
 
56
- This library supports both of these approaches. By default, the list is only rearranged when searched. To activate the option for rearranging the list upon creation, use `rearrangeOnCreation=true` when creating a new SoList instance. See the example below for more details.
57
-
58
- Methods which perform rearrange of the list:
59
- - Rearrange upon search: `at()`, `find()`, `findIndex()`, `findLast()`, `findLastIndex()`, `includes()`, `indexOf()` and `lastIndexOf()`.
60
- - Rearrange upon creation: `constructor` (initialization from an iterable), `insert()`, `push()` and `unshift()`.
91
+ ```javascript
92
+ const { MoveToFrontSoList } = require("solists");
61
93
 
62
- ## Installation
63
- ```
64
- npm install solists
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"]
65
99
  ```
66
100
 
67
- ## Example
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
+
68
109
  ```javascript
69
- const { FrequencyCountSoList, MoveToFrontSoList, TransposeSoList } = require("solists");
70
-
71
- /** Examples of SoList without rearrange upon creation **/
72
-
73
- // Example of SoList with Frequency Count heuristic
74
- const fcList1 = new FrequencyCountSoList(false,[1,2,3,4,5]);
75
- console.log(fcList1.toString()); // 1,2,3,4,5
76
- fcList1.includes(2);
77
- fcList1.includes(4);
78
- console.log(fcList1.toString()); // 2,4,1,3,5
79
-
80
- // Example of SoList with Move to Front heuristic
81
- const mtfList1 = new MoveToFrontSoList(false,[1,2,3,4,5]);
82
- console.log(mtfList1.toString()); // 1,2,3,4,5
83
- mtfList1.includes(2);
84
- mtfList1.includes(4);
85
- console.log(mtfList1.toString()); // 4,2,1,3,5
86
-
87
- // Example of SoList with Transpose heuristic
88
- const tList1 = new TransposeSoList(false,[1,2,3,4,5]);
89
- console.log(tList1.toString()); // 1,2,3,4,5
90
- tList1.includes(2);
91
- tList1.includes(4);
92
- console.log(tList1.toString()); // 2,1,4,3,5
93
-
94
- /** Examples of SoList with rearrange upon creation **/
95
-
96
- // Example of SoList with Frequency Count heuristic
97
- const fcList2 = new FrequencyCountSoList(true,[1,2,3,4,5]);
98
- console.log(fcList2.toString()); // 1,2,3,4,5
99
- fcList2.includes(2);
100
- fcList2.includes(4);
101
- console.log(fcList2.toString()); // 2,4,1,3,5
102
-
103
- // Example of SoList with Move to Front heuristic
104
- const mtfList2 = new MoveToFrontSoList(true,[1,2,3,4,5]);
105
- console.log(mtfList2.toString()); // 5,4,3,2,1
106
- mtfList2.includes(2);
107
- mtfList2.includes(4);
108
- console.log(mtfList2.toString()); // 4,2,5,3,1
109
-
110
- // Example of SoList with Transpose heuristic
111
- const tList2 = new TransposeSoList(true,[1,2,3,4,5]);
112
- console.log(tList2.toString()); // 2,3,4,5,1
113
- tList2.includes(2);
114
- tList2.includes(4);
115
- console.log(tList2.toString()); // 2,4,3,5,1
110
+ const { TransposeSoList } = require("solists");
116
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"]
117
117
  ```
118
- ## Methods and properties
119
-
120
- List of properties of SoList:
121
-
122
- | Name | Description |
123
- | ------------- | ------------- |
124
- |`length`|Represents the number of elements in that SoList|
125
-
126
- List of methods of SoList:
127
-
128
- | Name | Description |
129
- | ------------- | ------------- |
130
- |`solist[Symbol.iterator]()`|Returns an iterator that yields the value of each index in the SoList|
131
- |`at()`|Returns the value at a given index|
132
- |`concat()`|Returns a new SoList consisting of merging the existing SoList with given iterable inputs|
133
- |`constructor`|Creates a new empty SoList instance or from a given iterable|
134
- |`copyWithin()`|Shallow copies part of a SoList to another location in the same SoList and returns it|
135
- |`entries()`|Returns a SoList iterator object of key/value pairs|
136
- |`every()`|Checks if every element in a SoList satisfies a predicate function|
137
- |`fill()`|Changes all elements in a SoList to a static value|
138
- |`filter()`|Creates a new SoList with every element in a SoList that satisfies a predicate function|
139
- |`find()`|Returns the value of the first element in a SoList that satisfies a predicate function|
140
- |`findIndex()`|Returns the index of the first element in a SoList that satisfies a predicate function|
141
- |`findLast()`|Returns the value of the last element in a SoList that satisfies a predicate function|
142
- |`findLastIndex()`|Returns the index of the last element in a SoList that satisfies a predicate function|
143
- |`flat()`|Creates a new SoList with all sub-SoList elements concatenated into it recursively up to the specified depth|
144
- |`forEach()`|Executes a provided function once for each SoList element|
145
- |`includes()`|Determines whether a SoList includes a certain value among its entries|
146
- |`indexOf()`|Returns the first index at which a given element can be found in a SoList|
147
- |`insert()`|Adds an element into a specific index of a SoList|
148
- |`isEmpty()`|Checks if the SoList does not contain any elements|
149
- |`isEqual()`|Checks if the SoList is equal to a given iterable|
150
- |`join()`|Joins all elements of SoList into a string separated by commas or a specified separator string|
151
- |`keys()`|Returns a SoList iterator object of keys|
152
- |`lastIndexOf()`|Returns the last index at which a given element can be found in a SoList|
153
- |`map()`|Creates a new SoList populated with the results of calling a provided function on every element of a SoList|
154
- |`pop()`|Removes the last element from a SoList and returns that element|
155
- |`push()`|Adds one or more elements to the end of a SoList and returns the new length of the SoList|
156
- |`reduce()`|Reduces the values of a SoList to a single value (going left-to-right)|
157
- |`reduceRight()`|Reduces the values of a SoList to a single value (going right-to-left)|
158
- |`remove()`|Removes an element by a specific index from a SoList|
159
- |`reverse()`|Reverses the order of the elements in a SoList|
160
- |`shift()`|removes the first element from a SoList and returns that removed element|
161
- |`slice()`|Returns a shallow copy of a portion of a SoList into a new SoList selected by positions|
162
- |`some()`|Checks if any of the elements in a SoList satisfy a predicate function|
163
- |`sort()`|Sorts the elements of a SoList and returns the reference to the same SoList, now sorted|
164
- |`splice()`|Changes the contents of a SoList by removing or replacing existing elements and/or adding new elements|
165
- |`toLocaleString()`|Returns a string representing the elements of the SoList using their `toLocaleString` methods|
166
- |`toString()`|Returns a string representing the specified SoList and its elements|
167
- |`unshift()`|Adds one or more elements to the beginning of a SoList and returns the new length of the SoList|
168
- |`values()`|Returns a SoList iterator object of values|
169
-
170
- ## SoList vs JS-Array
171
- Although SoList implements most of the methods of JS-Array (with identical behavior), there are several differences and limitations:
172
- - Unlike JS-Array, SoList does not support empty items (for example `[1,,3]`).
173
- - Currently, the `every()`, `filter()`, `find()`, `findIndex()`, `findLast()`, `findLastIndex()`, `flatMap()` and `some()` don't support the `thisArg` argument.
174
- - Unsupported JS-Array methods: `group()` and `groupToMap()`.
175
- - Additional custom methods of SoList: `insert()`, `isEmpty()`, `isEqual()` and `remove()`.
176
118
 
177
- ## Contributing
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>
178
125
 
179
- Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
126
+ ## How It Works
180
127
 
181
- Please make sure to update tests as appropriate and run existing ones using:
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.
182
129
 
130
+ **Supported heuristics:**
131
+
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`:
141
+
142
+ ```javascript
143
+ const l = new MoveToFrontSoList([1, 2, 3], { accessOnly: false });
183
144
  ```
184
- npm run test
185
- ```
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 |
206
+
207
+ ## Contributing
208
+
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).
186
210
 
187
211
  ## License
188
212
 
189
- The library is freely distributable under the terms of the [MIT license](LICENSE).
213
+ The library is freely distributable under the terms of the [MIT license](LICENSE).
@@ -1,66 +1,83 @@
1
- import { Node } from './Node';
2
- export declare class DoublyLinkedList {
3
- length: number;
4
- protected head: Node | null;
5
- protected tail: Node | null;
6
- protected rearrangeOnCreation: boolean;
7
- constructor(rearrangeOnCreation?: boolean, iterable?: null);
8
- [Symbol.iterator](): Generator<any, any, unknown>;
9
- at(index: number): unknown;
10
- concat(...values: any[]): DoublyLinkedList;
11
- copyWithin(target: any, start: any): DoublyLinkedList;
12
- entries(): Generator<any, any, unknown>;
13
- every(callbackFn: any): boolean;
14
- fill(value: any): DoublyLinkedList;
15
- filter(callbackFn: any): DoublyLinkedList;
16
- find(callbackFn: any): unknown;
17
- findIndex(callbackFn: any): number;
18
- findLast(callbackFn: any): unknown;
19
- findLastIndex(callbackFn: any): any;
20
- flat(depth?: number): DoublyLinkedList;
21
- flatMap(callbackFn: any): DoublyLinkedList;
22
- forEach(callbackFn: any): void;
23
- includes(searchedValue: any, fromIndex: any): boolean;
24
- indexOf(searchedValue: any, fromIndex?: number): number;
25
- join(separator: any): string;
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
- lastIndexOf(searchElement: any): number;
28
- map(callbackFn: any): DoublyLinkedList;
29
- pop(): unknown;
30
- push(...values: any): number;
31
- reduce(callbackFn: any, initialValue: any): any;
32
- reduceRight(callbackFn: any, initialValue: any): any;
33
- reverse(): DoublyLinkedList;
34
- shift(): unknown;
35
- slice(startIndex: any, endIndex: any): DoublyLinkedList;
36
- some(callbackFn: any): boolean;
37
- sort(comparefn: any): DoublyLinkedList;
38
- splice(start: any, deleteCount: any): DoublyLinkedList;
39
- toLocaleString(locales: any, options: any): string;
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(...values: any): number;
42
- values(): Generator<any, any, unknown>;
43
- insert(index: any, value: any): number | undefined;
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(value: any): boolean;
46
- remove(index: any): any;
47
- protected _getIndexByNode(node: Node): number;
48
- protected _getNode(index: number): Node | null;
49
- protected _insertFirst(newNode: Node): void;
50
- protected _insertBefore(existingNode: Node, newNode: Node): void;
51
- protected _insertAfter(existingNode: Node, newNode: Node): void;
52
- protected _rearrange(node: Node): number | undefined;
53
- protected _remove(node: Node): void;
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;