data-structure-typed 1.54.3 → 2.0.1
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/CHANGELOG.md +1 -1
- package/benchmark/report.html +26 -2
- package/benchmark/report.json +292 -42
- package/dist/cjs/data-structures/base/iterable-element-base.d.ts +14 -40
- package/dist/cjs/data-structures/base/iterable-element-base.js +14 -11
- package/dist/cjs/data-structures/base/iterable-element-base.js.map +1 -1
- package/dist/cjs/data-structures/base/linear-base.d.ts +277 -0
- package/dist/cjs/data-structures/base/linear-base.js +553 -0
- package/dist/cjs/data-structures/base/linear-base.js.map +1 -0
- package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.d.ts +12 -8
- package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.js +50 -37
- package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/avl-tree.d.ts +64 -0
- package/dist/cjs/data-structures/binary-tree/avl-tree.js +64 -0
- package/dist/cjs/data-structures/binary-tree/avl-tree.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/binary-tree.d.ts +62 -0
- package/dist/cjs/data-structures/binary-tree/binary-tree.js +67 -5
- package/dist/cjs/data-structures/binary-tree/binary-tree.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/bst.d.ts +3 -3
- package/dist/cjs/data-structures/binary-tree/bst.js +14 -14
- package/dist/cjs/data-structures/binary-tree/bst.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/red-black-tree.d.ts +1 -7
- package/dist/cjs/data-structures/binary-tree/red-black-tree.js +1 -7
- package/dist/cjs/data-structures/binary-tree/red-black-tree.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/tree-multi-map.d.ts +175 -14
- package/dist/cjs/data-structures/binary-tree/tree-multi-map.js +210 -40
- package/dist/cjs/data-structures/binary-tree/tree-multi-map.js.map +1 -1
- package/dist/cjs/data-structures/graph/abstract-graph.js +16 -16
- package/dist/cjs/data-structures/graph/abstract-graph.js.map +1 -1
- package/dist/cjs/data-structures/hash/hash-map.d.ts +46 -0
- package/dist/cjs/data-structures/hash/hash-map.js +46 -0
- package/dist/cjs/data-structures/hash/hash-map.js.map +1 -1
- package/dist/cjs/data-structures/heap/heap.d.ts +3 -11
- package/dist/cjs/data-structures/heap/heap.js +0 -10
- package/dist/cjs/data-structures/heap/heap.js.map +1 -1
- package/dist/cjs/data-structures/heap/max-heap.d.ts +2 -2
- package/dist/cjs/data-structures/heap/max-heap.js.map +1 -1
- package/dist/cjs/data-structures/heap/min-heap.d.ts +2 -2
- package/dist/cjs/data-structures/heap/min-heap.js.map +1 -1
- package/dist/cjs/data-structures/linked-list/doubly-linked-list.d.ts +65 -94
- package/dist/cjs/data-structures/linked-list/doubly-linked-list.js +131 -146
- package/dist/cjs/data-structures/linked-list/doubly-linked-list.js.map +1 -1
- package/dist/cjs/data-structures/linked-list/singly-linked-list.d.ts +145 -75
- package/dist/cjs/data-structures/linked-list/singly-linked-list.js +283 -169
- package/dist/cjs/data-structures/linked-list/singly-linked-list.js.map +1 -1
- package/dist/cjs/data-structures/priority-queue/max-priority-queue.d.ts +2 -2
- package/dist/cjs/data-structures/priority-queue/max-priority-queue.js.map +1 -1
- package/dist/cjs/data-structures/priority-queue/min-priority-queue.d.ts +2 -2
- package/dist/cjs/data-structures/priority-queue/min-priority-queue.js.map +1 -1
- package/dist/cjs/data-structures/priority-queue/priority-queue.d.ts +2 -2
- package/dist/cjs/data-structures/priority-queue/priority-queue.js.map +1 -1
- package/dist/cjs/data-structures/queue/deque.d.ts +130 -91
- package/dist/cjs/data-structures/queue/deque.js +269 -169
- package/dist/cjs/data-structures/queue/deque.js.map +1 -1
- package/dist/cjs/data-structures/queue/queue.d.ts +131 -40
- package/dist/cjs/data-structures/queue/queue.js +181 -50
- package/dist/cjs/data-structures/queue/queue.js.map +1 -1
- package/dist/cjs/data-structures/stack/stack.d.ts +124 -11
- package/dist/cjs/data-structures/stack/stack.js +121 -10
- package/dist/cjs/data-structures/stack/stack.js.map +1 -1
- package/dist/cjs/data-structures/trie/trie.d.ts +4 -3
- package/dist/cjs/data-structures/trie/trie.js +3 -0
- package/dist/cjs/data-structures/trie/trie.js.map +1 -1
- package/dist/cjs/types/data-structures/base/base.d.ts +9 -4
- package/dist/cjs/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +1 -1
- package/dist/cjs/types/data-structures/binary-tree/tree-multi-map.d.ts +1 -1
- package/dist/cjs/types/data-structures/linked-list/doubly-linked-list.d.ts +2 -2
- package/dist/cjs/types/data-structures/linked-list/singly-linked-list.d.ts +2 -2
- package/dist/cjs/types/data-structures/queue/deque.d.ts +2 -3
- package/dist/cjs/types/data-structures/queue/queue.d.ts +2 -2
- package/dist/esm/data-structures/base/iterable-element-base.d.ts +14 -40
- package/dist/esm/data-structures/base/iterable-element-base.js +14 -11
- package/dist/esm/data-structures/base/iterable-element-base.js.map +1 -1
- package/dist/esm/data-structures/base/linear-base.d.ts +277 -0
- package/dist/esm/data-structures/base/linear-base.js +549 -0
- package/dist/esm/data-structures/base/linear-base.js.map +1 -0
- package/dist/esm/data-structures/binary-tree/avl-tree-multi-map.d.ts +12 -8
- package/dist/esm/data-structures/binary-tree/avl-tree-multi-map.js +50 -36
- package/dist/esm/data-structures/binary-tree/avl-tree-multi-map.js.map +1 -1
- package/dist/esm/data-structures/binary-tree/avl-tree.d.ts +64 -0
- package/dist/esm/data-structures/binary-tree/avl-tree.js +64 -0
- package/dist/esm/data-structures/binary-tree/avl-tree.js.map +1 -1
- package/dist/esm/data-structures/binary-tree/binary-tree.d.ts +62 -0
- package/dist/esm/data-structures/binary-tree/binary-tree.js +67 -5
- package/dist/esm/data-structures/binary-tree/binary-tree.js.map +1 -1
- package/dist/esm/data-structures/binary-tree/bst.d.ts +3 -3
- package/dist/esm/data-structures/binary-tree/bst.js +14 -12
- package/dist/esm/data-structures/binary-tree/bst.js.map +1 -1
- package/dist/esm/data-structures/binary-tree/red-black-tree.d.ts +1 -7
- package/dist/esm/data-structures/binary-tree/red-black-tree.js +1 -7
- package/dist/esm/data-structures/binary-tree/red-black-tree.js.map +1 -1
- package/dist/esm/data-structures/binary-tree/tree-multi-map.d.ts +175 -14
- package/dist/esm/data-structures/binary-tree/tree-multi-map.js +210 -39
- package/dist/esm/data-structures/binary-tree/tree-multi-map.js.map +1 -1
- package/dist/esm/data-structures/graph/abstract-graph.js +16 -16
- package/dist/esm/data-structures/graph/abstract-graph.js.map +1 -1
- package/dist/esm/data-structures/hash/hash-map.d.ts +46 -0
- package/dist/esm/data-structures/hash/hash-map.js +46 -0
- package/dist/esm/data-structures/hash/hash-map.js.map +1 -1
- package/dist/esm/data-structures/heap/heap.d.ts +3 -11
- package/dist/esm/data-structures/heap/heap.js +0 -10
- package/dist/esm/data-structures/heap/heap.js.map +1 -1
- package/dist/esm/data-structures/heap/max-heap.d.ts +2 -2
- package/dist/esm/data-structures/heap/max-heap.js.map +1 -1
- package/dist/esm/data-structures/heap/min-heap.d.ts +2 -2
- package/dist/esm/data-structures/heap/min-heap.js.map +1 -1
- package/dist/esm/data-structures/linked-list/doubly-linked-list.d.ts +65 -94
- package/dist/esm/data-structures/linked-list/doubly-linked-list.js +132 -148
- package/dist/esm/data-structures/linked-list/doubly-linked-list.js.map +1 -1
- package/dist/esm/data-structures/linked-list/singly-linked-list.d.ts +145 -75
- package/dist/esm/data-structures/linked-list/singly-linked-list.js +283 -170
- package/dist/esm/data-structures/linked-list/singly-linked-list.js.map +1 -1
- package/dist/esm/data-structures/priority-queue/max-priority-queue.d.ts +2 -2
- package/dist/esm/data-structures/priority-queue/max-priority-queue.js.map +1 -1
- package/dist/esm/data-structures/priority-queue/min-priority-queue.d.ts +2 -2
- package/dist/esm/data-structures/priority-queue/min-priority-queue.js.map +1 -1
- package/dist/esm/data-structures/priority-queue/priority-queue.d.ts +2 -2
- package/dist/esm/data-structures/priority-queue/priority-queue.js.map +1 -1
- package/dist/esm/data-structures/queue/deque.d.ts +130 -91
- package/dist/esm/data-structures/queue/deque.js +269 -169
- package/dist/esm/data-structures/queue/deque.js.map +1 -1
- package/dist/esm/data-structures/queue/queue.d.ts +131 -40
- package/dist/esm/data-structures/queue/queue.js +182 -51
- package/dist/esm/data-structures/queue/queue.js.map +1 -1
- package/dist/esm/data-structures/stack/stack.d.ts +124 -11
- package/dist/esm/data-structures/stack/stack.js +121 -10
- package/dist/esm/data-structures/stack/stack.js.map +1 -1
- package/dist/esm/data-structures/trie/trie.d.ts +4 -3
- package/dist/esm/data-structures/trie/trie.js +3 -0
- package/dist/esm/data-structures/trie/trie.js.map +1 -1
- package/dist/esm/types/data-structures/base/base.d.ts +9 -4
- package/dist/esm/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +1 -1
- package/dist/esm/types/data-structures/binary-tree/tree-multi-map.d.ts +1 -1
- package/dist/esm/types/data-structures/linked-list/doubly-linked-list.d.ts +2 -2
- package/dist/esm/types/data-structures/linked-list/singly-linked-list.d.ts +2 -2
- package/dist/esm/types/data-structures/queue/deque.d.ts +2 -3
- package/dist/esm/types/data-structures/queue/queue.d.ts +2 -2
- package/dist/individuals/binary-tree/avl-tree-counter.mjs +4701 -0
- package/dist/individuals/binary-tree/avl-tree-multi-map.mjs +4514 -0
- package/dist/individuals/binary-tree/avl-tree.mjs +4321 -0
- package/dist/individuals/binary-tree/binary-tree.mjs +3097 -0
- package/dist/individuals/binary-tree/bst.mjs +3858 -0
- package/dist/individuals/binary-tree/red-black-tree.mjs +4391 -0
- package/dist/individuals/binary-tree/tree-counter.mjs +4806 -0
- package/dist/individuals/binary-tree/tree-multi-map.mjs +4582 -0
- package/dist/individuals/graph/directed-graph.mjs +2910 -0
- package/dist/individuals/graph/undirected-graph.mjs +2745 -0
- package/dist/individuals/hash/hash-map.mjs +1040 -0
- package/dist/individuals/heap/heap.mjs +909 -0
- package/dist/individuals/heap/max-heap.mjs +671 -0
- package/dist/individuals/heap/min-heap.mjs +659 -0
- package/dist/individuals/linked-list/doubly-linked-list.mjs +1495 -0
- package/dist/individuals/linked-list/singly-linked-list.mjs +1479 -0
- package/dist/individuals/priority-queue/max-priority-queue.mjs +768 -0
- package/dist/individuals/priority-queue/min-priority-queue.mjs +757 -0
- package/dist/individuals/priority-queue/priority-queue.mjs +670 -0
- package/dist/individuals/queue/deque.mjs +1262 -0
- package/dist/individuals/queue/queue.mjs +1865 -0
- package/dist/individuals/stack/stack.mjs +415 -0
- package/dist/individuals/trie/trie.mjs +687 -0
- package/dist/umd/data-structure-typed.js +1260 -649
- package/dist/umd/data-structure-typed.min.js +3 -3
- package/dist/umd/data-structure-typed.min.js.map +1 -1
- package/package.json +7 -7
- package/src/data-structures/base/iterable-element-base.ts +29 -20
- package/src/data-structures/base/linear-base.ts +649 -0
- package/src/data-structures/binary-tree/avl-tree-multi-map.ts +51 -36
- package/src/data-structures/binary-tree/avl-tree.ts +64 -0
- package/src/data-structures/binary-tree/binary-tree.ts +5 -5
- package/src/data-structures/binary-tree/bst.ts +9 -9
- package/src/data-structures/binary-tree/tree-multi-map.ts +214 -40
- package/src/data-structures/graph/abstract-graph.ts +16 -16
- package/src/data-structures/hash/hash-map.ts +46 -0
- package/src/data-structures/heap/heap.ts +3 -14
- package/src/data-structures/heap/max-heap.ts +2 -2
- package/src/data-structures/heap/min-heap.ts +2 -2
- package/src/data-structures/linked-list/doubly-linked-list.ts +144 -160
- package/src/data-structures/linked-list/singly-linked-list.ts +307 -185
- package/src/data-structures/priority-queue/max-priority-queue.ts +2 -5
- package/src/data-structures/priority-queue/min-priority-queue.ts +2 -5
- package/src/data-structures/priority-queue/priority-queue.ts +2 -2
- package/src/data-structures/queue/deque.ts +286 -183
- package/src/data-structures/queue/queue.ts +196 -63
- package/src/data-structures/stack/stack.ts +124 -18
- package/src/data-structures/trie/trie.ts +7 -3
- package/src/types/data-structures/base/base.ts +17 -8
- package/src/types/data-structures/binary-tree/avl-tree-multi-map.ts +1 -1
- package/src/types/data-structures/binary-tree/tree-multi-map.ts +1 -1
- package/src/types/data-structures/linked-list/doubly-linked-list.ts +2 -2
- package/src/types/data-structures/linked-list/singly-linked-list.ts +2 -2
- package/src/types/data-structures/queue/deque.ts +2 -3
- package/src/types/data-structures/queue/queue.ts +2 -2
- package/test/integration/all-in-one.test.ts +1 -1
- package/test/integration/avl-tree.test.ts +1 -1
- package/test/integration/bst.test.ts +2 -2
- package/test/unit/data-structures/binary-tree/avl-tree-multi-map.test.ts +168 -0
- package/test/unit/data-structures/binary-tree/avl-tree.test.ts +15 -14
- package/test/unit/data-structures/binary-tree/red-black-tree.test.ts +1 -1
- package/test/unit/data-structures/binary-tree/tree-multi-map.test.ts +165 -7
- package/test/unit/data-structures/graph/directed-graph.test.ts +37 -37
- package/test/unit/data-structures/graph/undirected-graph.test.ts +2 -2
- package/test/unit/data-structures/hash/hash-map.test.ts +135 -0
- package/test/unit/data-structures/linked-list/doubly-linked-list.test.ts +135 -27
- package/test/unit/data-structures/linked-list/singly-linked-list.test.ts +183 -12
- package/test/unit/data-structures/queue/deque.test.ts +241 -60
- package/test/unit/data-structures/queue/queue.test.ts +332 -19
- package/test/unit/data-structures/stack/stack.test.ts +165 -0
- package/test/unit/unrestricted-interconversion.test.ts +1 -1
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
import { ElementCallback, LinearBaseOptions, ReduceLinearCallback } from '../../types';
|
|
2
|
+
import { IterableElementBase } from './iterable-element-base';
|
|
3
|
+
export declare class LinkedListNode<E = any> {
|
|
4
|
+
constructor(value: E);
|
|
5
|
+
protected _value: E;
|
|
6
|
+
get value(): E;
|
|
7
|
+
set value(value: E);
|
|
8
|
+
protected _next: LinkedListNode<E> | undefined;
|
|
9
|
+
get next(): LinkedListNode<E> | undefined;
|
|
10
|
+
set next(value: LinkedListNode<E> | undefined);
|
|
11
|
+
}
|
|
12
|
+
export declare abstract class LinearBase<E, R = any, NODE extends LinkedListNode<E> = LinkedListNode<E>> extends IterableElementBase<E, R> {
|
|
13
|
+
/**
|
|
14
|
+
* The constructor initializes the LinearBase class with optional options, setting the maximum length
|
|
15
|
+
* if provided.
|
|
16
|
+
* @param [options] - The `options` parameter is an optional object that can be passed to the
|
|
17
|
+
* constructor. It is of type `LinearBaseOptions<E, R>`. The constructor checks if the `options`
|
|
18
|
+
* object is provided and then extracts the `maxLen` property from it. If `maxLen` is a
|
|
19
|
+
*/
|
|
20
|
+
protected constructor(options?: LinearBaseOptions<E, R>);
|
|
21
|
+
abstract get length(): number;
|
|
22
|
+
protected _maxLen: number;
|
|
23
|
+
get maxLen(): number;
|
|
24
|
+
/**
|
|
25
|
+
* Time Complexity: O(n)
|
|
26
|
+
* Space Complexity: O(1)
|
|
27
|
+
*
|
|
28
|
+
* The function indexOf searches for a specified element starting from a given index in an array-like
|
|
29
|
+
* object and returns the index of the first occurrence, or -1 if not found.
|
|
30
|
+
* @param {E} searchElement - The `searchElement` parameter in the `indexOf` function represents the
|
|
31
|
+
* element that you want to find within the array. The function will search for this element starting
|
|
32
|
+
* from the `fromIndex` (if provided) up to the end of the array. If the `searchElement` is found
|
|
33
|
+
* within the
|
|
34
|
+
* @param {number} [fromIndex=0] - The `fromIndex` parameter in the `indexOf` function represents the
|
|
35
|
+
* index at which to start searching for the `searchElement` within the array. If provided, the
|
|
36
|
+
* search will begin at this index and continue to the end of the array. If `fromIndex` is not
|
|
37
|
+
* specified, the default
|
|
38
|
+
* @returns The `indexOf` method is returning the index of the `searchElement` if it is found in the
|
|
39
|
+
* array starting from the `fromIndex`. If the `searchElement` is not found, it returns -1.
|
|
40
|
+
*/
|
|
41
|
+
indexOf(searchElement: E, fromIndex?: number): number;
|
|
42
|
+
/**
|
|
43
|
+
* Time Complexity: O(n)
|
|
44
|
+
* Space Complexity: O(1)
|
|
45
|
+
*
|
|
46
|
+
* The function `lastIndexOf` in TypeScript returns the index of the last occurrence of a specified
|
|
47
|
+
* element in an array.
|
|
48
|
+
* @param {E} searchElement - The `searchElement` parameter is the element that you want to find the
|
|
49
|
+
* last index of within the array. The `lastIndexOf` method will search the array starting from the
|
|
50
|
+
* `fromIndex` (or the end of the array if not specified) and return the index of the last occurrence
|
|
51
|
+
* of the
|
|
52
|
+
* @param {number} fromIndex - The `fromIndex` parameter in the `lastIndexOf` method specifies the
|
|
53
|
+
* index at which to start searching for the `searchElement` in the array. By default, it starts
|
|
54
|
+
* searching from the last element of the array (`this.length - 1`). If a specific `fromIndex` is
|
|
55
|
+
* provided
|
|
56
|
+
* @returns The last index of the `searchElement` in the array is being returned. If the
|
|
57
|
+
* `searchElement` is not found in the array, -1 is returned.
|
|
58
|
+
*/
|
|
59
|
+
lastIndexOf(searchElement: E, fromIndex?: number): number;
|
|
60
|
+
/**
|
|
61
|
+
* Time Complexity: O(n)
|
|
62
|
+
* Space Complexity: O(1)
|
|
63
|
+
*
|
|
64
|
+
* The `findIndex` function iterates over an array and returns the index of the first element that
|
|
65
|
+
* satisfies the provided predicate function.
|
|
66
|
+
* @param predicate - The `predicate` parameter in the `findIndex` function is a callback function
|
|
67
|
+
* that takes three arguments: `item`, `index`, and the array `this`. It should return a boolean
|
|
68
|
+
* value indicating whether the current element satisfies the condition being checked for.
|
|
69
|
+
* @param {any} [thisArg] - The `thisArg` parameter in the `findIndex` function is an optional
|
|
70
|
+
* parameter that specifies the value to use as `this` when executing the `predicate` function. If
|
|
71
|
+
* provided, the `predicate` function will be called with `thisArg` as its `this` value. If `
|
|
72
|
+
* @returns The `findIndex` method is returning the index of the first element in the array that
|
|
73
|
+
* satisfies the provided predicate function. If no such element is found, it returns -1.
|
|
74
|
+
*/
|
|
75
|
+
findIndex(predicate: ElementCallback<E, R, boolean>, thisArg?: any): number;
|
|
76
|
+
concat(...items: this[]): this;
|
|
77
|
+
/**
|
|
78
|
+
* Time Complexity: O(n log n)
|
|
79
|
+
* Space Complexity: O(n)
|
|
80
|
+
*
|
|
81
|
+
* The `sort` function in TypeScript sorts the elements of a collection using a specified comparison
|
|
82
|
+
* function.
|
|
83
|
+
* @param [compareFn] - The `compareFn` parameter is a function that defines the sort order. It takes
|
|
84
|
+
* two elements `a` and `b` as input and returns a number indicating their relative order. If the
|
|
85
|
+
* returned value is negative, `a` comes before `b`. If the returned value is positive, `
|
|
86
|
+
* @returns The `sort` method is returning the instance of the object on which it is called (this),
|
|
87
|
+
* after sorting the elements based on the provided comparison function (compareFn).
|
|
88
|
+
*/
|
|
89
|
+
sort(compareFn?: (a: E, b: E) => number): this;
|
|
90
|
+
/**
|
|
91
|
+
* Time Complexity: O(n + m)
|
|
92
|
+
* Space Complexity: O(m)
|
|
93
|
+
*
|
|
94
|
+
* The `splice` function in TypeScript removes elements from an array and optionally inserts new
|
|
95
|
+
* elements at the specified index.
|
|
96
|
+
* @param {number} start - The `start` parameter in the `splice` method indicates the index at which
|
|
97
|
+
* to start modifying the array. If `start` is a negative number, it will count from the end of the
|
|
98
|
+
* array.
|
|
99
|
+
* @param {number} [deleteCount=0] - The `deleteCount` parameter in the `splice` method specifies the
|
|
100
|
+
* number of elements to remove from the array starting at the specified `start` index. If
|
|
101
|
+
* `deleteCount` is not provided or is 0, no elements are removed, and only new elements are inserted
|
|
102
|
+
* at the `start`
|
|
103
|
+
* @param {E[]} items - The `items` parameter in the `splice` method represents the elements that
|
|
104
|
+
* will be inserted into the array at the specified `start` index. These elements can be of any type
|
|
105
|
+
* and you can pass multiple elements separated by commas. The `splice` method will insert these
|
|
106
|
+
* items into the array at the
|
|
107
|
+
* @returns The `splice` method returns a list of elements that were removed from the original list
|
|
108
|
+
* during the operation.
|
|
109
|
+
*/
|
|
110
|
+
splice(start: number, deleteCount?: number, ...items: E[]): this;
|
|
111
|
+
/**
|
|
112
|
+
* Time Complexity: O(n)
|
|
113
|
+
* Space Complexity: O(1)
|
|
114
|
+
*
|
|
115
|
+
* The `join` function in TypeScript returns a string by joining the elements of an array with a
|
|
116
|
+
* specified separator.
|
|
117
|
+
* @param {string} [separator=,] - The `separator` parameter is a string that specifies the character
|
|
118
|
+
* or characters that will be used to separate each element when joining them into a single string.
|
|
119
|
+
* By default, the separator is set to a comma (`,`), but you can provide a different separator if
|
|
120
|
+
* needed.
|
|
121
|
+
* @returns The `join` method is being returned, which takes an optional `separator` parameter
|
|
122
|
+
* (defaulting to a comma) and returns a string created by joining all elements of the array after
|
|
123
|
+
* converting it to an array.
|
|
124
|
+
*/
|
|
125
|
+
join(separator?: string): string;
|
|
126
|
+
/**
|
|
127
|
+
* Time Complexity: O(n)
|
|
128
|
+
* Space Complexity: O(n)
|
|
129
|
+
*
|
|
130
|
+
* The function `toReversedArray` takes an array and returns a new array with its elements in reverse
|
|
131
|
+
* order.
|
|
132
|
+
* @returns The `toReversedArray()` function returns an array of elements of type `E` in reverse
|
|
133
|
+
* order.
|
|
134
|
+
*/
|
|
135
|
+
toReversedArray(): E[];
|
|
136
|
+
reduceRight(callbackfn: ReduceLinearCallback<E>): E;
|
|
137
|
+
reduceRight(callbackfn: ReduceLinearCallback<E>, initialValue: E): E;
|
|
138
|
+
reduceRight<U>(callbackfn: ReduceLinearCallback<E, U>, initialValue: U): U;
|
|
139
|
+
/**
|
|
140
|
+
* Time Complexity: O(m)
|
|
141
|
+
* Space Complexity: O(m)
|
|
142
|
+
*
|
|
143
|
+
* The `slice` function in TypeScript creates a new instance by extracting a portion of elements from
|
|
144
|
+
* the original instance based on the specified start and end indices.
|
|
145
|
+
* @param {number} [start=0] - The `start` parameter in the `slice` method represents the index at
|
|
146
|
+
* which to begin extracting elements from an array-like object. If no `start` parameter is provided,
|
|
147
|
+
* the default value is 0, meaning the extraction will start from the beginning of the array.
|
|
148
|
+
* @param {number} end - The `end` parameter in the `slice` method represents the index at which to
|
|
149
|
+
* end the slicing. By default, if no `end` parameter is provided, it will slice until the end of the
|
|
150
|
+
* array (i.e., `this.length`).
|
|
151
|
+
* @returns The `slice` method is returning a new instance of the object with elements sliced from
|
|
152
|
+
* the specified start index (default is 0) to the specified end index (default is the length of the
|
|
153
|
+
* object).
|
|
154
|
+
*/
|
|
155
|
+
slice(start?: number, end?: number): this;
|
|
156
|
+
/**
|
|
157
|
+
* Time Complexity: O(n)
|
|
158
|
+
* Space Complexity: O(1)
|
|
159
|
+
*
|
|
160
|
+
* The `fill` function in TypeScript fills a specified range in an array-like object with a given
|
|
161
|
+
* value.
|
|
162
|
+
* @param {E} value - The `value` parameter in the `fill` method represents the element that will be
|
|
163
|
+
* used to fill the specified range in the array.
|
|
164
|
+
* @param [start=0] - The `start` parameter specifies the index at which to start filling the array
|
|
165
|
+
* with the specified value. If not provided, it defaults to 0, indicating the beginning of the
|
|
166
|
+
* array.
|
|
167
|
+
* @param end - The `end` parameter in the `fill` function represents the index at which the filling
|
|
168
|
+
* of values should stop. It specifies the end of the range within the array where the `value` should
|
|
169
|
+
* be filled.
|
|
170
|
+
* @returns The `fill` method is returning the modified object (`this`) after filling the specified
|
|
171
|
+
* range with the provided value.
|
|
172
|
+
*/
|
|
173
|
+
fill(value: E, start?: number, end?: number): this;
|
|
174
|
+
abstract setAt(index: number, value: E): boolean;
|
|
175
|
+
abstract clone(): this;
|
|
176
|
+
abstract reverse(): this;
|
|
177
|
+
abstract push(elementOrNode: E | NODE): boolean;
|
|
178
|
+
abstract pushMany(elements: Iterable<E> | Iterable<R> | Iterable<NODE>): boolean[];
|
|
179
|
+
abstract delete(elementOrNode: E | NODE | undefined): boolean;
|
|
180
|
+
abstract at(index: number): E | undefined;
|
|
181
|
+
abstract deleteAt(pos: number): E | undefined;
|
|
182
|
+
abstract addAt(index: number, newElementOrNode: E | NODE): boolean;
|
|
183
|
+
protected abstract _createInstance(options?: LinearBaseOptions<E, R>): this;
|
|
184
|
+
protected abstract _getReverseIterator(...args: any[]): IterableIterator<E>;
|
|
185
|
+
}
|
|
186
|
+
export declare abstract class LinearLinkedBase<E, R = any, NODE extends LinkedListNode<E> = LinkedListNode<E>> extends LinearBase<E, R, NODE> {
|
|
187
|
+
/**
|
|
188
|
+
* The constructor initializes the LinearBase class with optional options, setting the maximum length
|
|
189
|
+
* if provided and valid.
|
|
190
|
+
* @param [options] - The `options` parameter is an optional object that can be passed to the
|
|
191
|
+
* constructor. It is of type `LinearBaseOptions<E, R>`. This object may contain properties such as
|
|
192
|
+
* `maxLen`, which is a number representing the maximum length. If `maxLen` is a positive integer,
|
|
193
|
+
*/
|
|
194
|
+
protected constructor(options?: LinearBaseOptions<E, R>);
|
|
195
|
+
/**
|
|
196
|
+
* Time Complexity: O(n)
|
|
197
|
+
* Space Complexity: O(1)
|
|
198
|
+
*
|
|
199
|
+
* The function overrides the indexOf method to improve performance by searching for an element in a
|
|
200
|
+
* custom array implementation starting from a specified index.
|
|
201
|
+
* @param {E} searchElement - The `searchElement` parameter is the element that you are searching for
|
|
202
|
+
* within the array. The `indexOf` method will return the index of the first occurrence of this
|
|
203
|
+
* element within the array.
|
|
204
|
+
* @param {number} [fromIndex=0] - The `fromIndex` parameter in the `indexOf` method specifies the
|
|
205
|
+
* index in the array at which to start the search for the `searchElement`. If provided, the search
|
|
206
|
+
* will begin at the specified index and continue to the end of the array. If not provided, the
|
|
207
|
+
* search will start at index
|
|
208
|
+
* @returns The `indexOf` method is returning the index of the `searchElement` if it is found in the
|
|
209
|
+
* array starting from the `fromIndex`. If the `searchElement` is not found, it returns -1.
|
|
210
|
+
*/
|
|
211
|
+
indexOf(searchElement: E, fromIndex?: number): number;
|
|
212
|
+
/**
|
|
213
|
+
* Time Complexity: O(n)
|
|
214
|
+
* Space Complexity: O(1)
|
|
215
|
+
*
|
|
216
|
+
* The function overrides the lastIndexOf method in TypeScript to improve performance by searching
|
|
217
|
+
* for an element in reverse order starting from a specified index.
|
|
218
|
+
* @param {E} searchElement - The `searchElement` parameter is the element that you want to find
|
|
219
|
+
* within the array. The `lastIndexOf` method searches the array for this element starting from the
|
|
220
|
+
* end of the array (or from the specified `fromIndex` if provided) and returns the index of the last
|
|
221
|
+
* occurrence of the element
|
|
222
|
+
* @param {number} fromIndex - The `fromIndex` parameter in the `lastIndexOf` method specifies the
|
|
223
|
+
* index at which to start searching for the `searchElement` in the array. If provided, the search
|
|
224
|
+
* will begin at this index and move towards the beginning of the array. If not provided, the search
|
|
225
|
+
* will start at the
|
|
226
|
+
* @returns The `lastIndexOf` method is being overridden to search for the `searchElement` starting
|
|
227
|
+
* from the specified `fromIndex` (defaulting to the end of the array). It iterates over the array in
|
|
228
|
+
* reverse order using a custom iterator `_getReverseIterator` and returns the index of the last
|
|
229
|
+
* occurrence of the `searchElement` if found, or -1 if not found.
|
|
230
|
+
*/
|
|
231
|
+
lastIndexOf(searchElement: E, fromIndex?: number): number;
|
|
232
|
+
concat(...items: LinearBase<E, R>[]): this;
|
|
233
|
+
/**
|
|
234
|
+
* Time Complexity: O(m)
|
|
235
|
+
* Space Complexity: O(m)
|
|
236
|
+
*
|
|
237
|
+
* The `slice` method is overridden to improve performance by creating a new instance and iterating
|
|
238
|
+
* through the array to extract a subset based on the specified start and end indices.
|
|
239
|
+
* @param {number} [start=0] - The `start` parameter in the `slice` method specifies the index at
|
|
240
|
+
* which to begin extracting elements from the array. If no `start` parameter is provided, the
|
|
241
|
+
* default value is 0, indicating that extraction should start from the beginning of the array.
|
|
242
|
+
* @param {number} end - The `end` parameter in the `slice` method represents the index at which to
|
|
243
|
+
* end the slicing of the array. If not provided, it defaults to the length of the array.
|
|
244
|
+
* @returns The `slice` method is returning a new instance of the array implementation with elements
|
|
245
|
+
* sliced from the original array based on the `start` and `end` parameters.
|
|
246
|
+
*/
|
|
247
|
+
slice(start?: number, end?: number): this;
|
|
248
|
+
/**
|
|
249
|
+
* Time Complexity: O(n + m)
|
|
250
|
+
* Space Complexity: O(m)
|
|
251
|
+
*
|
|
252
|
+
* The function overrides the splice method to handle deletion and insertion of elements in a data
|
|
253
|
+
* structure while returning the removed elements.
|
|
254
|
+
* @param {number} start - The `start` parameter in the `splice` method indicates the index at which
|
|
255
|
+
* to start modifying the array.
|
|
256
|
+
* @param {number} [deleteCount=0] - The `deleteCount` parameter in the `splice` method specifies the
|
|
257
|
+
* number of elements to remove from the array starting at the specified `start` index. If
|
|
258
|
+
* `deleteCount` is not provided, it defaults to 0, meaning no elements will be removed but new
|
|
259
|
+
* elements can still be inserted at
|
|
260
|
+
* @param {E[]} items - The `items` parameter in the `splice` method represents the elements that
|
|
261
|
+
* will be inserted into the array at the specified `start` index. These elements can be of any type
|
|
262
|
+
* and there can be multiple elements passed as arguments to be inserted into the array.
|
|
263
|
+
* @returns The `splice` method is returning a new instance of the data structure that was modified
|
|
264
|
+
* by removing elements specified by the `start` and `deleteCount` parameters, and inserting new
|
|
265
|
+
* elements provided in the `items` array.
|
|
266
|
+
*/
|
|
267
|
+
splice(start: number, deleteCount?: number, ...items: E[]): this;
|
|
268
|
+
reduceRight(callbackfn: ReduceLinearCallback<E>): E;
|
|
269
|
+
reduceRight(callbackfn: ReduceLinearCallback<E>, initialValue: E): E;
|
|
270
|
+
reduceRight<U>(callbackfn: ReduceLinearCallback<E, U>, initialValue: U): U;
|
|
271
|
+
abstract delete(elementOrNode: E | NODE | undefined): boolean;
|
|
272
|
+
abstract addBefore(existingElementOrNode: E | NODE, newElementOrNode: E | NODE): boolean;
|
|
273
|
+
abstract addAfter(existingElementOrNode: E | NODE, newElementOrNode: E | NODE): boolean;
|
|
274
|
+
abstract getNodeAt(index: number): NODE | undefined;
|
|
275
|
+
protected abstract _getNodeIterator(...args: any[]): IterableIterator<NODE>;
|
|
276
|
+
protected abstract _getPrevNode(node: NODE): NODE | undefined;
|
|
277
|
+
}
|