collect-your-stuff 2.1.0 → 2.1.2
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 +898 -213
- package/browser/collect-your-stuff.js +2672 -20684
- package/browser/collect-your-stuff.min.js +1 -1
- package/dist/collections/arrayable/ArrayElement.d.ts +38 -38
- package/dist/collections/arrayable/ArrayElement.js +66 -66
- package/dist/collections/arrayable/Arrayable.d.ts +122 -122
- package/dist/collections/arrayable/Arrayable.js +2 -2
- package/dist/collections/doubly-linked-list/DoubleLinker.d.ts +50 -50
- package/dist/collections/doubly-linked-list/DoubleLinker.js +1 -1
- package/dist/collections/doubly-linked-list/DoublyLinkedList.d.ts +125 -125
- package/dist/collections/doubly-linked-list/DoublyLinkedList.js +3 -3
- package/dist/collections/linked-list/LinkedList.d.ts +126 -126
- package/dist/collections/linked-list/LinkedList.js +3 -3
- package/dist/collections/linked-list/Linker.d.ts +46 -46
- package/dist/collections/linked-list/Linker.js +1 -1
- package/dist/collections/linked-tree-list/LinkedTreeList.d.ts +159 -159
- package/dist/collections/linked-tree-list/LinkedTreeList.js +3 -3
- package/dist/collections/linked-tree-list/TreeLinker.d.ts +71 -71
- package/dist/collections/linked-tree-list/TreeLinker.js +2 -2
- package/dist/collections/queue/Queue.d.ts +59 -59
- package/dist/collections/queue/Queue.js +11 -9
- package/dist/collections/queue/Queueable.d.ts +83 -83
- package/dist/collections/queue/Queueable.js +9 -7
- package/dist/collections/queue/TaskQueue.d.ts +68 -68
- package/dist/collections/queue/TaskQueue.js +2 -2
- package/dist/collections/stack/Stack.d.ts +64 -64
- package/dist/collections/stack/Stack.js +11 -9
- package/dist/collections/stack/Stackable.d.ts +59 -59
- package/dist/collections/stack/Stackable.js +1 -1
- package/dist/collections/stack/TaskStack.d.ts +65 -65
- package/dist/collections/stack/TaskStack.js +2 -2
- package/dist/main.d.ts +68 -69
- package/dist/main.js +1 -2
- package/dist/main.min.js +1 -1
- package/dist/recipes/ArrayIterator.d.ts +20 -20
- package/dist/recipes/ArrayIterator.js +39 -39
- package/dist/recipes/DoubleLinkerIterator.d.ts +18 -18
- package/dist/recipes/DoubleLinkerIterator.js +33 -33
- package/dist/recipes/IsArrayable.d.ts +105 -105
- package/dist/recipes/IsArrayable.js +5 -5
- package/dist/recipes/IsDoubleLinker.d.ts +14 -14
- package/dist/recipes/IsDoubleLinker.js +5 -5
- package/dist/recipes/IsElement.d.ts +14 -14
- package/dist/recipes/IsElement.js +5 -5
- package/dist/recipes/IsLinker.d.ts +10 -10
- package/dist/recipes/IsLinker.js +5 -5
- package/dist/recipes/IsQueue.d.ts +37 -37
- package/dist/recipes/IsQueue.js +5 -5
- package/dist/recipes/IsStack.d.ts +36 -36
- package/dist/recipes/IsStack.js +5 -5
- package/dist/recipes/IsTree.d.ts +11 -11
- package/dist/recipes/IsTree.js +5 -5
- package/dist/recipes/IsTreeNode.d.ts +29 -29
- package/dist/recipes/IsTreeNode.js +5 -5
- package/dist/recipes/LinkerIterator.d.ts +18 -18
- package/dist/recipes/LinkerIterator.js +33 -33
- package/dist/recipes/Runnable.d.ts +55 -55
- package/dist/recipes/Runnable.js +69 -69
- package/dist/recipes/TreeLinkerIterator.d.ts +20 -20
- package/dist/recipes/TreeLinkerIterator.js +1 -1
- package/dist/recipes/recipes.d.ts +15 -15
- package/dist/recipes/recipes.js +2 -2
- package/dist/services/parseTree.d.ts +9 -9
- package/dist/services/parseTree.js +1 -1
- package/dist/services/parseTreeNext.d.ts +17 -17
- package/dist/services/parseTreeNext.js +42 -42
- package/dist/services/services.d.ts +13 -13
- package/dist/services/services.js +2 -2
- package/package.json +2 -2
|
@@ -1,125 +1,125 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file doubly linked list.
|
|
3
|
-
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
4
|
-
* @version 1.1.0
|
|
5
|
-
* @memberOf module:collect-your-stuff
|
|
6
|
-
*/
|
|
7
|
-
import { DoubleLinker } from './DoubleLinker';
|
|
8
|
-
import { forEachCallback, IsArrayable } from '../../recipes/IsArrayable';
|
|
9
|
-
import { IsDoubleLinker } from '../../recipes/IsDoubleLinker';
|
|
10
|
-
/**
|
|
11
|
-
* DoublyLinkedList represents a collection stored as a LinkedList with prev and next references.
|
|
12
|
-
* @extends LinkedList
|
|
13
|
-
*/
|
|
14
|
-
export declare class DoublyLinkedList implements IsArrayable<DoubleLinker>, Iterable<DoubleLinker> {
|
|
15
|
-
/** The class used to create this instance, so that it can be recognized as valid without an instanceof check. */
|
|
16
|
-
readonly classType: typeof DoublyLinkedList;
|
|
17
|
-
/** A linker of the list (null when the list is empty); the head is found by walking back from it. */
|
|
18
|
-
innerList: DoubleLinker;
|
|
19
|
-
/** Whether the inner list has been initialized (it can only be initialized once). */
|
|
20
|
-
initialized: boolean;
|
|
21
|
-
/** The class used to wrap the data given to this list as linkers. */
|
|
22
|
-
linkerClass: typeof DoubleLinker;
|
|
23
|
-
/** The last linker, remembered so that adding to the end does not need to walk the whole list (null when not known yet). */
|
|
24
|
-
private tailCache;
|
|
25
|
-
/** The number of linkers, kept up to date by the list's own methods so that the length does not need to walk the whole list (null when not known yet). */
|
|
26
|
-
private countCache;
|
|
27
|
-
/**
|
|
28
|
-
* Create the new DoublyLinkedList instance.
|
|
29
|
-
* @param {DoubleLinker} [linkerClass=DoubleLinker] The class used to wrap given data as linkers.
|
|
30
|
-
*/
|
|
31
|
-
constructor(linkerClass?: typeof DoubleLinker);
|
|
32
|
-
/**
|
|
33
|
-
* Initialize the inner list, should only run once.
|
|
34
|
-
* @param {DoubleLinker} initialList Give the list of double-linkers to start in this doubly linked-list.
|
|
35
|
-
* @return {DoublyLinkedList}
|
|
36
|
-
*/
|
|
37
|
-
initialize(initialList: DoubleLinker): DoublyLinkedList;
|
|
38
|
-
/**
|
|
39
|
-
* Retrieve the innerList used (the list itself, not a copy).
|
|
40
|
-
* @returns {DoubleLinker}
|
|
41
|
-
*/
|
|
42
|
-
get list(): DoubleLinker;
|
|
43
|
-
/**
|
|
44
|
-
* Retrieve the first DoubleLinker in the list.
|
|
45
|
-
* @returns {DoubleLinker}
|
|
46
|
-
*/
|
|
47
|
-
get first(): DoubleLinker | null;
|
|
48
|
-
/**
|
|
49
|
-
* Retrieve the last DoubleLinker in the list. The end is remembered, so this does not walk the list.
|
|
50
|
-
* @returns {DoubleLinker}
|
|
51
|
-
*/
|
|
52
|
-
get last(): DoubleLinker | null;
|
|
53
|
-
/**
|
|
54
|
-
* Return the length of the list. It is kept up to date by the list's own methods, so this does not walk the list
|
|
55
|
-
* (call reset() after linkers were changed directly).
|
|
56
|
-
* @returns {number}
|
|
57
|
-
*/
|
|
58
|
-
get length(): number;
|
|
59
|
-
/**
|
|
60
|
-
* Insert a new node (or data) after a node.
|
|
61
|
-
* @param {DoubleLinker|*} node The existing node as reference (which must be in this list, this is not checked), or null to insert at the start of the list
|
|
62
|
-
* @param {DoubleLinker|*} newNode The new node to go after the existing node
|
|
63
|
-
* @returns {DoublyLinkedList}
|
|
64
|
-
*/
|
|
65
|
-
insertAfter(node: DoubleLinker | null, newNode: DoubleLinker | any): DoublyLinkedList;
|
|
66
|
-
/**
|
|
67
|
-
* Insert a new node (or data) before a node.
|
|
68
|
-
* @param {DoubleLinker|*} node The existing node as reference (which must be in this list, this is not checked), or null to insert at the end of the list
|
|
69
|
-
* @param {DoubleLinker|*} newNode The new node to go before the existing node
|
|
70
|
-
* @returns {DoublyLinkedList}
|
|
71
|
-
*/
|
|
72
|
-
insertBefore(node: DoubleLinker | null, newNode: DoubleLinker | any): DoublyLinkedList;
|
|
73
|
-
/**
|
|
74
|
-
* Add a node (or data) after the given (or last) node in the list.
|
|
75
|
-
* @param {DoubleLinker|*} node The new node to add to the end of the list
|
|
76
|
-
* @param {DoubleLinker} after The existing last node
|
|
77
|
-
* @returns {DoubleLinker}
|
|
78
|
-
*/
|
|
79
|
-
append(node: DoubleLinker | any, after?: DoubleLinker): DoublyLinkedList;
|
|
80
|
-
/**
|
|
81
|
-
* Add a node (or data) before the given (or first) node in the list.
|
|
82
|
-
* @param {DoubleLinker|*} node The new node to add to the start of the list
|
|
83
|
-
* @param {DoubleLinker} before The existing first node
|
|
84
|
-
* @returns {DoubleLinker}
|
|
85
|
-
*/
|
|
86
|
-
prepend(node: DoubleLinker | any, before?: DoubleLinker): DoublyLinkedList;
|
|
87
|
-
/**
|
|
88
|
-
* Remove a linker from this linked list.
|
|
89
|
-
* @param {DoubleLinker} node The node we wish to remove (and it will be returned after removal)
|
|
90
|
-
* @return {DoubleLinker}
|
|
91
|
-
*/
|
|
92
|
-
remove(node: DoubleLinker | null): DoubleLinker | null;
|
|
93
|
-
/**
|
|
94
|
-
* Refresh all references (the head, the end and the length) by walking the list once, and return the head. The list's
|
|
95
|
-
* own methods keep these up to date, so this is only needed after linkers were changed directly.
|
|
96
|
-
* @return {DoubleLinker|null}
|
|
97
|
-
*/
|
|
98
|
-
reset(): DoubleLinker | null;
|
|
99
|
-
/**
|
|
100
|
-
* Retrieve a DoubleLinker item from this list by numeric index, otherwise return null.
|
|
101
|
-
* @param {number} index The integer number for retrieving a node by position.
|
|
102
|
-
* @returns {DoubleLinker|null}
|
|
103
|
-
*/
|
|
104
|
-
item(index: number): DoubleLinker;
|
|
105
|
-
/**
|
|
106
|
-
* Be able to run forEach on this DoublyLinkedList to iterate over the DoubleLinker Items.
|
|
107
|
-
* @param {forEachCallback} callback The function to call for-each double linker
|
|
108
|
-
* @param {DoublyLinkedList} thisArg Optional, 'this' reference
|
|
109
|
-
* @return {DoublyLinkedList} The list which was iterated.
|
|
110
|
-
*/
|
|
111
|
-
forEach(callback: forEachCallback, thisArg?: DoublyLinkedList): DoublyLinkedList;
|
|
112
|
-
/**
|
|
113
|
-
* Be able to iterate over this class.
|
|
114
|
-
* @returns {Iterator}
|
|
115
|
-
*/
|
|
116
|
-
[Symbol.iterator](): Iterator<DoubleLinker>;
|
|
117
|
-
/**
|
|
118
|
-
* Convert an array into a DoublyLinkedList instance, return the new instance.
|
|
119
|
-
* @param {Array} [values=[]] An array of values which will be converted to linkers in this doubly-linked-list
|
|
120
|
-
* @param {IsDoubleLinker} [linkerClass=DoubleLinker] The class to use for each linker
|
|
121
|
-
* @param {IsArrayable<IsDoubleLinker>} [classType=LinkedList] Provide the type of IsArrayable to use.
|
|
122
|
-
* @returns {DoublyLinkedList}
|
|
123
|
-
*/
|
|
124
|
-
static fromArray: (values?: Array<any>, linkerClass?: typeof DoubleLinker, classType?: any) => IsArrayable<IsDoubleLinker> | any;
|
|
125
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @file doubly linked list.
|
|
3
|
+
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
4
|
+
* @version 1.1.0
|
|
5
|
+
* @memberOf module:collect-your-stuff
|
|
6
|
+
*/
|
|
7
|
+
import { DoubleLinker } from './DoubleLinker';
|
|
8
|
+
import { forEachCallback, IsArrayable } from '../../recipes/IsArrayable';
|
|
9
|
+
import { IsDoubleLinker } from '../../recipes/IsDoubleLinker';
|
|
10
|
+
/**
|
|
11
|
+
* DoublyLinkedList represents a collection stored as a LinkedList with prev and next references.
|
|
12
|
+
* @extends LinkedList
|
|
13
|
+
*/
|
|
14
|
+
export declare class DoublyLinkedList implements IsArrayable<DoubleLinker>, Iterable<DoubleLinker> {
|
|
15
|
+
/** The class used to create this instance, so that it can be recognized as valid without an instanceof check. */
|
|
16
|
+
readonly classType: typeof DoublyLinkedList;
|
|
17
|
+
/** A linker of the list (null when the list is empty); the head is found by walking back from it. */
|
|
18
|
+
innerList: DoubleLinker;
|
|
19
|
+
/** Whether the inner list has been initialized (it can only be initialized once). */
|
|
20
|
+
initialized: boolean;
|
|
21
|
+
/** The class used to wrap the data given to this list as linkers. */
|
|
22
|
+
linkerClass: typeof DoubleLinker;
|
|
23
|
+
/** The last linker, remembered so that adding to the end does not need to walk the whole list (null when not known yet). */
|
|
24
|
+
private tailCache;
|
|
25
|
+
/** The number of linkers, kept up to date by the list's own methods so that the length does not need to walk the whole list (null when not known yet). */
|
|
26
|
+
private countCache;
|
|
27
|
+
/**
|
|
28
|
+
* Create the new DoublyLinkedList instance.
|
|
29
|
+
* @param {DoubleLinker} [linkerClass=DoubleLinker] The class used to wrap given data as linkers.
|
|
30
|
+
*/
|
|
31
|
+
constructor(linkerClass?: typeof DoubleLinker);
|
|
32
|
+
/**
|
|
33
|
+
* Initialize the inner list, should only run once.
|
|
34
|
+
* @param {DoubleLinker} initialList Give the list of double-linkers to start in this doubly linked-list.
|
|
35
|
+
* @return {DoublyLinkedList}
|
|
36
|
+
*/
|
|
37
|
+
initialize(initialList: DoubleLinker): DoublyLinkedList;
|
|
38
|
+
/**
|
|
39
|
+
* Retrieve the innerList used (the list itself, not a copy).
|
|
40
|
+
* @returns {DoubleLinker}
|
|
41
|
+
*/
|
|
42
|
+
get list(): DoubleLinker;
|
|
43
|
+
/**
|
|
44
|
+
* Retrieve the first DoubleLinker in the list.
|
|
45
|
+
* @returns {DoubleLinker}
|
|
46
|
+
*/
|
|
47
|
+
get first(): DoubleLinker | null;
|
|
48
|
+
/**
|
|
49
|
+
* Retrieve the last DoubleLinker in the list. The end is remembered, so this does not walk the list.
|
|
50
|
+
* @returns {DoubleLinker}
|
|
51
|
+
*/
|
|
52
|
+
get last(): DoubleLinker | null;
|
|
53
|
+
/**
|
|
54
|
+
* Return the length of the list. It is kept up to date by the list's own methods, so this does not walk the list
|
|
55
|
+
* (call reset() after linkers were changed directly).
|
|
56
|
+
* @returns {number}
|
|
57
|
+
*/
|
|
58
|
+
get length(): number;
|
|
59
|
+
/**
|
|
60
|
+
* Insert a new node (or data) after a node.
|
|
61
|
+
* @param {DoubleLinker|*} node The existing node as reference (which must be in this list, this is not checked), or null to insert at the start of the list
|
|
62
|
+
* @param {DoubleLinker|*} newNode The new node to go after the existing node
|
|
63
|
+
* @returns {DoublyLinkedList}
|
|
64
|
+
*/
|
|
65
|
+
insertAfter(node: DoubleLinker | null, newNode: DoubleLinker | any): DoublyLinkedList;
|
|
66
|
+
/**
|
|
67
|
+
* Insert a new node (or data) before a node.
|
|
68
|
+
* @param {DoubleLinker|*} node The existing node as reference (which must be in this list, this is not checked), or null to insert at the end of the list
|
|
69
|
+
* @param {DoubleLinker|*} newNode The new node to go before the existing node
|
|
70
|
+
* @returns {DoublyLinkedList}
|
|
71
|
+
*/
|
|
72
|
+
insertBefore(node: DoubleLinker | null, newNode: DoubleLinker | any): DoublyLinkedList;
|
|
73
|
+
/**
|
|
74
|
+
* Add a node (or data) after the given (or last) node in the list.
|
|
75
|
+
* @param {DoubleLinker|*} node The new node to add to the end of the list
|
|
76
|
+
* @param {DoubleLinker} after The existing last node
|
|
77
|
+
* @returns {DoubleLinker}
|
|
78
|
+
*/
|
|
79
|
+
append(node: DoubleLinker | any, after?: DoubleLinker): DoublyLinkedList;
|
|
80
|
+
/**
|
|
81
|
+
* Add a node (or data) before the given (or first) node in the list.
|
|
82
|
+
* @param {DoubleLinker|*} node The new node to add to the start of the list
|
|
83
|
+
* @param {DoubleLinker} before The existing first node
|
|
84
|
+
* @returns {DoubleLinker}
|
|
85
|
+
*/
|
|
86
|
+
prepend(node: DoubleLinker | any, before?: DoubleLinker): DoublyLinkedList;
|
|
87
|
+
/**
|
|
88
|
+
* Remove a linker from this linked list.
|
|
89
|
+
* @param {DoubleLinker} node The node we wish to remove (and it will be returned after removal)
|
|
90
|
+
* @return {DoubleLinker}
|
|
91
|
+
*/
|
|
92
|
+
remove(node: DoubleLinker | null): DoubleLinker | null;
|
|
93
|
+
/**
|
|
94
|
+
* Refresh all references (the head, the end and the length) by walking the list once, and return the head. The list's
|
|
95
|
+
* own methods keep these up to date, so this is only needed after linkers were changed directly.
|
|
96
|
+
* @return {DoubleLinker|null}
|
|
97
|
+
*/
|
|
98
|
+
reset(): DoubleLinker | null;
|
|
99
|
+
/**
|
|
100
|
+
* Retrieve a DoubleLinker item from this list by numeric index, otherwise return null.
|
|
101
|
+
* @param {number} index The integer number for retrieving a node by position.
|
|
102
|
+
* @returns {DoubleLinker|null}
|
|
103
|
+
*/
|
|
104
|
+
item(index: number): DoubleLinker;
|
|
105
|
+
/**
|
|
106
|
+
* Be able to run forEach on this DoublyLinkedList to iterate over the DoubleLinker Items.
|
|
107
|
+
* @param {forEachCallback} callback The function to call for-each double linker
|
|
108
|
+
* @param {DoublyLinkedList} thisArg Optional, 'this' reference
|
|
109
|
+
* @return {DoublyLinkedList} The list which was iterated.
|
|
110
|
+
*/
|
|
111
|
+
forEach(callback: forEachCallback, thisArg?: DoublyLinkedList): DoublyLinkedList;
|
|
112
|
+
/**
|
|
113
|
+
* Be able to iterate over this class.
|
|
114
|
+
* @returns {Iterator}
|
|
115
|
+
*/
|
|
116
|
+
[Symbol.iterator](): Iterator<DoubleLinker>;
|
|
117
|
+
/**
|
|
118
|
+
* Convert an array into a DoublyLinkedList instance, return the new instance.
|
|
119
|
+
* @param {Array} [values=[]] An array of values which will be converted to linkers in this doubly-linked-list
|
|
120
|
+
* @param {IsDoubleLinker} [linkerClass=DoubleLinker] The class to use for each linker
|
|
121
|
+
* @param {IsArrayable<IsDoubleLinker>} [classType=LinkedList] Provide the type of IsArrayable to use.
|
|
122
|
+
* @returns {DoublyLinkedList}
|
|
123
|
+
*/
|
|
124
|
+
static fromArray: (values?: Array<any>, linkerClass?: typeof DoubleLinker, classType?: any) => IsArrayable<IsDoubleLinker> | any;
|
|
125
|
+
}
|
|
@@ -6,9 +6,9 @@ Object.defineProperty(exports, '__esModule', {
|
|
|
6
6
|
exports.DoublyLinkedList = void 0
|
|
7
7
|
require('core-js/modules/esnext.iterator.constructor.js')
|
|
8
8
|
require('core-js/modules/esnext.iterator.for-each.js')
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
const _DoubleLinker = require('./DoubleLinker')
|
|
10
|
+
const _DoubleLinkerIterator = require('../../recipes/DoubleLinkerIterator')
|
|
11
|
+
const _LinkedList = require('../linked-list/LinkedList')
|
|
12
12
|
/**
|
|
13
13
|
* @file doubly linked list.
|
|
14
14
|
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
@@ -1,126 +1,126 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file linked list.
|
|
3
|
-
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
4
|
-
* @version 1.1.0
|
|
5
|
-
* @memberOf module:collect-your-stuff
|
|
6
|
-
*/
|
|
7
|
-
import { forEachCallback, IsArrayable } from '../../recipes/IsArrayable';
|
|
8
|
-
import { IsLinker } from '../../recipes/IsLinker';
|
|
9
|
-
import { Linker } from './Linker';
|
|
10
|
-
/**
|
|
11
|
-
* LinkedList represents a collection stored as a LinkedList with next references.
|
|
12
|
-
* @extends Arrayable
|
|
13
|
-
*/
|
|
14
|
-
export declare class LinkedList implements IsArrayable<Linker>, Iterable<Linker> {
|
|
15
|
-
/** The class used to create this instance, so that it can be recognized as valid without an instanceof check. */
|
|
16
|
-
readonly classType: typeof LinkedList;
|
|
17
|
-
/** The first linker of the list (null when the list is empty), from which the whole list is reached. */
|
|
18
|
-
innerList: Linker;
|
|
19
|
-
/** Whether the inner list has been initialized (it can only be initialized once). */
|
|
20
|
-
initialized: boolean;
|
|
21
|
-
/** The class used to wrap the data given to this list as linkers. */
|
|
22
|
-
linkerClass: typeof Linker;
|
|
23
|
-
/** The last linker, remembered so that adding to the end does not need to walk the whole list (null when not known yet). */
|
|
24
|
-
private tailCache;
|
|
25
|
-
/** The number of linkers, kept up to date by the list's own methods so that the length does not need to walk the whole list (null when not known yet). */
|
|
26
|
-
private countCache;
|
|
27
|
-
/**
|
|
28
|
-
* Create the new LinkedList instance.
|
|
29
|
-
* @param {Linker} [linkerClass=Linker] The class used to wrap given data as linkers.
|
|
30
|
-
*/
|
|
31
|
-
constructor(linkerClass?: typeof Linker);
|
|
32
|
-
/**
|
|
33
|
-
* Initialize the inner list, should only run once.
|
|
34
|
-
* @param {Linker|Array} initialList Give the list of linkers to start in this linked-list.
|
|
35
|
-
* @return {LinkedList}
|
|
36
|
-
*/
|
|
37
|
-
initialize(initialList: Linker): LinkedList;
|
|
38
|
-
/**
|
|
39
|
-
* Retrieve the innerList used (the list itself, not a copy).
|
|
40
|
-
* @returns {Linker}
|
|
41
|
-
*/
|
|
42
|
-
get list(): IsLinker;
|
|
43
|
-
/**
|
|
44
|
-
* Retrieve the first Linker in the list.
|
|
45
|
-
* @returns {Linker}
|
|
46
|
-
*/
|
|
47
|
-
get first(): Linker;
|
|
48
|
-
/**
|
|
49
|
-
* Retrieve the last Linker in the list. The end is remembered, so this does not walk the list.
|
|
50
|
-
* @returns {Linker}
|
|
51
|
-
*/
|
|
52
|
-
get last(): Linker | null;
|
|
53
|
-
/**
|
|
54
|
-
* Return the length of the list. It is kept up to date by the list's own methods, so this does not walk the list
|
|
55
|
-
* (call reset() after linkers were changed directly).
|
|
56
|
-
* @returns {number}
|
|
57
|
-
*/
|
|
58
|
-
get length(): number;
|
|
59
|
-
/**
|
|
60
|
-
* Insert a new node (or data) after a node.
|
|
61
|
-
* @param {Linker|*} node The existing node as reference, or null to insert at the start of the list
|
|
62
|
-
* @param {Linker|*} newNode The new node to go after the existing node
|
|
63
|
-
* @returns {LinkedList}
|
|
64
|
-
*/
|
|
65
|
-
insertAfter(node: IsLinker | null, newNode: Linker | any): LinkedList;
|
|
66
|
-
/**
|
|
67
|
-
* Insert a new node (or data) before a node.
|
|
68
|
-
* @param {Linker|*} node The existing node as reference, or null to insert at the end of the list
|
|
69
|
-
* @param {Linker|*} newNode The new node to go before the existing node
|
|
70
|
-
* @returns {LinkedList}
|
|
71
|
-
* @throws {Error} When the reference node is not in this list
|
|
72
|
-
*/
|
|
73
|
-
insertBefore(node: IsLinker | null, newNode: Linker | any): LinkedList;
|
|
74
|
-
/**
|
|
75
|
-
* Add a node (or data) after the given (or last) node in the list.
|
|
76
|
-
* @param {Linker|*} node The new node to add to the end of the list
|
|
77
|
-
* @param {Linker} after The existing last node
|
|
78
|
-
* @returns {Linker}
|
|
79
|
-
*/
|
|
80
|
-
append(node: Linker | any, after?: IsLinker): LinkedList;
|
|
81
|
-
/**
|
|
82
|
-
* Add a node (or data) before the given (or first) node in the list.
|
|
83
|
-
* @param {Linker|*} node The new node to add to the start of the list
|
|
84
|
-
* @param {Linker} before The existing first node
|
|
85
|
-
* @returns {Linker}
|
|
86
|
-
*/
|
|
87
|
-
prepend(node: Linker | any, before?: IsLinker): LinkedList;
|
|
88
|
-
/**
|
|
89
|
-
* Remove a linker from this linked list.
|
|
90
|
-
* @param {Linker} node The node we wish to remove (and it will be returned after removal)
|
|
91
|
-
* @return {Linker|null} The removed node, or null when it was not in this list (nothing is removed)
|
|
92
|
-
*/
|
|
93
|
-
remove(node: Linker | null): Linker | null;
|
|
94
|
-
/**
|
|
95
|
-
* Refresh the remembered end and length of the list by walking it once. The list's own methods keep these up to date,
|
|
96
|
-
* so this is only needed after linkers were changed directly (for example by setting next on a linker).
|
|
97
|
-
* @return {Linker|null} The first linker of the list
|
|
98
|
-
*/
|
|
99
|
-
reset(): Linker | null;
|
|
100
|
-
/**
|
|
101
|
-
* Retrieve a Linker item from this list by numeric index, otherwise return null.
|
|
102
|
-
* @param {number} index The integer number for retrieving a node by position.
|
|
103
|
-
* @returns {Linker|null}
|
|
104
|
-
*/
|
|
105
|
-
item(index: number): Linker | null;
|
|
106
|
-
/**
|
|
107
|
-
* Be able to run forEach on this LinkedList to iterate over the linkers.
|
|
108
|
-
* @param {forEachCallback} callback The function to call for-each linker
|
|
109
|
-
* @param {LinkedList} thisArg Optional, 'this' reference
|
|
110
|
-
* @returns {LinkedList}
|
|
111
|
-
*/
|
|
112
|
-
forEach(callback: forEachCallback, thisArg?: LinkedList): LinkedList;
|
|
113
|
-
/**
|
|
114
|
-
* Be able to iterate over this class.
|
|
115
|
-
* @returns {Iterator}
|
|
116
|
-
*/
|
|
117
|
-
[Symbol.iterator](): Iterator<Linker>;
|
|
118
|
-
/**
|
|
119
|
-
* Convert an array to a LinkedList.
|
|
120
|
-
* @param {Array} values An array of values which will be converted to linkers in this linked-list
|
|
121
|
-
* @param {IsLinker} linkerClass The class to use for each linker
|
|
122
|
-
* @param {IsArrayable<Linker>} [classType=LinkedList] Provide the type of IsArrayable to use.
|
|
123
|
-
* @returns {LinkedList}
|
|
124
|
-
*/
|
|
125
|
-
static fromArray: (values?: Array<any>, linkerClass?: typeof Linker, classType?: any) => IsArrayable<IsLinker> | any;
|
|
126
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @file linked list.
|
|
3
|
+
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
4
|
+
* @version 1.1.0
|
|
5
|
+
* @memberOf module:collect-your-stuff
|
|
6
|
+
*/
|
|
7
|
+
import { forEachCallback, IsArrayable } from '../../recipes/IsArrayable';
|
|
8
|
+
import { IsLinker } from '../../recipes/IsLinker';
|
|
9
|
+
import { Linker } from './Linker';
|
|
10
|
+
/**
|
|
11
|
+
* LinkedList represents a collection stored as a LinkedList with next references.
|
|
12
|
+
* @extends Arrayable
|
|
13
|
+
*/
|
|
14
|
+
export declare class LinkedList implements IsArrayable<Linker>, Iterable<Linker> {
|
|
15
|
+
/** The class used to create this instance, so that it can be recognized as valid without an instanceof check. */
|
|
16
|
+
readonly classType: typeof LinkedList;
|
|
17
|
+
/** The first linker of the list (null when the list is empty), from which the whole list is reached. */
|
|
18
|
+
innerList: Linker;
|
|
19
|
+
/** Whether the inner list has been initialized (it can only be initialized once). */
|
|
20
|
+
initialized: boolean;
|
|
21
|
+
/** The class used to wrap the data given to this list as linkers. */
|
|
22
|
+
linkerClass: typeof Linker;
|
|
23
|
+
/** The last linker, remembered so that adding to the end does not need to walk the whole list (null when not known yet). */
|
|
24
|
+
private tailCache;
|
|
25
|
+
/** The number of linkers, kept up to date by the list's own methods so that the length does not need to walk the whole list (null when not known yet). */
|
|
26
|
+
private countCache;
|
|
27
|
+
/**
|
|
28
|
+
* Create the new LinkedList instance.
|
|
29
|
+
* @param {Linker} [linkerClass=Linker] The class used to wrap given data as linkers.
|
|
30
|
+
*/
|
|
31
|
+
constructor(linkerClass?: typeof Linker);
|
|
32
|
+
/**
|
|
33
|
+
* Initialize the inner list, should only run once.
|
|
34
|
+
* @param {Linker|Array} initialList Give the list of linkers to start in this linked-list.
|
|
35
|
+
* @return {LinkedList}
|
|
36
|
+
*/
|
|
37
|
+
initialize(initialList: Linker): LinkedList;
|
|
38
|
+
/**
|
|
39
|
+
* Retrieve the innerList used (the list itself, not a copy).
|
|
40
|
+
* @returns {Linker}
|
|
41
|
+
*/
|
|
42
|
+
get list(): IsLinker;
|
|
43
|
+
/**
|
|
44
|
+
* Retrieve the first Linker in the list.
|
|
45
|
+
* @returns {Linker}
|
|
46
|
+
*/
|
|
47
|
+
get first(): Linker;
|
|
48
|
+
/**
|
|
49
|
+
* Retrieve the last Linker in the list. The end is remembered, so this does not walk the list.
|
|
50
|
+
* @returns {Linker}
|
|
51
|
+
*/
|
|
52
|
+
get last(): Linker | null;
|
|
53
|
+
/**
|
|
54
|
+
* Return the length of the list. It is kept up to date by the list's own methods, so this does not walk the list
|
|
55
|
+
* (call reset() after linkers were changed directly).
|
|
56
|
+
* @returns {number}
|
|
57
|
+
*/
|
|
58
|
+
get length(): number;
|
|
59
|
+
/**
|
|
60
|
+
* Insert a new node (or data) after a node.
|
|
61
|
+
* @param {Linker|*} node The existing node as reference, or null to insert at the start of the list
|
|
62
|
+
* @param {Linker|*} newNode The new node to go after the existing node
|
|
63
|
+
* @returns {LinkedList}
|
|
64
|
+
*/
|
|
65
|
+
insertAfter(node: IsLinker | null, newNode: Linker | any): LinkedList;
|
|
66
|
+
/**
|
|
67
|
+
* Insert a new node (or data) before a node.
|
|
68
|
+
* @param {Linker|*} node The existing node as reference, or null to insert at the end of the list
|
|
69
|
+
* @param {Linker|*} newNode The new node to go before the existing node
|
|
70
|
+
* @returns {LinkedList}
|
|
71
|
+
* @throws {Error} When the reference node is not in this list
|
|
72
|
+
*/
|
|
73
|
+
insertBefore(node: IsLinker | null, newNode: Linker | any): LinkedList;
|
|
74
|
+
/**
|
|
75
|
+
* Add a node (or data) after the given (or last) node in the list.
|
|
76
|
+
* @param {Linker|*} node The new node to add to the end of the list
|
|
77
|
+
* @param {Linker} after The existing last node
|
|
78
|
+
* @returns {Linker}
|
|
79
|
+
*/
|
|
80
|
+
append(node: Linker | any, after?: IsLinker): LinkedList;
|
|
81
|
+
/**
|
|
82
|
+
* Add a node (or data) before the given (or first) node in the list.
|
|
83
|
+
* @param {Linker|*} node The new node to add to the start of the list
|
|
84
|
+
* @param {Linker} before The existing first node
|
|
85
|
+
* @returns {Linker}
|
|
86
|
+
*/
|
|
87
|
+
prepend(node: Linker | any, before?: IsLinker): LinkedList;
|
|
88
|
+
/**
|
|
89
|
+
* Remove a linker from this linked list.
|
|
90
|
+
* @param {Linker} node The node we wish to remove (and it will be returned after removal)
|
|
91
|
+
* @return {Linker|null} The removed node, or null when it was not in this list (nothing is removed)
|
|
92
|
+
*/
|
|
93
|
+
remove(node: Linker | null): Linker | null;
|
|
94
|
+
/**
|
|
95
|
+
* Refresh the remembered end and length of the list by walking it once. The list's own methods keep these up to date,
|
|
96
|
+
* so this is only needed after linkers were changed directly (for example by setting next on a linker).
|
|
97
|
+
* @return {Linker|null} The first linker of the list
|
|
98
|
+
*/
|
|
99
|
+
reset(): Linker | null;
|
|
100
|
+
/**
|
|
101
|
+
* Retrieve a Linker item from this list by numeric index, otherwise return null.
|
|
102
|
+
* @param {number} index The integer number for retrieving a node by position.
|
|
103
|
+
* @returns {Linker|null}
|
|
104
|
+
*/
|
|
105
|
+
item(index: number): Linker | null;
|
|
106
|
+
/**
|
|
107
|
+
* Be able to run forEach on this LinkedList to iterate over the linkers.
|
|
108
|
+
* @param {forEachCallback} callback The function to call for-each linker
|
|
109
|
+
* @param {LinkedList} thisArg Optional, 'this' reference
|
|
110
|
+
* @returns {LinkedList}
|
|
111
|
+
*/
|
|
112
|
+
forEach(callback: forEachCallback, thisArg?: LinkedList): LinkedList;
|
|
113
|
+
/**
|
|
114
|
+
* Be able to iterate over this class.
|
|
115
|
+
* @returns {Iterator}
|
|
116
|
+
*/
|
|
117
|
+
[Symbol.iterator](): Iterator<Linker>;
|
|
118
|
+
/**
|
|
119
|
+
* Convert an array to a LinkedList.
|
|
120
|
+
* @param {Array} values An array of values which will be converted to linkers in this linked-list
|
|
121
|
+
* @param {IsLinker} linkerClass The class to use for each linker
|
|
122
|
+
* @param {IsArrayable<Linker>} [classType=LinkedList] Provide the type of IsArrayable to use.
|
|
123
|
+
* @returns {LinkedList}
|
|
124
|
+
*/
|
|
125
|
+
static fromArray: (values?: Array<any>, linkerClass?: typeof Linker, classType?: any) => IsArrayable<IsLinker> | any;
|
|
126
|
+
}
|
|
@@ -4,9 +4,9 @@ Object.defineProperty(exports, '__esModule', {
|
|
|
4
4
|
value: true
|
|
5
5
|
})
|
|
6
6
|
exports.LinkedList = void 0
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
const _Linker = require('./Linker')
|
|
8
|
+
const _LinkerIterator = require('../../recipes/LinkerIterator')
|
|
9
|
+
const _Arrayable = require('../arrayable/Arrayable')
|
|
10
10
|
/**
|
|
11
11
|
* LinkedList represents a collection stored as a LinkedList with next references.
|
|
12
12
|
* @extends Arrayable
|
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file linked list item.
|
|
3
|
-
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
4
|
-
* @version 1.1.0
|
|
5
|
-
* @memberOf module:collect-your-stuff
|
|
6
|
-
*/
|
|
7
|
-
import { IsLinker } from '../../recipes/IsLinker';
|
|
8
|
-
/**
|
|
9
|
-
* Linker represents a node in a LinkedList.
|
|
10
|
-
* @extends ArrayElement
|
|
11
|
-
*/
|
|
12
|
-
export declare class Linker implements IsLinker {
|
|
13
|
-
/** The class used to create this instance, so that it can be recognized as valid without an instanceof check. */
|
|
14
|
-
readonly classType: typeof Linker;
|
|
15
|
-
/** The data stored in this linker. */
|
|
16
|
-
data: any;
|
|
17
|
-
/** The linker after this one, or null when this is the last. */
|
|
18
|
-
next: Linker | null;
|
|
19
|
-
/**
|
|
20
|
-
* Create the new Linker instance, provide the data and optionally give the next Linker.
|
|
21
|
-
* @param {Object} [nodeData={}] The settings for the new linker.
|
|
22
|
-
* @param {*} [nodeData.data=null] The data to be stored in this linker
|
|
23
|
-
* @param {Linker|null} [nodeData.next=null] The reference to the next linker if any
|
|
24
|
-
*/
|
|
25
|
-
constructor({ data, next }?: {
|
|
26
|
-
data?: any;
|
|
27
|
-
next?: Linker | null;
|
|
28
|
-
});
|
|
29
|
-
/**
|
|
30
|
-
* Make a new Linker from the data given if it is not already a valid Linker.
|
|
31
|
-
* @param {Linker|*} linker Return a valid Linker instance from given data, or even an already valid one.
|
|
32
|
-
* @param {IsLinker} [classType=Linker] Provide the type of IsLinker to use.
|
|
33
|
-
* @return {Linker}
|
|
34
|
-
*/
|
|
35
|
-
static make: (linker: Linker | any, classType?: any) => IsLinker | any;
|
|
36
|
-
/**
|
|
37
|
-
* Convert an array into Linker instances, return the head and tail Linkers.
|
|
38
|
-
* @param {Array} [values=[]] Provide an array of data that will be converted to a chain of linkers.
|
|
39
|
-
* @param {IsLinker} [classType=Linker] Provide the type of IsLinker to use.
|
|
40
|
-
* @returns {{head: Linker, tail: Linker}}
|
|
41
|
-
*/
|
|
42
|
-
static fromArray: (values?: Array<any>, classType?: any) => {
|
|
43
|
-
head: IsLinker;
|
|
44
|
-
tail: IsLinker;
|
|
45
|
-
};
|
|
46
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @file linked list item.
|
|
3
|
+
* @author Joshua Heagle <joshuaheagle@gmail.com>
|
|
4
|
+
* @version 1.1.0
|
|
5
|
+
* @memberOf module:collect-your-stuff
|
|
6
|
+
*/
|
|
7
|
+
import { IsLinker } from '../../recipes/IsLinker';
|
|
8
|
+
/**
|
|
9
|
+
* Linker represents a node in a LinkedList.
|
|
10
|
+
* @extends ArrayElement
|
|
11
|
+
*/
|
|
12
|
+
export declare class Linker implements IsLinker {
|
|
13
|
+
/** The class used to create this instance, so that it can be recognized as valid without an instanceof check. */
|
|
14
|
+
readonly classType: typeof Linker;
|
|
15
|
+
/** The data stored in this linker. */
|
|
16
|
+
data: any;
|
|
17
|
+
/** The linker after this one, or null when this is the last. */
|
|
18
|
+
next: Linker | null;
|
|
19
|
+
/**
|
|
20
|
+
* Create the new Linker instance, provide the data and optionally give the next Linker.
|
|
21
|
+
* @param {Object} [nodeData={}] The settings for the new linker.
|
|
22
|
+
* @param {*} [nodeData.data=null] The data to be stored in this linker
|
|
23
|
+
* @param {Linker|null} [nodeData.next=null] The reference to the next linker if any
|
|
24
|
+
*/
|
|
25
|
+
constructor({ data, next }?: {
|
|
26
|
+
data?: any;
|
|
27
|
+
next?: Linker | null;
|
|
28
|
+
});
|
|
29
|
+
/**
|
|
30
|
+
* Make a new Linker from the data given if it is not already a valid Linker.
|
|
31
|
+
* @param {Linker|*} linker Return a valid Linker instance from given data, or even an already valid one.
|
|
32
|
+
* @param {IsLinker} [classType=Linker] Provide the type of IsLinker to use.
|
|
33
|
+
* @return {Linker}
|
|
34
|
+
*/
|
|
35
|
+
static make: (linker: Linker | any, classType?: any) => IsLinker | any;
|
|
36
|
+
/**
|
|
37
|
+
* Convert an array into Linker instances, return the head and tail Linkers.
|
|
38
|
+
* @param {Array} [values=[]] Provide an array of data that will be converted to a chain of linkers.
|
|
39
|
+
* @param {IsLinker} [classType=Linker] Provide the type of IsLinker to use.
|
|
40
|
+
* @returns {{head: Linker, tail: Linker}}
|
|
41
|
+
*/
|
|
42
|
+
static fromArray: (values?: Array<any>, classType?: any) => {
|
|
43
|
+
head: IsLinker;
|
|
44
|
+
tail: IsLinker;
|
|
45
|
+
};
|
|
46
|
+
}
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, '__esModule', {
|
|
|
6
6
|
exports.Linker = void 0
|
|
7
7
|
require('core-js/modules/esnext.iterator.constructor.js')
|
|
8
8
|
require('core-js/modules/esnext.iterator.reduce.js')
|
|
9
|
-
|
|
9
|
+
const _ArrayElement = require('../arrayable/ArrayElement')
|
|
10
10
|
/**
|
|
11
11
|
* Linker represents a node in a LinkedList.
|
|
12
12
|
* @extends ArrayElement
|