atomic-fns 0.3.3 → 0.3.5
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 +18 -4
- package/core/collections/LRUCache.d.ts +22 -1
- package/core/collections/LRUCache.js +22 -1
- package/core/collections/LRUCache.ts +22 -1
- package/core/collections/SortedMap.d.ts +1 -1
- package/core/collections/SortedMap.js +1 -1
- package/core/collections/SortedMap.ts +1 -1
- package/core/collections/SortedSet.d.ts +6 -0
- package/core/collections/SortedSet.js +6 -0
- package/core/collections/SortedSet.ts +6 -0
- package/core/collections/SortedTree.d.ts +3 -3
- package/core/collections/SortedTree.js +3 -3
- package/core/collections/SortedTree.ts +3 -3
- package/core/collections/abc.d.ts +1 -1
- package/core/collections/abc.ts +1 -1
- package/core/collections/deque.d.ts +55 -48
- package/core/collections/deque.js +61 -53
- package/core/collections/deque.ts +63 -54
- package/core/collections/index.d.ts +2 -0
- package/core/collections/index.js +7 -5
- package/core/collections/index.ts +7 -5
- package/core/functools/index.d.ts +3 -2
- package/core/functools/index.ts +8 -3
- package/core/globals/index.d.ts +23 -4
- package/core/globals/index.js +29 -6
- package/core/globals/index.ts +40 -7
- package/core/i18n/date/format.d.ts +16 -0
- package/core/i18n/date/format.js +307 -0
- package/core/i18n/date/format.ts +343 -0
- package/core/i18n/date/index.d.ts +224 -0
- package/core/i18n/date/index.js +387 -0
- package/core/i18n/date/index.ts +471 -0
- package/core/i18n/date/test.html +67 -0
- package/core/i18n/index.d.ts +7 -0
- package/core/i18n/index.js +7 -0
- package/core/i18n/index.ts +8 -0
- package/core/index.d.ts +1 -0
- package/core/index.js +1 -0
- package/core/index.ts +1 -0
- package/core/operators/index.d.ts +1 -1
- package/core/operators/index.js +35 -5
- package/core/operators/index.ts +34 -6
- package/package.json +11 -11
- package/tests/globals.spec.ts +12 -12
- package/tsconfig.json +2 -1
- package/core/datetime/index.d.ts +0 -45
- package/core/datetime/index.js +0 -71
- package/core/datetime/index.ts +0 -128
package/README.md
CHANGED
|
@@ -21,7 +21,7 @@ You may prefer this because it's:
|
|
|
21
21
|
|
|
22
22
|
## Get Started
|
|
23
23
|
|
|
24
|
-
This library is available as an npm package.
|
|
24
|
+
This library is available as an [npm package](https://www.npmjs.com/package/atomic-fns).
|
|
25
25
|
|
|
26
26
|
To install the package you need to have [npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm) (or [yarn](https://yarnpkg.com/getting-started/install)) and then run:
|
|
27
27
|
|
|
@@ -52,7 +52,7 @@ You could also import any individual module directly from an html page like this
|
|
|
52
52
|
```html
|
|
53
53
|
<script type="module">
|
|
54
54
|
import {
|
|
55
|
-
namedtuple,
|
|
55
|
+
namedtuple, FrozenSet, SortedSet, SortedMap
|
|
56
56
|
} from 'https://unpkg.com/atomic-fns/core/collections';
|
|
57
57
|
// your code goes here...
|
|
58
58
|
</script>
|
|
@@ -66,7 +66,7 @@ This library features a data model similar to [Python](https://docs.python.org/3
|
|
|
66
66
|
For example in Python collections `size()` is a method while in JS its just a property. So this library uses `size` property instead of methods. Similarly, the `len` function implementation checks for both `length` and `size` since many JS objects have a `length` property.
|
|
67
67
|
|
|
68
68
|
## Special method names
|
|
69
|
-
This library adds support for operators
|
|
69
|
+
This library adds support for operators using object methods such as:
|
|
70
70
|
- `obj.eq(other)` adds custom `obj == other`.
|
|
71
71
|
- `obj.lt(other)` adds custom `obj < other`.
|
|
72
72
|
- `obj.lte(other)` adds custom `obj <= other`.
|
|
@@ -76,11 +76,25 @@ This library adds support for operators via object methods like:
|
|
|
76
76
|
|
|
77
77
|
When you implement those, you can also apply operators to values like `eq(x, y), lte(x, y), compare(x, y)`, etc. to get the result of `x.<operator>(y)`.
|
|
78
78
|
|
|
79
|
-
|
|
79
|
+
## New Types
|
|
80
|
+
|
|
81
|
+
Introduces some common base interfaces and typing patterns you may have seen like `Optional`, `Result`, `Comparable`, `Iterator`, and others.
|
|
82
|
+
|
|
83
|
+
### Sorted Containers
|
|
84
|
+
- [SortedSet](https://atomic-fns.dev/classes/Collections.SortedSet.html)
|
|
85
|
+
- [SortedMap](https://atomic-fns.dev/classes/Collections.SortedMap.html)
|
|
86
|
+
- [SortedTree](https://atomic-fns.dev/classes/Collections.SortedTree.html)
|
|
87
|
+
|
|
88
|
+
### Other Containers
|
|
89
|
+
- [Deque](https://atomic-fns.dev/classes/Collections.Deque.html)
|
|
90
|
+
- [FrozenSet](https://atomic-fns.dev/classes/Collections.FrozenSet.html)
|
|
91
|
+
- [LRUCache](https://atomic-fns.dev/classes/Collections.LRUCache.html)
|
|
92
|
+
|
|
80
93
|
|
|
81
94
|
## Contributing
|
|
82
95
|
If you want to contribute to the project and make it better, your help is very welcome. Contributing is also a great way to learn more about social coding on Github, new technologies and and their ecosystems and how to make constructive, helpful bug reports, feature requests and the noblest of all contributions: a good, clean pull request. You will be listed as a **Champion** on the official site as well.
|
|
83
96
|
|
|
97
|
+
|
|
84
98
|
## License
|
|
85
99
|
|
|
86
100
|
[Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0)
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { Iteratee } from '../globals/index.js';
|
|
2
2
|
import { Mapping } from './abc.js';
|
|
3
3
|
/**
|
|
4
|
-
* Base append-only Cache collection.
|
|
4
|
+
* Base append-only Cache collection that supports adding and accessing keys in O(1).
|
|
5
|
+
* The collection has a fixed given size (default 1024) and when full, it evicts keys using LRU approach. This operation is also O(1).
|
|
6
|
+
* @template K, V
|
|
5
7
|
*/
|
|
6
8
|
export declare class Cache<K, V = any> extends Mapping<K, V> {
|
|
7
9
|
capacity: number;
|
|
@@ -13,6 +15,12 @@ export declare class Cache<K, V = any> extends Mapping<K, V> {
|
|
|
13
15
|
protected backward: Uint8Array | Uint16Array | Uint32Array;
|
|
14
16
|
protected K: K[];
|
|
15
17
|
protected V: V[];
|
|
18
|
+
/**
|
|
19
|
+
* Create a new cache object of fixed size.
|
|
20
|
+
* @param {number} [capacity=1024] The maximum number of keys to keep in cache.
|
|
21
|
+
* @param {Function} [Keys=Array] The constructor to use for the Keys array. When using numeric values, a TypedArray constructor can be used.
|
|
22
|
+
* @param {Function} [Values=Array] The constructor to use for the Values array. When using numeric values, a TypedArray constructor can be used.
|
|
23
|
+
*/
|
|
16
24
|
constructor(capacity?: number, Keys?: ArrayConstructor, Values?: ArrayConstructor);
|
|
17
25
|
/**
|
|
18
26
|
* This is just an alias of {@link Cache.set}.
|
|
@@ -30,6 +38,9 @@ export declare class Cache<K, V = any> extends Mapping<K, V> {
|
|
|
30
38
|
* Method used to clear the structure.
|
|
31
39
|
*/
|
|
32
40
|
clear(): void;
|
|
41
|
+
/**
|
|
42
|
+
* Returns the number of keys in the cache.
|
|
43
|
+
*/
|
|
33
44
|
get size(): number;
|
|
34
45
|
/**
|
|
35
46
|
* Method used to splay a value on top.
|
|
@@ -101,10 +112,20 @@ export declare class Cache<K, V = any> extends Mapping<K, V> {
|
|
|
101
112
|
*/
|
|
102
113
|
inspect(): Map<any, any>;
|
|
103
114
|
}
|
|
115
|
+
/**
|
|
116
|
+
* Implements a Least Recently Used fixed-capacity cache which supports updating, removing, and accessing keys in O(1).
|
|
117
|
+
*/
|
|
104
118
|
export declare class LRUCache<K, V> extends Cache<K, V> {
|
|
105
119
|
deletedSize: number;
|
|
106
120
|
deleted: Uint8Array | Uint16Array | Uint32Array;
|
|
121
|
+
/**
|
|
122
|
+
* Create a new LRU cache object of fixed size.
|
|
123
|
+
* @param {number} [capacity=1024] The maximum number of keys to keep in cache.
|
|
124
|
+
* @param {Function} [Keys=Array] The constructor to use for the Keys array. When using numeric values, a TypedArray constructor can be used.
|
|
125
|
+
* @param {Function} [Values=Array] The constructor to use for the Values array. When using numeric values, a TypedArray constructor can be used.
|
|
126
|
+
*/
|
|
107
127
|
constructor(capacity?: number, Keys?: ArrayConstructor, Values?: ArrayConstructor);
|
|
128
|
+
/** Remove all elements in the cache. */
|
|
108
129
|
clear(): void;
|
|
109
130
|
/**
|
|
110
131
|
* Method used to set the value for the given key in the cache.
|
|
@@ -3,7 +3,9 @@ import { IterableIterator } from '../itertools/index.js';
|
|
|
3
3
|
import { Mapping } from './abc.js';
|
|
4
4
|
import { getPointerArray } from './typedArrays.js';
|
|
5
5
|
/**
|
|
6
|
-
* Base append-only Cache collection.
|
|
6
|
+
* Base append-only Cache collection that supports adding and accessing keys in O(1).
|
|
7
|
+
* The collection has a fixed given size (default 1024) and when full, it evicts keys using LRU approach. This operation is also O(1).
|
|
8
|
+
* @template K, V
|
|
7
9
|
*/
|
|
8
10
|
export class Cache extends Mapping {
|
|
9
11
|
capacity;
|
|
@@ -15,6 +17,12 @@ export class Cache extends Mapping {
|
|
|
15
17
|
backward;
|
|
16
18
|
K;
|
|
17
19
|
V;
|
|
20
|
+
/**
|
|
21
|
+
* Create a new cache object of fixed size.
|
|
22
|
+
* @param {number} [capacity=1024] The maximum number of keys to keep in cache.
|
|
23
|
+
* @param {Function} [Keys=Array] The constructor to use for the Keys array. When using numeric values, a TypedArray constructor can be used.
|
|
24
|
+
* @param {Function} [Values=Array] The constructor to use for the Values array. When using numeric values, a TypedArray constructor can be used.
|
|
25
|
+
*/
|
|
18
26
|
constructor(capacity = 1024, Keys = Array, Values = Array) {
|
|
19
27
|
super();
|
|
20
28
|
this.capacity = capacity;
|
|
@@ -53,6 +61,9 @@ export class Cache extends Mapping {
|
|
|
53
61
|
this.tail = 0;
|
|
54
62
|
this.items = new Map();
|
|
55
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* Returns the number of keys in the cache.
|
|
66
|
+
*/
|
|
56
67
|
get size() {
|
|
57
68
|
return this.count;
|
|
58
69
|
}
|
|
@@ -264,14 +275,24 @@ export class Cache extends Mapping {
|
|
|
264
275
|
return this.inspect();
|
|
265
276
|
}
|
|
266
277
|
}
|
|
278
|
+
/**
|
|
279
|
+
* Implements a Least Recently Used fixed-capacity cache which supports updating, removing, and accessing keys in O(1).
|
|
280
|
+
*/
|
|
267
281
|
export class LRUCache extends Cache {
|
|
268
282
|
deletedSize = 0;
|
|
269
283
|
deleted;
|
|
284
|
+
/**
|
|
285
|
+
* Create a new LRU cache object of fixed size.
|
|
286
|
+
* @param {number} [capacity=1024] The maximum number of keys to keep in cache.
|
|
287
|
+
* @param {Function} [Keys=Array] The constructor to use for the Keys array. When using numeric values, a TypedArray constructor can be used.
|
|
288
|
+
* @param {Function} [Values=Array] The constructor to use for the Values array. When using numeric values, a TypedArray constructor can be used.
|
|
289
|
+
*/
|
|
270
290
|
constructor(capacity = 1024, Keys = Array, Values = Array) {
|
|
271
291
|
super(capacity, Keys, Values);
|
|
272
292
|
const PointerArray = getPointerArray(capacity);
|
|
273
293
|
this.deleted = new PointerArray(capacity);
|
|
274
294
|
}
|
|
295
|
+
/** Remove all elements in the cache. */
|
|
275
296
|
clear() {
|
|
276
297
|
super.clear();
|
|
277
298
|
this.deletedSize = 0;
|
|
@@ -4,7 +4,9 @@ import { Mapping } from './abc.js'
|
|
|
4
4
|
import { getPointerArray } from './typedArrays.js'
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* Base append-only Cache collection.
|
|
7
|
+
* Base append-only Cache collection that supports adding and accessing keys in O(1).
|
|
8
|
+
* The collection has a fixed given size (default 1024) and when full, it evicts keys using LRU approach. This operation is also O(1).
|
|
9
|
+
* @template K, V
|
|
8
10
|
*/
|
|
9
11
|
export class Cache<K, V = any> extends Mapping<K, V> {
|
|
10
12
|
capacity: number
|
|
@@ -17,6 +19,12 @@ export class Cache<K, V = any> extends Mapping<K, V> {
|
|
|
17
19
|
protected K: K[]
|
|
18
20
|
protected V: V[]
|
|
19
21
|
|
|
22
|
+
/**
|
|
23
|
+
* Create a new cache object of fixed size.
|
|
24
|
+
* @param {number} [capacity=1024] The maximum number of keys to keep in cache.
|
|
25
|
+
* @param {Function} [Keys=Array] The constructor to use for the Keys array. When using numeric values, a TypedArray constructor can be used.
|
|
26
|
+
* @param {Function} [Values=Array] The constructor to use for the Values array. When using numeric values, a TypedArray constructor can be used.
|
|
27
|
+
*/
|
|
20
28
|
constructor(capacity = 1024, Keys = Array, Values = Array) {
|
|
21
29
|
super()
|
|
22
30
|
this.capacity = capacity
|
|
@@ -61,6 +69,9 @@ export class Cache<K, V = any> extends Mapping<K, V> {
|
|
|
61
69
|
this.items = new Map()
|
|
62
70
|
}
|
|
63
71
|
|
|
72
|
+
/**
|
|
73
|
+
* Returns the number of keys in the cache.
|
|
74
|
+
*/
|
|
64
75
|
get size() {
|
|
65
76
|
return this.count
|
|
66
77
|
}
|
|
@@ -315,16 +326,26 @@ export class Cache<K, V = any> extends Mapping<K, V> {
|
|
|
315
326
|
}
|
|
316
327
|
}
|
|
317
328
|
|
|
329
|
+
/**
|
|
330
|
+
* Implements a Least Recently Used fixed-capacity cache which supports updating, removing, and accessing keys in O(1).
|
|
331
|
+
*/
|
|
318
332
|
export class LRUCache<K, V> extends Cache<K, V> {
|
|
319
333
|
deletedSize = 0
|
|
320
334
|
deleted: Uint8Array | Uint16Array | Uint32Array
|
|
321
335
|
|
|
336
|
+
/**
|
|
337
|
+
* Create a new LRU cache object of fixed size.
|
|
338
|
+
* @param {number} [capacity=1024] The maximum number of keys to keep in cache.
|
|
339
|
+
* @param {Function} [Keys=Array] The constructor to use for the Keys array. When using numeric values, a TypedArray constructor can be used.
|
|
340
|
+
* @param {Function} [Values=Array] The constructor to use for the Values array. When using numeric values, a TypedArray constructor can be used.
|
|
341
|
+
*/
|
|
322
342
|
constructor(capacity = 1024, Keys = Array, Values = Array) {
|
|
323
343
|
super(capacity, Keys, Values)
|
|
324
344
|
const PointerArray = getPointerArray(capacity)
|
|
325
345
|
this.deleted = new PointerArray(capacity)
|
|
326
346
|
}
|
|
327
347
|
|
|
348
|
+
/** Remove all elements in the cache. */
|
|
328
349
|
clear() {
|
|
329
350
|
super.clear()
|
|
330
351
|
this.deletedSize = 0
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Mapping } from './abc.js';
|
|
2
2
|
/**
|
|
3
|
-
* A `SortedMap` is a map that holds key value pairs
|
|
3
|
+
* A `SortedMap` is a map that holds key value pairs ordered by keys. Any primitive value (and objects that implement {@link Comparable} or {@link Ordered} interfaces) can be used as keys or values.
|
|
4
4
|
* @see {@link Operators.compare}
|
|
5
5
|
* @see {@link Operators.lt}
|
|
6
6
|
* @template K, V
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Mapping } from './abc.js';
|
|
2
2
|
import { SplayTree } from './SplayTree.js';
|
|
3
3
|
/**
|
|
4
|
-
* A `SortedMap` is a map that holds key value pairs
|
|
4
|
+
* A `SortedMap` is a map that holds key value pairs ordered by keys. Any primitive value (and objects that implement {@link Comparable} or {@link Ordered} interfaces) can be used as keys or values.
|
|
5
5
|
* @see {@link Operators.compare}
|
|
6
6
|
* @see {@link Operators.lt}
|
|
7
7
|
* @template K, V
|
|
@@ -2,7 +2,7 @@ import { Mapping } from './abc.js'
|
|
|
2
2
|
import { SplayTree } from './SplayTree.js'
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* A `SortedMap` is a map that holds key value pairs
|
|
5
|
+
* A `SortedMap` is a map that holds key value pairs ordered by keys. Any primitive value (and objects that implement {@link Comparable} or {@link Ordered} interfaces) can be used as keys or values.
|
|
6
6
|
* @see {@link Operators.compare}
|
|
7
7
|
* @see {@link Operators.lt}
|
|
8
8
|
* @template K, V
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import { Collection } from './abc.js';
|
|
2
|
+
/**
|
|
3
|
+
* A `SortedSet` is a set that holds values in order. Any primitive value (and objects that implement {@link Comparable} or {@link Ordered} interfaces) can be used as values.
|
|
4
|
+
* @see {@link Compare}
|
|
5
|
+
* @see {@link Ordered}
|
|
6
|
+
* @template K, V
|
|
7
|
+
*/
|
|
2
8
|
export declare class SortedSet<T> extends Collection {
|
|
3
9
|
private readonly store;
|
|
4
10
|
/**
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { Collection } from './abc.js';
|
|
2
2
|
import { SplayTree } from './SplayTree.js';
|
|
3
|
+
/**
|
|
4
|
+
* A `SortedSet` is a set that holds values in order. Any primitive value (and objects that implement {@link Comparable} or {@link Ordered} interfaces) can be used as values.
|
|
5
|
+
* @see {@link Compare}
|
|
6
|
+
* @see {@link Ordered}
|
|
7
|
+
* @template K, V
|
|
8
|
+
*/
|
|
3
9
|
export class SortedSet extends Collection {
|
|
4
10
|
store;
|
|
5
11
|
/**
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { Collection } from './abc.js'
|
|
2
2
|
import { SplayTree } from './SplayTree.js'
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* A `SortedSet` is a set that holds values in order. Any primitive value (and objects that implement {@link Comparable} or {@link Ordered} interfaces) can be used as values.
|
|
6
|
+
* @see {@link Compare}
|
|
7
|
+
* @see {@link Ordered}
|
|
8
|
+
* @template K, V
|
|
9
|
+
*/
|
|
4
10
|
export class SortedSet<T> extends Collection {
|
|
5
11
|
private readonly store: SplayTree<T>
|
|
6
12
|
/**
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Comparer } from '../operators/index.js';
|
|
2
2
|
import { Mapping } from './abc.js';
|
|
3
3
|
/**
|
|
4
|
-
* A `SortedTree` is a map that holds key value pairs
|
|
5
|
-
* @see {@link
|
|
6
|
-
* @see {@link
|
|
4
|
+
* A `SortedTree` is a map that holds key value pairs ordered by keys. Any primitive value (and objects that implement {@link Comparable} or {@link Ordered} interfaces) can be used as keys or values.
|
|
5
|
+
* @see {@link Compare}
|
|
6
|
+
* @see {@link Ordered}
|
|
7
7
|
* @template K, V
|
|
8
8
|
*/
|
|
9
9
|
export declare class SortedTree<K, V> extends Mapping<K, V> {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Mapping } from './abc.js';
|
|
2
2
|
import { BTree } from './BTree.js';
|
|
3
3
|
/**
|
|
4
|
-
* A `SortedTree` is a map that holds key value pairs
|
|
5
|
-
* @see {@link
|
|
6
|
-
* @see {@link
|
|
4
|
+
* A `SortedTree` is a map that holds key value pairs ordered by keys. Any primitive value (and objects that implement {@link Comparable} or {@link Ordered} interfaces) can be used as keys or values.
|
|
5
|
+
* @see {@link Compare}
|
|
6
|
+
* @see {@link Ordered}
|
|
7
7
|
* @template K, V
|
|
8
8
|
*/
|
|
9
9
|
export class SortedTree extends Mapping {
|
|
@@ -3,9 +3,9 @@ import { Mapping } from './abc.js'
|
|
|
3
3
|
import { BTree } from './BTree.js'
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* A `SortedTree` is a map that holds key value pairs
|
|
7
|
-
* @see {@link
|
|
8
|
-
* @see {@link
|
|
6
|
+
* A `SortedTree` is a map that holds key value pairs ordered by keys. Any primitive value (and objects that implement {@link Comparable} or {@link Ordered} interfaces) can be used as keys or values.
|
|
7
|
+
* @see {@link Compare}
|
|
8
|
+
* @see {@link Ordered}
|
|
9
9
|
* @template K, V
|
|
10
10
|
*/
|
|
11
11
|
export class SortedTree<K, V> extends Mapping<K, V> {
|
package/core/collections/abc.ts
CHANGED
|
@@ -2,107 +2,114 @@ import { Iteratee } from '../globals/index.js';
|
|
|
2
2
|
import { Sequence } from './abc.js';
|
|
3
3
|
/**
|
|
4
4
|
* Fixed capacity double-ended queue implemented as ring deque.
|
|
5
|
-
*
|
|
6
|
-
* @constructor
|
|
5
|
+
* @template T
|
|
7
6
|
*/
|
|
8
|
-
export declare class Deque<T> extends Sequence<T> {
|
|
7
|
+
export declare class Deque<T = any> extends Sequence<T> {
|
|
9
8
|
items: T[];
|
|
10
9
|
start: number;
|
|
11
10
|
count: number;
|
|
12
11
|
capacity: number;
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
ArrayConstructor: any;
|
|
13
|
+
/**
|
|
14
|
+
* Creates a new `Deque` instance of a fixed size.
|
|
15
|
+
* @param {Array} [arrType = []] The initial elements or array type to use (accepts any kind of typed array).
|
|
16
|
+
* @param {number} [capacity=1024] The fixed size of the deque. Defaults to `1024`.
|
|
17
|
+
*/
|
|
18
|
+
constructor(arrType?: T[], capacity?: number);
|
|
19
|
+
/** Returns the total number of elements in the deque. */
|
|
15
20
|
get size(): number;
|
|
16
21
|
/**
|
|
17
22
|
* Method used to clear the structure.
|
|
18
|
-
*
|
|
19
|
-
* @return {undefined}
|
|
20
23
|
*/
|
|
21
24
|
clear(): void;
|
|
22
25
|
/**
|
|
23
26
|
* Alias of {@link Deque.append}
|
|
24
|
-
*
|
|
25
|
-
* @
|
|
26
|
-
* @return {number} - Returns the new size of the deque.
|
|
27
|
+
* @param {T} item Item to append.
|
|
28
|
+
* @returns {number} Returns the new size of the deque.
|
|
27
29
|
*/
|
|
28
30
|
add(item: any): number;
|
|
29
31
|
/**
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* @
|
|
33
|
-
* @return {number} - Returns the new size of the deque.
|
|
32
|
+
* Appends a new element to the end of the deque.
|
|
33
|
+
* @param {T} item Item to append.
|
|
34
|
+
* @returns {number} Returns the new size of the deque.
|
|
34
35
|
*/
|
|
35
36
|
append(item: any): number;
|
|
36
37
|
/**
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
* @
|
|
40
|
-
* @return {number} - Returns the new size of the deque.
|
|
38
|
+
* Appends a new element to the beginning of the deque.
|
|
39
|
+
* @param {T} item Item to prepend.
|
|
40
|
+
* @returns {number} Returns the new size of the deque.
|
|
41
41
|
*/
|
|
42
42
|
appendleft(item: any): number;
|
|
43
43
|
/**
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
* @return {any} - Returns the popped item.
|
|
44
|
+
* Removes and returns the element at the end of the deque.
|
|
45
|
+
* @returns {?T} Returns the popped item.
|
|
47
46
|
*/
|
|
48
47
|
pop(): T | undefined;
|
|
49
48
|
/**
|
|
50
49
|
* Alias of {@link Deque.pop}
|
|
50
|
+
* @returns {?T} Returns the popped item.
|
|
51
51
|
*/
|
|
52
52
|
remove(): T | undefined;
|
|
53
53
|
/**
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
* @return {any} - Returns the shifted item.
|
|
54
|
+
* Removes and returns the element at the beginning of the deque.
|
|
55
|
+
* @returns {?T} Returns the removed deque element.
|
|
57
56
|
*/
|
|
58
57
|
popleft(): T | undefined;
|
|
59
58
|
/**
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
* @return {any}
|
|
59
|
+
* Returns the element at the beginning of the deque.
|
|
60
|
+
* @returns {?T} The element if exists
|
|
63
61
|
*/
|
|
64
62
|
first(): T | undefined;
|
|
65
63
|
/**
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
* @
|
|
69
|
-
* @return {any}
|
|
64
|
+
* Returns the element at a specified index position in the deque.
|
|
65
|
+
* @param {number} index The given index
|
|
66
|
+
* @returns {?T} The element if exists
|
|
70
67
|
*/
|
|
71
68
|
get(index: any): T | undefined;
|
|
72
69
|
/**
|
|
73
|
-
* Update the
|
|
74
|
-
* @param index The given index
|
|
75
|
-
* @param value The new value to set at `index`.
|
|
70
|
+
* Update the element at a given `index`.
|
|
71
|
+
* @param {number} index The given index
|
|
76
72
|
*/
|
|
77
73
|
set(index: number, value: T): void;
|
|
74
|
+
/**
|
|
75
|
+
* Check if a given element is in the deque.
|
|
76
|
+
* @param {T} x The value to find
|
|
77
|
+
* @returns {boolean} `true` if the value is found
|
|
78
|
+
*/
|
|
78
79
|
contains(x: any): boolean;
|
|
80
|
+
/**
|
|
81
|
+
* Returns the first element that matches the `iteratee` function.
|
|
82
|
+
* @param {Iteratee<T>} iteratee A function that will be invoked per element
|
|
83
|
+
* @returns {?T} The element if exists
|
|
84
|
+
*/
|
|
79
85
|
find(iteratee: Iteratee<T>): T | undefined;
|
|
80
86
|
/**
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
* @param {function} iteratee - Function to call for each item.
|
|
84
|
-
* @param {object} scope - Optional scope.
|
|
85
|
-
* @return {undefined}
|
|
87
|
+
* Calls `iteratee` function for every element in the deque.
|
|
88
|
+
* @param {Iteratee<T>} iteratee A function that will be invoked per element
|
|
86
89
|
*/
|
|
87
90
|
forEach(iteratee: any): void;
|
|
91
|
+
/**
|
|
92
|
+
* Returns a new array with all the elements in reverse order.
|
|
93
|
+
* @returns {Array<T>} The elements reversed
|
|
94
|
+
*/
|
|
88
95
|
reversed(): any;
|
|
89
96
|
/**
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
* @return {array}
|
|
97
|
+
* Returns a new array with all the elements in the order they were added to the deque.
|
|
98
|
+
* @returns {Array<T>} The elements array
|
|
93
99
|
*/
|
|
94
100
|
toArray(): any;
|
|
95
101
|
/**
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
* @return {Iterator}
|
|
102
|
+
* Returns an iterator over the deque's values.
|
|
103
|
+
* @returns {Iterator}
|
|
99
104
|
*/
|
|
100
105
|
values(): Iterable<T>;
|
|
106
|
+
/**
|
|
107
|
+
* Alias of {@link Deque.values}. Returns iterator of values.
|
|
108
|
+
*/
|
|
101
109
|
keys(): Iterable<T>;
|
|
102
110
|
/**
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
* @return {Iterator}
|
|
111
|
+
* Creates an iterator of `[index, value]` pairs for all elements in the deque.
|
|
112
|
+
* @returns {Iterator}
|
|
106
113
|
*/
|
|
107
114
|
entries(): Iterator<[number, T], any, undefined> & Iterable<[number, T]>;
|
|
108
115
|
[Symbol.iterator](): Iterable<T>;
|