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 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
- # Self-organizing lists in TypeScript
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
- 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.
4
-
5
- ## Introduction
21
+ ## Installation
6
22
 
7
- 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.
23
+ ```sh
24
+ npm install solists
25
+ ```
8
26
 
9
- ### Self-organizing techniques
27
+ ## Example
10
28
 
11
- #### Frequency Count
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
- 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.
37
+ ```javascript
38
+ const { FrequencyCountSoList } = require("solists");
14
39
 
15
- Pseudocode:
16
- ```
17
- init: count(i) = 0 for each item i
18
- At t-th item selection:
19
- if item i is searched:
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
- #### 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>
25
54
 
26
- This technique moves the node which is accessed to the head of the list.
55
+ ```javascript
56
+ const { KInARowSoList } = require("solists");
27
57
 
28
- Pseudocode:
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
- At the t-th item selection:
31
- if item i is selected:
32
- move item i to head of the list
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
- #### Transpose
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
- This technique involves swapping an accessed node with its predecessor.
91
+ ```javascript
92
+ const { MoveToFrontSoList } = require("solists");
38
93
 
39
- Pseudocode:
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
- At the t-th item selection:
42
- if item i is selected:
43
- if i is not the head of list:
44
- swap item i with item (i - 1)
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
- ### Rearrange upon creation
48
- 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.
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
- 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 `rearrange_on_creation=true` when creating a new SoList instance. See the example below for more details.
126
+ ## How It Works
51
127
 
52
- Methods which perform rearrange of the list:
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
- ## Installation
57
- ```
58
- npm install solists
59
- ```
130
+ **Supported heuristics:**
60
131
 
61
- ## Example
62
- ```javascript
63
- const { FrequencyCountSoList, MoveToFrontSoList, TransposeSoList } = require("solists");
64
-
65
- /** Examples of SoList without rearrange upon creation **/
66
-
67
- // Example of SoList with Frequency Count heuristic
68
- const fcList1 = new FrequencyCountSoList(false,[1,2,3,4,5]);
69
- console.log(fcList1.toString()); // 1,2,3,4,5
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
- ## Methods and properties
113
-
114
- List of properties of SoList:
115
-
116
- | Name | Description |
117
- | ------------- | ------------- |
118
- |`length`|Represents the number of elements in that SoList|
119
-
120
- List of methods of SoList:
121
-
122
- | Name | Description |
123
- | ------------- | ------------- |
124
- |`solist[Symbol.iterator]()`|Returns an iterator that yields the value of each index in the SoList|
125
- |`at()`|Returns the value at a given index|
126
- |`concat()`|Returns a new SoList consisting of merging the existing SoList with given iterable inputs|
127
- |`constructor`|Creates a new empty SoList instance or from a given iterable|
128
- |`copyWithin()`|Shallow copies part of a SoList to another location in the same SoList and returns it|
129
- |`entries()`|Returns a SoList iterator object of key/value pairs|
130
- |`every()`|Checks if every element in a SoList satisfies a predicate function|
131
- |`fill()`|Changes all elements in a SoList to a static value|
132
- |`filter()`|Creates a new SoList with every element in a SoList that satisfies a predicate function|
133
- |`find()`|Returns the value of the first element in a SoList that satisfies a predicate function|
134
- |`findIndex()`|Returns the index of the first element in a SoList that satisfies a predicate function|
135
- |`findLast()`|Returns the value of the last element in a SoList that satisfies a predicate function|
136
- |`findLastIndex()`|Returns the index of the last element in a SoList that satisfies a predicate function|
137
- |`flat()`|Creates a new SoList with all sub-SoList elements concatenated into it recursively up to the specified depth|
138
- |`forEach()`|Executes a provided function once for each SoList element|
139
- |`includes()`|Determines whether a SoList includes a certain value among its entries|
140
- |`indexOf()`|Returns the first index at which a given element can be found in a SoList|
141
- |`insert()`|Adds an element into a specific index of a SoList|
142
- |`isEqual()`|Checks if the SoList is equal to a given iterable|
143
- |`isEmpty()`|Checks if the SoList does not contain any elements|
144
- |`join()`|Joins all elements of SoList into a string separated by commas or a specified separator string|
145
- |`keys()`|Returns a SoList iterator object of keys|
146
- |`lastIndexOf()`|Returns the last index at which a given element can be found in a SoList|
147
- |`map()`|Creates a new SoList populated with the results of calling a provided function on every element of a SoList|
148
- |`pop()`|Removes the last element from a SoList and returns that element|
149
- |`push()`|Adds one or more elements to the end of a SoList and returns the new length of the SoList|
150
- |`reduce()`|Reduces the values of a SoList to a single value (going left-to-right)|
151
- |`reduceRight()`|Reduces the values of a SoList to a single value (going right-to-left)|
152
- |`remove()`|Removes an element by a specific index from a SoList|
153
- |`reverse()`|Reverses the order of the elements in a SoList|
154
- |`shift()`|removes the first element from a SoList and returns that removed element|
155
- |`slice()`|Returns a shallow copy of a portion of a SoList into a new SoList selected by positions|
156
- |`some()`|Checks if any of the elements in a SoList satisfy a predicate function|
157
- |`sort()`|Sorts the elements of a SoList and returns the reference to the same SoList, now sorted|
158
- |`splice()`|Changes the contents of a SoList by removing or replacing existing elements and/or adding new elements|
159
- |`toLocaleString()`|Returns a string representing the elements of the SoList using their `toLocaleString` methods|
160
- |`toString()`|Returns a string representing the specified SoList and its elements|
161
- |`unshift()`|Adds one or more elements to the beginning of a SoList and returns the new length of the SoList|
162
- |`values()`|Returns a SoList iterator object of values|
163
-
164
- ## SoList vs JS-Array
165
- Although SoList implements most of the methods of JS-Array (with identical behavior), there are several differences and limitations:
166
- - Unlike JS-Array, SoList does not support empty items (for example `[1,,3]`).
167
- - Currently, the `every()`, `filter()`, `find()`, `findIndex()`, `findLast()`, `findLastIndex()`, `flatMap()` and `some()` don't support the `thisArg` argument.
168
- - Unsupported JS-Array methods: `group()` and `groupToMap()`.
169
- - Additional custom methods of SoList: `insert()`, `isEqual()`, `isEmpty()` and `remove()`.
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
- Please make sure to update tests as appropriate and run existing ones using:
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 './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;