min-heap-typed 1.49.6 → 1.49.8
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/dist/data-structures/binary-tree/avl-tree.d.ts +3 -3
- package/dist/data-structures/binary-tree/avl-tree.js +5 -5
- package/dist/data-structures/binary-tree/binary-tree.d.ts +3 -3
- package/dist/data-structures/binary-tree/binary-tree.js +11 -13
- package/dist/data-structures/binary-tree/bst.d.ts +3 -3
- package/dist/data-structures/binary-tree/bst.js +6 -7
- package/dist/data-structures/binary-tree/rb-tree.d.ts +2 -2
- package/dist/data-structures/binary-tree/rb-tree.js +6 -6
- package/dist/data-structures/binary-tree/tree-multimap.d.ts +1 -1
- package/dist/data-structures/binary-tree/tree-multimap.js +3 -3
- package/dist/data-structures/hash/hash-map.d.ts +24 -27
- package/dist/data-structures/hash/hash-map.js +35 -35
- package/dist/data-structures/hash/index.d.ts +0 -1
- package/dist/data-structures/hash/index.js +0 -1
- package/dist/data-structures/heap/heap.d.ts +2 -1
- package/dist/data-structures/heap/heap.js +13 -13
- package/dist/data-structures/heap/max-heap.js +1 -1
- package/dist/data-structures/heap/min-heap.js +1 -1
- package/dist/data-structures/linked-list/doubly-linked-list.js +1 -1
- package/dist/data-structures/linked-list/singly-linked-list.js +1 -3
- package/dist/data-structures/linked-list/skip-linked-list.d.ts +2 -8
- package/dist/data-structures/linked-list/skip-linked-list.js +15 -18
- package/dist/data-structures/matrix/matrix.d.ts +2 -7
- package/dist/data-structures/matrix/matrix.js +0 -7
- package/dist/data-structures/priority-queue/max-priority-queue.js +1 -1
- package/dist/data-structures/priority-queue/min-priority-queue.js +1 -1
- package/dist/data-structures/priority-queue/priority-queue.js +1 -1
- package/dist/data-structures/queue/deque.d.ts +2 -11
- package/dist/data-structures/queue/deque.js +9 -13
- package/dist/data-structures/queue/queue.d.ts +13 -13
- package/dist/data-structures/queue/queue.js +29 -25
- package/dist/data-structures/stack/stack.js +2 -3
- package/dist/data-structures/trie/trie.d.ts +2 -2
- package/dist/data-structures/trie/trie.js +9 -5
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +2 -2
- package/dist/types/data-structures/binary-tree/bst.d.ts +1 -1
- package/dist/types/data-structures/binary-tree/rb-tree.d.ts +1 -1
- package/dist/types/data-structures/binary-tree/tree-multimap.d.ts +1 -1
- package/dist/types/data-structures/hash/hash-map.d.ts +5 -2
- package/dist/types/data-structures/hash/index.d.ts +0 -1
- package/dist/types/data-structures/hash/index.js +0 -1
- package/dist/types/data-structures/heap/heap.d.ts +1 -1
- package/dist/types/data-structures/linked-list/index.d.ts +1 -0
- package/dist/types/data-structures/linked-list/index.js +1 -0
- package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +4 -1
- package/dist/types/data-structures/matrix/index.d.ts +1 -0
- package/dist/types/data-structures/matrix/index.js +1 -0
- package/dist/types/data-structures/matrix/matrix.d.ts +7 -1
- package/dist/types/data-structures/queue/deque.d.ts +3 -1
- package/dist/types/data-structures/trie/trie.d.ts +3 -1
- package/package.json +2 -2
- package/src/data-structures/binary-tree/avl-tree.ts +4 -4
- package/src/data-structures/binary-tree/binary-tree.ts +10 -14
- package/src/data-structures/binary-tree/bst.ts +5 -7
- package/src/data-structures/binary-tree/rb-tree.ts +4 -5
- package/src/data-structures/binary-tree/tree-multimap.ts +2 -2
- package/src/data-structures/hash/hash-map.ts +46 -50
- package/src/data-structures/hash/index.ts +0 -1
- package/src/data-structures/heap/heap.ts +20 -19
- package/src/data-structures/heap/max-heap.ts +1 -1
- package/src/data-structures/heap/min-heap.ts +1 -1
- package/src/data-structures/linked-list/doubly-linked-list.ts +1 -1
- package/src/data-structures/linked-list/singly-linked-list.ts +2 -5
- package/src/data-structures/linked-list/skip-linked-list.ts +15 -16
- package/src/data-structures/matrix/matrix.ts +2 -10
- package/src/data-structures/priority-queue/max-priority-queue.ts +1 -1
- package/src/data-structures/priority-queue/min-priority-queue.ts +1 -1
- package/src/data-structures/priority-queue/priority-queue.ts +1 -1
- package/src/data-structures/queue/deque.ts +11 -15
- package/src/data-structures/queue/queue.ts +29 -28
- package/src/data-structures/stack/stack.ts +3 -6
- package/src/data-structures/trie/trie.ts +10 -11
- package/src/types/data-structures/binary-tree/binary-tree.ts +2 -2
- package/src/types/data-structures/binary-tree/bst.ts +1 -1
- package/src/types/data-structures/binary-tree/rb-tree.ts +1 -1
- package/src/types/data-structures/binary-tree/tree-multimap.ts +1 -1
- package/src/types/data-structures/hash/hash-map.ts +6 -2
- package/src/types/data-structures/hash/index.ts +0 -1
- package/src/types/data-structures/heap/heap.ts +1 -1
- package/src/types/data-structures/linked-list/index.ts +1 -0
- package/src/types/data-structures/linked-list/skip-linked-list.ts +1 -1
- package/src/types/data-structures/matrix/index.ts +1 -0
- package/src/types/data-structures/matrix/matrix.ts +7 -1
- package/src/types/data-structures/queue/deque.ts +1 -1
- package/src/types/data-structures/trie/trie.ts +1 -1
- package/dist/data-structures/hash/hash-table.d.ts +0 -108
- package/dist/data-structures/hash/hash-table.js +0 -281
- package/dist/types/data-structures/hash/hash-table.d.ts +0 -1
- package/dist/types/data-structures/hash/hash-table.js +0 -2
- package/dist/types/data-structures/matrix/matrix2d.d.ts +0 -1
- package/dist/types/data-structures/matrix/matrix2d.js +0 -2
- package/dist/types/data-structures/matrix/vector2d.d.ts +0 -1
- package/dist/types/data-structures/matrix/vector2d.js +0 -2
- package/src/data-structures/hash/hash-table.ts +0 -318
- package/src/types/data-structures/hash/hash-table.ts +0 -1
- package/src/types/data-structures/matrix/matrix2d.ts +0 -1
- package/src/types/data-structures/matrix/vector2d.ts +0 -1
|
@@ -13,7 +13,7 @@ const heap_1 = require("./heap");
|
|
|
13
13
|
* 8. Graph Algorithms: Such as Dijkstra's shortest path algorithm and Prim's minimum spanning tree algorithm, which use heaps to improve performance.
|
|
14
14
|
*/
|
|
15
15
|
class MaxHeap extends heap_1.Heap {
|
|
16
|
-
constructor(elements, options = {
|
|
16
|
+
constructor(elements = [], options = {
|
|
17
17
|
comparator: (a, b) => {
|
|
18
18
|
if (!(typeof a === 'number' && typeof b === 'number')) {
|
|
19
19
|
throw new Error('The a, b params of compare function must be number');
|
|
@@ -13,7 +13,7 @@ const heap_1 = require("./heap");
|
|
|
13
13
|
* 8. Graph Algorithms: Such as Dijkstra's shortest path algorithm and Prim's minimum spanning tree algorithm, which use heaps to improve performance.
|
|
14
14
|
*/
|
|
15
15
|
class MinHeap extends heap_1.Heap {
|
|
16
|
-
constructor(elements, options = {
|
|
16
|
+
constructor(elements = [], options = {
|
|
17
17
|
comparator: (a, b) => {
|
|
18
18
|
if (!(typeof a === 'number' && typeof b === 'number')) {
|
|
19
19
|
throw new Error('The a, b params of compare function must be number');
|
|
@@ -25,7 +25,7 @@ class DoublyLinkedList extends base_1.IterableElementBase {
|
|
|
25
25
|
/**
|
|
26
26
|
* The constructor initializes the linked list with an empty head, tail, and size.
|
|
27
27
|
*/
|
|
28
|
-
constructor(elements) {
|
|
28
|
+
constructor(elements = []) {
|
|
29
29
|
super();
|
|
30
30
|
this._head = undefined;
|
|
31
31
|
this._tail = undefined;
|
|
@@ -18,10 +18,8 @@ class SinglyLinkedList extends base_1.IterableElementBase {
|
|
|
18
18
|
/**
|
|
19
19
|
* The constructor initializes the linked list with an empty head, tail, and length.
|
|
20
20
|
*/
|
|
21
|
-
constructor(elements) {
|
|
21
|
+
constructor(elements = []) {
|
|
22
22
|
super();
|
|
23
|
-
this._head = undefined;
|
|
24
|
-
this._tail = undefined;
|
|
25
23
|
this._size = 0;
|
|
26
24
|
if (elements) {
|
|
27
25
|
for (const el of elements)
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
|
|
6
6
|
* @license MIT License
|
|
7
7
|
*/
|
|
8
|
+
import type { SkipLinkedListOptions } from '../../types';
|
|
8
9
|
export declare class SkipListNode<K, V> {
|
|
9
10
|
key: K;
|
|
10
11
|
value: V;
|
|
@@ -12,14 +13,7 @@ export declare class SkipListNode<K, V> {
|
|
|
12
13
|
constructor(key: K, value: V, level: number);
|
|
13
14
|
}
|
|
14
15
|
export declare class SkipList<K, V> {
|
|
15
|
-
|
|
16
|
-
* The constructor initializes a SkipList with a specified maximum level and probability.
|
|
17
|
-
* @param [maxLevel=16] - The `maxLevel` parameter represents the maximum level that a skip list can have. It determines
|
|
18
|
-
* the maximum number of levels that can be created in the skip list.
|
|
19
|
-
* @param [probability=0.5] - The probability parameter represents the probability of a node being promoted to a higher
|
|
20
|
-
* level in the skip list. It is used to determine the height of each node in the skip list.
|
|
21
|
-
*/
|
|
22
|
-
constructor(maxLevel?: number, probability?: number);
|
|
16
|
+
constructor(elements?: Iterable<[K, V]>, options?: SkipLinkedListOptions);
|
|
23
17
|
protected _head: SkipListNode<K, V>;
|
|
24
18
|
get head(): SkipListNode<K, V>;
|
|
25
19
|
protected _level: number;
|
|
@@ -1,11 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* data-structure-typed
|
|
4
|
-
*
|
|
5
|
-
* @author Tyler Zeng
|
|
6
|
-
* @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
|
|
7
|
-
* @license MIT License
|
|
8
|
-
*/
|
|
9
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
3
|
exports.SkipList = exports.SkipListNode = void 0;
|
|
11
4
|
class SkipListNode {
|
|
@@ -17,18 +10,22 @@ class SkipListNode {
|
|
|
17
10
|
}
|
|
18
11
|
exports.SkipListNode = SkipListNode;
|
|
19
12
|
class SkipList {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
* @param [maxLevel=16] - The `maxLevel` parameter represents the maximum level that a skip list can have. It determines
|
|
23
|
-
* the maximum number of levels that can be created in the skip list.
|
|
24
|
-
* @param [probability=0.5] - The probability parameter represents the probability of a node being promoted to a higher
|
|
25
|
-
* level in the skip list. It is used to determine the height of each node in the skip list.
|
|
26
|
-
*/
|
|
27
|
-
constructor(maxLevel = 16, probability = 0.5) {
|
|
28
|
-
this._head = new SkipListNode(undefined, undefined, maxLevel);
|
|
13
|
+
constructor(elements = [], options) {
|
|
14
|
+
this._head = new SkipListNode(undefined, undefined, this.maxLevel);
|
|
29
15
|
this._level = 0;
|
|
30
|
-
this._maxLevel =
|
|
31
|
-
this._probability =
|
|
16
|
+
this._maxLevel = 16;
|
|
17
|
+
this._probability = 0.5;
|
|
18
|
+
if (options) {
|
|
19
|
+
const { maxLevel, probability } = options;
|
|
20
|
+
if (typeof maxLevel === 'number')
|
|
21
|
+
this._maxLevel = maxLevel;
|
|
22
|
+
if (typeof probability === 'number')
|
|
23
|
+
this._probability = probability;
|
|
24
|
+
}
|
|
25
|
+
if (elements) {
|
|
26
|
+
for (const [key, value] of elements)
|
|
27
|
+
this.add(key, value);
|
|
28
|
+
}
|
|
32
29
|
}
|
|
33
30
|
get head() {
|
|
34
31
|
return this._head;
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
|
|
6
6
|
* @license MIT License
|
|
7
7
|
*/
|
|
8
|
+
import type { MatrixOptions } from '../../types';
|
|
8
9
|
export declare class Matrix {
|
|
9
10
|
/**
|
|
10
11
|
* The constructor function initializes a matrix object with the provided data and options, or with
|
|
@@ -13,13 +14,7 @@ export declare class Matrix {
|
|
|
13
14
|
* @param [options] - The `options` parameter is an optional object that can contain the following
|
|
14
15
|
* properties:
|
|
15
16
|
*/
|
|
16
|
-
constructor(data: number[][], options?:
|
|
17
|
-
rows?: number;
|
|
18
|
-
cols?: number;
|
|
19
|
-
addFn?: (a: number, b: number) => any;
|
|
20
|
-
subtractFn?: (a: number, b: number) => any;
|
|
21
|
-
multiplyFn?: (a: number, b: number) => any;
|
|
22
|
-
});
|
|
17
|
+
constructor(data: number[][], options?: MatrixOptions);
|
|
23
18
|
protected _rows: number;
|
|
24
19
|
get rows(): number;
|
|
25
20
|
protected _cols: number;
|
|
@@ -1,11 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* data-structure-typed
|
|
4
|
-
*
|
|
5
|
-
* @author Tyler Zeng
|
|
6
|
-
* @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
|
|
7
|
-
* @license MIT License
|
|
8
|
-
*/
|
|
9
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
3
|
exports.Matrix = void 0;
|
|
11
4
|
class Matrix {
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.MaxPriorityQueue = void 0;
|
|
4
4
|
const priority_queue_1 = require("./priority-queue");
|
|
5
5
|
class MaxPriorityQueue extends priority_queue_1.PriorityQueue {
|
|
6
|
-
constructor(elements, options = {
|
|
6
|
+
constructor(elements = [], options = {
|
|
7
7
|
comparator: (a, b) => {
|
|
8
8
|
if (!(typeof a === 'number' && typeof b === 'number')) {
|
|
9
9
|
throw new Error('The a, b params of compare function must be number');
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.MinPriorityQueue = void 0;
|
|
4
4
|
const priority_queue_1 = require("./priority-queue");
|
|
5
5
|
class MinPriorityQueue extends priority_queue_1.PriorityQueue {
|
|
6
|
-
constructor(elements, options = {
|
|
6
|
+
constructor(elements = [], options = {
|
|
7
7
|
comparator: (a, b) => {
|
|
8
8
|
if (!(typeof a === 'number' && typeof b === 'number')) {
|
|
9
9
|
throw new Error('The a, b params of compare function must be number');
|
|
@@ -11,7 +11,7 @@ const heap_1 = require("../heap");
|
|
|
11
11
|
* 6. Kth Largest Element in a Data Stream: Used to maintain a min-heap of size K for quickly finding the Kth largest element in stream data
|
|
12
12
|
*/
|
|
13
13
|
class PriorityQueue extends heap_1.Heap {
|
|
14
|
-
constructor(elements, options) {
|
|
14
|
+
constructor(elements = [], options) {
|
|
15
15
|
super(elements, options);
|
|
16
16
|
}
|
|
17
17
|
}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
|
|
6
6
|
* @license MIT License
|
|
7
7
|
*/
|
|
8
|
-
import type { ElementCallback, IterableWithSizeOrLength } from '../../types';
|
|
8
|
+
import type { DequeOptions, ElementCallback, IterableWithSizeOrLength } from '../../types';
|
|
9
9
|
import { IterableElementBase } from '../base';
|
|
10
10
|
/**
|
|
11
11
|
* 1. Operations at Both Ends: Supports adding and removing elements at both the front and back of the queue. This allows it to be used as a stack (last in, first out) and a queue (first in, first out).
|
|
@@ -21,16 +21,7 @@ export declare class Deque<E> extends IterableElementBase<E> {
|
|
|
21
21
|
protected _lastInBucket: number;
|
|
22
22
|
protected _bucketCount: number;
|
|
23
23
|
protected readonly _bucketSize: number;
|
|
24
|
-
|
|
25
|
-
* The constructor initializes a data structure with a specified bucket size and populates it with
|
|
26
|
-
* elements from an iterable.
|
|
27
|
-
* @param elements - The `elements` parameter is an iterable object (such as an array or a Set) that
|
|
28
|
-
* contains the initial elements to be stored in the data structure. It can also be an object with a
|
|
29
|
-
* `length` property or a `size` property, which represents the number of elements in the iterable.
|
|
30
|
-
* @param bucketSize - The `bucketSize` parameter is the maximum number of elements that can be
|
|
31
|
-
* stored in each bucket. It determines the size of each bucket in the data structure.
|
|
32
|
-
*/
|
|
33
|
-
constructor(elements?: IterableWithSizeOrLength<E>, bucketSize?: number);
|
|
24
|
+
constructor(elements?: IterableWithSizeOrLength<E>, options?: DequeOptions);
|
|
34
25
|
protected _buckets: E[][];
|
|
35
26
|
get buckets(): E[][];
|
|
36
27
|
protected _size: number;
|
|
@@ -11,24 +11,21 @@ const utils_1 = require("../../utils");
|
|
|
11
11
|
* 5. Performance jitter: Deque may experience performance jitter, but DoublyLinkedList will not
|
|
12
12
|
*/
|
|
13
13
|
class Deque extends base_1.IterableElementBase {
|
|
14
|
-
|
|
15
|
-
* The constructor initializes a data structure with a specified bucket size and populates it with
|
|
16
|
-
* elements from an iterable.
|
|
17
|
-
* @param elements - The `elements` parameter is an iterable object (such as an array or a Set) that
|
|
18
|
-
* contains the initial elements to be stored in the data structure. It can also be an object with a
|
|
19
|
-
* `length` property or a `size` property, which represents the number of elements in the iterable.
|
|
20
|
-
* @param bucketSize - The `bucketSize` parameter is the maximum number of elements that can be
|
|
21
|
-
* stored in each bucket. It determines the size of each bucket in the data structure.
|
|
22
|
-
*/
|
|
23
|
-
constructor(elements = [], bucketSize = 1 << 12) {
|
|
14
|
+
constructor(elements = [], options) {
|
|
24
15
|
super();
|
|
25
16
|
this._bucketFirst = 0;
|
|
26
17
|
this._firstInBucket = 0;
|
|
27
18
|
this._bucketLast = 0;
|
|
28
19
|
this._lastInBucket = 0;
|
|
29
20
|
this._bucketCount = 0;
|
|
21
|
+
this._bucketSize = 1 << 12;
|
|
30
22
|
this._buckets = [];
|
|
31
23
|
this._size = 0;
|
|
24
|
+
if (options) {
|
|
25
|
+
const { bucketSize } = options;
|
|
26
|
+
if (typeof bucketSize === 'number')
|
|
27
|
+
this._bucketSize = bucketSize;
|
|
28
|
+
}
|
|
32
29
|
let _size;
|
|
33
30
|
if ('length' in elements) {
|
|
34
31
|
if (elements.length instanceof Function)
|
|
@@ -42,7 +39,6 @@ class Deque extends base_1.IterableElementBase {
|
|
|
42
39
|
else
|
|
43
40
|
_size = elements.size;
|
|
44
41
|
}
|
|
45
|
-
this._bucketSize = bucketSize;
|
|
46
42
|
this._bucketCount = (0, utils_1.calcMinUnitsRequired)(_size, this._bucketSize) || 1;
|
|
47
43
|
for (let i = 0; i < this._bucketCount; ++i) {
|
|
48
44
|
this._buckets.push(new Array(this._bucketSize));
|
|
@@ -612,7 +608,7 @@ class Deque extends base_1.IterableElementBase {
|
|
|
612
608
|
* satisfy the given predicate function.
|
|
613
609
|
*/
|
|
614
610
|
filter(predicate, thisArg) {
|
|
615
|
-
const newDeque = new Deque([], this._bucketSize);
|
|
611
|
+
const newDeque = new Deque([], { bucketSize: this._bucketSize });
|
|
616
612
|
let index = 0;
|
|
617
613
|
for (const el of this) {
|
|
618
614
|
if (predicate.call(thisArg, el, index, this)) {
|
|
@@ -640,7 +636,7 @@ class Deque extends base_1.IterableElementBase {
|
|
|
640
636
|
* @returns a new Deque object with the mapped values.
|
|
641
637
|
*/
|
|
642
638
|
map(callback, thisArg) {
|
|
643
|
-
const newDeque = new Deque([], this._bucketSize);
|
|
639
|
+
const newDeque = new Deque([], { bucketSize: this._bucketSize });
|
|
644
640
|
let index = 0;
|
|
645
641
|
for (const el of this) {
|
|
646
642
|
newDeque.push(callback.call(thisArg, el, index, this));
|
|
@@ -12,19 +12,19 @@ import { SinglyLinkedList } from '../linked-list';
|
|
|
12
12
|
* 3. Uses: Queues are commonly used to manage a series of tasks or elements that need to be processed in order. For example, managing task queues in a multi-threaded environment, or in algorithms for data structures like trees and graphs for breadth-first search.
|
|
13
13
|
* 4. Task Scheduling: Managing the order of task execution in operating systems or applications.
|
|
14
14
|
* 5. Data Buffering: Acting as a buffer for data packets in network communication.
|
|
15
|
-
* 6. Breadth-First Search (BFS): In traversal algorithms for graphs and trees, queues store
|
|
15
|
+
* 6. Breadth-First Search (BFS): In traversal algorithms for graphs and trees, queues store elements that are to be visited.
|
|
16
16
|
* 7. Real-time Queuing: Like queuing systems in banks or supermarkets.
|
|
17
17
|
*/
|
|
18
18
|
export declare class Queue<E = any> extends IterableElementBase<E> {
|
|
19
19
|
/**
|
|
20
20
|
* The constructor initializes an instance of a class with an optional array of elements and sets the offset to 0.
|
|
21
21
|
* @param {E[]} [elements] - The `elements` parameter is an optional array of elements of type `E`. If provided, it
|
|
22
|
-
* will be used to initialize the `
|
|
22
|
+
* will be used to initialize the `_elements` property of the class. If not provided, the `_elements` property will be
|
|
23
23
|
* initialized as an empty array.
|
|
24
24
|
*/
|
|
25
|
-
constructor(elements?: E
|
|
26
|
-
protected
|
|
27
|
-
get
|
|
25
|
+
constructor(elements?: Iterable<E>);
|
|
26
|
+
protected _elements: E[];
|
|
27
|
+
get elements(): E[];
|
|
28
28
|
protected _offset: number;
|
|
29
29
|
get offset(): number;
|
|
30
30
|
/**
|
|
@@ -36,8 +36,8 @@ export declare class Queue<E = any> extends IterableElementBase<E> {
|
|
|
36
36
|
* Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
|
|
37
37
|
* Space Complexity: O(1) - no additional space is used.
|
|
38
38
|
*
|
|
39
|
-
* The `first` function returns the first element of the array `
|
|
40
|
-
* @returns The `get first()` method returns the first element of the data structure, represented by the `
|
|
39
|
+
* The `first` function returns the first element of the array `_elements` if it exists, otherwise it returns `undefined`.
|
|
40
|
+
* @returns The `get first()` method returns the first element of the data structure, represented by the `_elements` array at
|
|
41
41
|
* the `_offset` index. If the data structure is empty (size is 0), it returns `undefined`.
|
|
42
42
|
*/
|
|
43
43
|
get first(): E | undefined;
|
|
@@ -50,7 +50,7 @@ export declare class Queue<E = any> extends IterableElementBase<E> {
|
|
|
50
50
|
* Space Complexity: O(1) - no additional space is used.
|
|
51
51
|
*
|
|
52
52
|
* The `last` function returns the last element in an array-like data structure, or undefined if the structure is empty.
|
|
53
|
-
* @returns The method `get last()` returns the last element of the `
|
|
53
|
+
* @returns The method `get last()` returns the last element of the `_elements` array if the array is not empty. If the
|
|
54
54
|
* array is empty, it returns `undefined`.
|
|
55
55
|
*/
|
|
56
56
|
get last(): E | undefined;
|
|
@@ -101,8 +101,8 @@ export declare class Queue<E = any> extends IterableElementBase<E> {
|
|
|
101
101
|
* Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
|
|
102
102
|
* Space Complexity: O(1) - no additional space is used.
|
|
103
103
|
*
|
|
104
|
-
* The `peek` function returns the first element of the array `
|
|
105
|
-
* @returns The `peek()` method returns the first element of the data structure, represented by the `
|
|
104
|
+
* The `peek` function returns the first element of the array `_elements` if it exists, otherwise it returns `undefined`.
|
|
105
|
+
* @returns The `peek()` method returns the first element of the data structure, represented by the `_elements` array at
|
|
106
106
|
* the `_offset` index. If the data structure is empty (size is 0), it returns `undefined`.
|
|
107
107
|
*/
|
|
108
108
|
peek(): E | undefined;
|
|
@@ -115,7 +115,7 @@ export declare class Queue<E = any> extends IterableElementBase<E> {
|
|
|
115
115
|
* Space Complexity: O(1) - no additional space is used.
|
|
116
116
|
*
|
|
117
117
|
* The `peekLast` function returns the last element in an array-like data structure, or undefined if the structure is empty.
|
|
118
|
-
* @returns The method `peekLast()` returns the last element of the `
|
|
118
|
+
* @returns The method `peekLast()` returns the last element of the `_elements` array if the array is not empty. If the
|
|
119
119
|
* array is empty, it returns `undefined`.
|
|
120
120
|
*/
|
|
121
121
|
peekLast(): E | undefined;
|
|
@@ -174,12 +174,12 @@ export declare class Queue<E = any> extends IterableElementBase<E> {
|
|
|
174
174
|
* Time Complexity: O(1) - constant time as it returns a shallow copy of the internal array.
|
|
175
175
|
* Space Complexity: O(n) - where n is the number of elements in the queue.
|
|
176
176
|
*
|
|
177
|
-
* The toArray() function returns an array of elements from the current offset to the end of the
|
|
177
|
+
* The toArray() function returns an array of elements from the current offset to the end of the _elements array.
|
|
178
178
|
* @returns An array of type E is being returned.
|
|
179
179
|
*/
|
|
180
180
|
toArray(): E[];
|
|
181
181
|
/**
|
|
182
|
-
* The clear function resets the
|
|
182
|
+
* The clear function resets the elements array and offset to their initial values.
|
|
183
183
|
*/
|
|
184
184
|
clear(): void;
|
|
185
185
|
/**
|
|
@@ -9,23 +9,27 @@ const linked_list_1 = require("../linked-list");
|
|
|
9
9
|
* 3. Uses: Queues are commonly used to manage a series of tasks or elements that need to be processed in order. For example, managing task queues in a multi-threaded environment, or in algorithms for data structures like trees and graphs for breadth-first search.
|
|
10
10
|
* 4. Task Scheduling: Managing the order of task execution in operating systems or applications.
|
|
11
11
|
* 5. Data Buffering: Acting as a buffer for data packets in network communication.
|
|
12
|
-
* 6. Breadth-First Search (BFS): In traversal algorithms for graphs and trees, queues store
|
|
12
|
+
* 6. Breadth-First Search (BFS): In traversal algorithms for graphs and trees, queues store elements that are to be visited.
|
|
13
13
|
* 7. Real-time Queuing: Like queuing systems in banks or supermarkets.
|
|
14
14
|
*/
|
|
15
15
|
class Queue extends base_1.IterableElementBase {
|
|
16
16
|
/**
|
|
17
17
|
* The constructor initializes an instance of a class with an optional array of elements and sets the offset to 0.
|
|
18
18
|
* @param {E[]} [elements] - The `elements` parameter is an optional array of elements of type `E`. If provided, it
|
|
19
|
-
* will be used to initialize the `
|
|
19
|
+
* will be used to initialize the `_elements` property of the class. If not provided, the `_elements` property will be
|
|
20
20
|
* initialized as an empty array.
|
|
21
21
|
*/
|
|
22
|
-
constructor(elements) {
|
|
22
|
+
constructor(elements = []) {
|
|
23
23
|
super();
|
|
24
|
-
this.
|
|
24
|
+
this._elements = [];
|
|
25
25
|
this._offset = 0;
|
|
26
|
+
if (elements) {
|
|
27
|
+
for (const el of elements)
|
|
28
|
+
this.push(el);
|
|
29
|
+
}
|
|
26
30
|
}
|
|
27
|
-
get
|
|
28
|
-
return this.
|
|
31
|
+
get elements() {
|
|
32
|
+
return this._elements;
|
|
29
33
|
}
|
|
30
34
|
get offset() {
|
|
31
35
|
return this._offset;
|
|
@@ -35,18 +39,18 @@ class Queue extends base_1.IterableElementBase {
|
|
|
35
39
|
* @returns {number} The size of the array, which is the difference between the length of the array and the offset.
|
|
36
40
|
*/
|
|
37
41
|
get size() {
|
|
38
|
-
return this.
|
|
42
|
+
return this.elements.length - this.offset;
|
|
39
43
|
}
|
|
40
44
|
/**
|
|
41
45
|
* Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
|
|
42
46
|
* Space Complexity: O(1) - no additional space is used.
|
|
43
47
|
*
|
|
44
|
-
* The `first` function returns the first element of the array `
|
|
45
|
-
* @returns The `get first()` method returns the first element of the data structure, represented by the `
|
|
48
|
+
* The `first` function returns the first element of the array `_elements` if it exists, otherwise it returns `undefined`.
|
|
49
|
+
* @returns The `get first()` method returns the first element of the data structure, represented by the `_elements` array at
|
|
46
50
|
* the `_offset` index. If the data structure is empty (size is 0), it returns `undefined`.
|
|
47
51
|
*/
|
|
48
52
|
get first() {
|
|
49
|
-
return this.size > 0 ? this.
|
|
53
|
+
return this.size > 0 ? this.elements[this.offset] : undefined;
|
|
50
54
|
}
|
|
51
55
|
/**
|
|
52
56
|
* Time Complexity: O(1) - constant time as it adds an element to the end of the array.
|
|
@@ -57,11 +61,11 @@ class Queue extends base_1.IterableElementBase {
|
|
|
57
61
|
* Space Complexity: O(1) - no additional space is used.
|
|
58
62
|
*
|
|
59
63
|
* The `last` function returns the last element in an array-like data structure, or undefined if the structure is empty.
|
|
60
|
-
* @returns The method `get last()` returns the last element of the `
|
|
64
|
+
* @returns The method `get last()` returns the last element of the `_elements` array if the array is not empty. If the
|
|
61
65
|
* array is empty, it returns `undefined`.
|
|
62
66
|
*/
|
|
63
67
|
get last() {
|
|
64
|
-
return this.size > 0 ? this.
|
|
68
|
+
return this.size > 0 ? this.elements[this.elements.length - 1] : undefined;
|
|
65
69
|
}
|
|
66
70
|
/**
|
|
67
71
|
* Time Complexity: O(n) - where n is the number of elements in the queue. In the worst case, it may need to shift all elements to update the offset.
|
|
@@ -91,7 +95,7 @@ class Queue extends base_1.IterableElementBase {
|
|
|
91
95
|
* @returns The `add` method is returning a `Queue<E>` object.
|
|
92
96
|
*/
|
|
93
97
|
push(element) {
|
|
94
|
-
this.
|
|
98
|
+
this.elements.push(element);
|
|
95
99
|
return true;
|
|
96
100
|
}
|
|
97
101
|
/**
|
|
@@ -111,11 +115,11 @@ class Queue extends base_1.IterableElementBase {
|
|
|
111
115
|
return undefined;
|
|
112
116
|
const first = this.first;
|
|
113
117
|
this._offset += 1;
|
|
114
|
-
if (this.offset * 2 < this.
|
|
118
|
+
if (this.offset * 2 < this.elements.length)
|
|
115
119
|
return first;
|
|
116
120
|
// only delete dequeued elements when reaching half size
|
|
117
121
|
// to decrease latency of shifting elements.
|
|
118
|
-
this.
|
|
122
|
+
this._elements = this.elements.slice(this.offset);
|
|
119
123
|
this._offset = 0;
|
|
120
124
|
return first;
|
|
121
125
|
}
|
|
@@ -127,8 +131,8 @@ class Queue extends base_1.IterableElementBase {
|
|
|
127
131
|
* Time Complexity: O(1) - constant time as it retrieves the value at the current offset.
|
|
128
132
|
* Space Complexity: O(1) - no additional space is used.
|
|
129
133
|
*
|
|
130
|
-
* The `peek` function returns the first element of the array `
|
|
131
|
-
* @returns The `peek()` method returns the first element of the data structure, represented by the `
|
|
134
|
+
* The `peek` function returns the first element of the array `_elements` if it exists, otherwise it returns `undefined`.
|
|
135
|
+
* @returns The `peek()` method returns the first element of the data structure, represented by the `_elements` array at
|
|
132
136
|
* the `_offset` index. If the data structure is empty (size is 0), it returns `undefined`.
|
|
133
137
|
*/
|
|
134
138
|
peek() {
|
|
@@ -143,7 +147,7 @@ class Queue extends base_1.IterableElementBase {
|
|
|
143
147
|
* Space Complexity: O(1) - no additional space is used.
|
|
144
148
|
*
|
|
145
149
|
* The `peekLast` function returns the last element in an array-like data structure, or undefined if the structure is empty.
|
|
146
|
-
* @returns The method `peekLast()` returns the last element of the `
|
|
150
|
+
* @returns The method `peekLast()` returns the last element of the `_elements` array if the array is not empty. If the
|
|
147
151
|
* array is empty, it returns `undefined`.
|
|
148
152
|
*/
|
|
149
153
|
peekLast() {
|
|
@@ -188,7 +192,7 @@ class Queue extends base_1.IterableElementBase {
|
|
|
188
192
|
* @param index
|
|
189
193
|
*/
|
|
190
194
|
getAt(index) {
|
|
191
|
-
return this.
|
|
195
|
+
return this.elements[index];
|
|
192
196
|
}
|
|
193
197
|
/**
|
|
194
198
|
* Time Complexity: O(1) - constant time as it retrieves the value at the specified index.
|
|
@@ -212,17 +216,17 @@ class Queue extends base_1.IterableElementBase {
|
|
|
212
216
|
* Time Complexity: O(1) - constant time as it returns a shallow copy of the internal array.
|
|
213
217
|
* Space Complexity: O(n) - where n is the number of elements in the queue.
|
|
214
218
|
*
|
|
215
|
-
* The toArray() function returns an array of elements from the current offset to the end of the
|
|
219
|
+
* The toArray() function returns an array of elements from the current offset to the end of the _elements array.
|
|
216
220
|
* @returns An array of type E is being returned.
|
|
217
221
|
*/
|
|
218
222
|
toArray() {
|
|
219
|
-
return this.
|
|
223
|
+
return this.elements.slice(this.offset);
|
|
220
224
|
}
|
|
221
225
|
/**
|
|
222
|
-
* The clear function resets the
|
|
226
|
+
* The clear function resets the elements array and offset to their initial values.
|
|
223
227
|
*/
|
|
224
228
|
clear() {
|
|
225
|
-
this.
|
|
229
|
+
this._elements = [];
|
|
226
230
|
this._offset = 0;
|
|
227
231
|
}
|
|
228
232
|
/**
|
|
@@ -237,7 +241,7 @@ class Queue extends base_1.IterableElementBase {
|
|
|
237
241
|
* @returns The `clone()` method is returning a new instance of the `Queue` class.
|
|
238
242
|
*/
|
|
239
243
|
clone() {
|
|
240
|
-
return new Queue(this.
|
|
244
|
+
return new Queue(this.elements.slice(this.offset));
|
|
241
245
|
}
|
|
242
246
|
/**
|
|
243
247
|
* Time Complexity: O(n)
|
|
@@ -302,7 +306,7 @@ class Queue extends base_1.IterableElementBase {
|
|
|
302
306
|
* Space Complexity: O(n)
|
|
303
307
|
*/
|
|
304
308
|
*_getIterator() {
|
|
305
|
-
for (const item of this.
|
|
309
|
+
for (const item of this.elements) {
|
|
306
310
|
yield item;
|
|
307
311
|
}
|
|
308
312
|
}
|
|
@@ -17,13 +17,12 @@ class Stack extends base_1.IterableElementBase {
|
|
|
17
17
|
* of elements of type `E`. It is used to initialize the `_elements` property of the class. If the `elements` parameter
|
|
18
18
|
* is provided and is an array, it is assigned to the `_elements
|
|
19
19
|
*/
|
|
20
|
-
constructor(elements) {
|
|
20
|
+
constructor(elements = []) {
|
|
21
21
|
super();
|
|
22
22
|
this._elements = [];
|
|
23
23
|
if (elements) {
|
|
24
|
-
for (const el of elements)
|
|
24
|
+
for (const el of elements)
|
|
25
25
|
this.push(el);
|
|
26
|
-
}
|
|
27
26
|
}
|
|
28
27
|
}
|
|
29
28
|
get elements() {
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
|
|
6
6
|
* @license MIT License
|
|
7
7
|
*/
|
|
8
|
-
import type { ElementCallback } from '../../types';
|
|
8
|
+
import type { ElementCallback, TrieOptions } from '../../types';
|
|
9
9
|
import { IterableElementBase } from '../base';
|
|
10
10
|
/**
|
|
11
11
|
* TrieNode represents a node in the Trie data structure. It holds a character key, a map of children nodes,
|
|
@@ -31,7 +31,7 @@ export declare class TrieNode {
|
|
|
31
31
|
* 11. Text Word Frequency Count: Counting and storing the frequency of words in a large amount of text data."
|
|
32
32
|
*/
|
|
33
33
|
export declare class Trie extends IterableElementBase<string> {
|
|
34
|
-
constructor(words?: string
|
|
34
|
+
constructor(words?: Iterable<string>, options?: TrieOptions);
|
|
35
35
|
protected _size: number;
|
|
36
36
|
get size(): number;
|
|
37
37
|
protected _caseSensitive: boolean;
|
|
@@ -28,15 +28,19 @@ exports.TrieNode = TrieNode;
|
|
|
28
28
|
* 11. Text Word Frequency Count: Counting and storing the frequency of words in a large amount of text data."
|
|
29
29
|
*/
|
|
30
30
|
class Trie extends base_1.IterableElementBase {
|
|
31
|
-
constructor(words
|
|
31
|
+
constructor(words = [], options) {
|
|
32
32
|
super();
|
|
33
|
-
this._root = new TrieNode('');
|
|
34
|
-
this._caseSensitive = caseSensitive;
|
|
35
33
|
this._size = 0;
|
|
34
|
+
this._caseSensitive = true;
|
|
35
|
+
this._root = new TrieNode('');
|
|
36
|
+
if (options) {
|
|
37
|
+
const { caseSensitive } = options;
|
|
38
|
+
if (caseSensitive !== undefined)
|
|
39
|
+
this._caseSensitive = caseSensitive;
|
|
40
|
+
}
|
|
36
41
|
if (words) {
|
|
37
|
-
for (const word of words)
|
|
42
|
+
for (const word of words)
|
|
38
43
|
this.add(word);
|
|
39
|
-
}
|
|
40
44
|
}
|
|
41
45
|
}
|
|
42
46
|
get size() {
|
|
@@ -3,6 +3,6 @@ import { IterationType } from "../../common";
|
|
|
3
3
|
export type BinaryTreeNodeNested<K, V> = BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, BinaryTreeNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
|
|
4
4
|
export type BinaryTreeNested<K, V, N extends BinaryTreeNode<K, V, N>> = BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, BinaryTree<K, V, N, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
|
|
5
5
|
export type BinaryTreeOptions<K> = {
|
|
6
|
-
iterationType
|
|
7
|
-
extractor
|
|
6
|
+
iterationType?: IterationType;
|
|
7
|
+
extractor?: (key: K) => number;
|
|
8
8
|
};
|
|
@@ -4,5 +4,5 @@ import { BSTVariant } from "../../common";
|
|
|
4
4
|
export type BSTNodeNested<K, V> = BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, BSTNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
|
|
5
5
|
export type BSTNested<K, V, N extends BSTNode<K, V, N>> = BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, BST<K, V, N, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
|
|
6
6
|
export type BSTOptions<K> = BinaryTreeOptions<K> & {
|
|
7
|
-
variant
|
|
7
|
+
variant?: BSTVariant;
|
|
8
8
|
};
|
|
@@ -6,4 +6,4 @@ export declare enum RBTNColor {
|
|
|
6
6
|
}
|
|
7
7
|
export type RedBlackTreeNodeNested<K, V> = RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, RedBlackTreeNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
|
|
8
8
|
export type RedBlackTreeNested<K, V, N extends RedBlackTreeNode<K, V, N>> = RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, RedBlackTree<K, V, N, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
|
|
9
|
-
export type RBTreeOptions<K> = BSTOptions<K> & {};
|
|
9
|
+
export type RBTreeOptions<K> = Omit<BSTOptions<K>, 'variant'> & {};
|
|
@@ -2,4 +2,4 @@ import { TreeMultimap, TreeMultimapNode } from '../../../data-structures';
|
|
|
2
2
|
import type { AVLTreeOptions } from './avl-tree';
|
|
3
3
|
export type TreeMultimapNodeNested<K, V> = TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, TreeMultimapNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
|
|
4
4
|
export type TreeMultimapNested<K, V, N extends TreeMultimapNode<K, V, N>> = TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, TreeMultimap<K, V, N, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
|
|
5
|
-
export type TreeMultimapOptions<K> =
|
|
5
|
+
export type TreeMultimapOptions<K> = AVLTreeOptions<K> & {};
|
|
@@ -4,9 +4,12 @@ export type HashMapLinkedNode<K, V> = {
|
|
|
4
4
|
next: HashMapLinkedNode<K, V>;
|
|
5
5
|
prev: HashMapLinkedNode<K, V>;
|
|
6
6
|
};
|
|
7
|
+
export type LinkedHashMapOptions<K> = {
|
|
8
|
+
hashFn?: (key: K) => string;
|
|
9
|
+
objHashFn?: (key: K) => object;
|
|
10
|
+
};
|
|
7
11
|
export type HashMapOptions<K> = {
|
|
8
|
-
hashFn
|
|
9
|
-
objHashFn: (key: K) => object;
|
|
12
|
+
hashFn?: (key: K) => string;
|
|
10
13
|
};
|
|
11
14
|
export type HashMapStoreItem<K, V> = {
|
|
12
15
|
key: K;
|