directed-graph-typed 1.48.0 → 1.49.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/dist/data-structures/base/index.d.ts +1 -0
  2. package/dist/data-structures/base/index.js +17 -0
  3. package/dist/data-structures/base/iterable-base.d.ts +232 -0
  4. package/dist/data-structures/base/iterable-base.js +312 -0
  5. package/dist/data-structures/binary-tree/avl-tree.d.ts +28 -19
  6. package/dist/data-structures/binary-tree/avl-tree.js +22 -11
  7. package/dist/data-structures/binary-tree/binary-tree.d.ts +158 -152
  8. package/dist/data-structures/binary-tree/binary-tree.js +241 -215
  9. package/dist/data-structures/binary-tree/bst.d.ts +64 -48
  10. package/dist/data-structures/binary-tree/bst.js +94 -65
  11. package/dist/data-structures/binary-tree/rb-tree.d.ts +39 -39
  12. package/dist/data-structures/binary-tree/rb-tree.js +42 -49
  13. package/dist/data-structures/binary-tree/tree-multimap.d.ts +60 -34
  14. package/dist/data-structures/binary-tree/tree-multimap.js +59 -27
  15. package/dist/data-structures/graph/abstract-graph.d.ts +92 -53
  16. package/dist/data-structures/graph/abstract-graph.js +130 -103
  17. package/dist/data-structures/graph/directed-graph.d.ts +70 -52
  18. package/dist/data-structures/graph/directed-graph.js +111 -65
  19. package/dist/data-structures/graph/map-graph.d.ts +5 -5
  20. package/dist/data-structures/graph/map-graph.js +8 -8
  21. package/dist/data-structures/graph/undirected-graph.d.ts +51 -32
  22. package/dist/data-structures/graph/undirected-graph.js +117 -54
  23. package/dist/data-structures/hash/hash-map.d.ts +160 -44
  24. package/dist/data-structures/hash/hash-map.js +314 -82
  25. package/dist/data-structures/heap/heap.d.ts +50 -7
  26. package/dist/data-structures/heap/heap.js +60 -30
  27. package/dist/data-structures/index.d.ts +1 -0
  28. package/dist/data-structures/index.js +1 -0
  29. package/dist/data-structures/linked-list/doubly-linked-list.d.ts +42 -55
  30. package/dist/data-structures/linked-list/doubly-linked-list.js +50 -77
  31. package/dist/data-structures/linked-list/singly-linked-list.d.ts +36 -55
  32. package/dist/data-structures/linked-list/singly-linked-list.js +44 -77
  33. package/dist/data-structures/queue/deque.d.ts +35 -167
  34. package/dist/data-structures/queue/deque.js +43 -249
  35. package/dist/data-structures/queue/queue.d.ts +49 -48
  36. package/dist/data-structures/queue/queue.js +69 -82
  37. package/dist/data-structures/stack/stack.d.ts +43 -10
  38. package/dist/data-structures/stack/stack.js +50 -31
  39. package/dist/data-structures/trie/trie.d.ts +41 -6
  40. package/dist/data-structures/trie/trie.js +53 -32
  41. package/dist/interfaces/binary-tree.d.ts +6 -6
  42. package/dist/types/common.d.ts +11 -8
  43. package/dist/types/common.js +6 -1
  44. package/dist/types/data-structures/base/base.d.ts +5 -0
  45. package/dist/types/data-structures/base/base.js +2 -0
  46. package/dist/types/data-structures/base/index.d.ts +1 -0
  47. package/dist/types/data-structures/base/index.js +17 -0
  48. package/dist/types/data-structures/binary-tree/avl-tree.d.ts +3 -3
  49. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +4 -4
  50. package/dist/types/data-structures/binary-tree/bst.d.ts +6 -6
  51. package/dist/types/data-structures/binary-tree/rb-tree.d.ts +3 -3
  52. package/dist/types/data-structures/binary-tree/tree-multimap.d.ts +3 -3
  53. package/dist/types/data-structures/hash/hash-map.d.ts +4 -0
  54. package/dist/types/data-structures/index.d.ts +1 -0
  55. package/dist/types/data-structures/index.js +1 -0
  56. package/package.json +2 -2
  57. package/src/data-structures/base/index.ts +1 -0
  58. package/src/data-structures/base/iterable-base.ts +329 -0
  59. package/src/data-structures/binary-tree/avl-tree.ts +37 -25
  60. package/src/data-structures/binary-tree/binary-tree.ts +336 -296
  61. package/src/data-structures/binary-tree/bst.ts +135 -89
  62. package/src/data-structures/binary-tree/rb-tree.ts +60 -69
  63. package/src/data-structures/binary-tree/tree-multimap.ts +86 -49
  64. package/src/data-structures/graph/abstract-graph.ts +136 -104
  65. package/src/data-structures/graph/directed-graph.ts +114 -65
  66. package/src/data-structures/graph/map-graph.ts +8 -8
  67. package/src/data-structures/graph/undirected-graph.ts +124 -56
  68. package/src/data-structures/hash/hash-map.ts +335 -84
  69. package/src/data-structures/heap/heap.ts +63 -36
  70. package/src/data-structures/index.ts +1 -0
  71. package/src/data-structures/linked-list/doubly-linked-list.ts +54 -83
  72. package/src/data-structures/linked-list/singly-linked-list.ts +49 -84
  73. package/src/data-structures/queue/deque.ts +43 -275
  74. package/src/data-structures/queue/queue.ts +71 -86
  75. package/src/data-structures/stack/stack.ts +53 -34
  76. package/src/data-structures/trie/trie.ts +58 -35
  77. package/src/interfaces/binary-tree.ts +5 -6
  78. package/src/types/common.ts +11 -8
  79. package/src/types/data-structures/base/base.ts +6 -0
  80. package/src/types/data-structures/base/index.ts +1 -0
  81. package/src/types/data-structures/binary-tree/avl-tree.ts +3 -3
  82. package/src/types/data-structures/binary-tree/binary-tree.ts +6 -5
  83. package/src/types/data-structures/binary-tree/bst.ts +6 -6
  84. package/src/types/data-structures/binary-tree/rb-tree.ts +3 -3
  85. package/src/types/data-structures/binary-tree/tree-multimap.ts +3 -3
  86. package/src/types/data-structures/hash/hash-map.ts +2 -0
  87. package/src/types/data-structures/heap/heap.ts +1 -1
  88. package/src/types/data-structures/index.ts +1 -0
  89. package/src/types/data-structures/priority-queue/priority-queue.ts +1 -1
@@ -0,0 +1 @@
1
+ export * from './base';
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./base"), exports);
@@ -1,5 +1,5 @@
1
1
  import { AVLTree, AVLTreeNode } from '../../../data-structures';
2
2
  import { BSTOptions } from './bst';
3
- export type AVLTreeNodeNested<T> = AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
4
- export type AVLTreeNested<T, N extends AVLTreeNode<T, N>> = AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, AVLTree<T, N, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
5
- export type AVLTreeOptions = BSTOptions & {};
3
+ export type AVLTreeNodeNested<K, V> = AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, AVLTreeNode<K, V, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
4
+ export type AVLTreeNested<K, V, N extends AVLTreeNode<K, V, N>> = AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, AVLTree<K, V, N, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
5
+ export type AVLTreeOptions<K> = BSTOptions<K> & {};
@@ -18,14 +18,14 @@ export declare enum FamilyPosition {
18
18
  ISOLATED = "ISOLATED",
19
19
  MAL_NODE = "MAL_NODE"
20
20
  }
21
- export type BTNKey = number;
22
21
  export type BiTreeDeleteResult<N> = {
23
22
  deleted: N | null | undefined;
24
23
  needBalanced: N | null | undefined;
25
24
  };
26
- export type BinaryTreeNodeNested<T> = BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, BinaryTreeNode<T, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
27
- export type BinaryTreeNested<T, N extends BinaryTreeNode<T, N>> = BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, BinaryTree<T, N, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
28
- export type BinaryTreeOptions = {
25
+ 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>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
26
+ 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>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
27
+ export type BinaryTreeOptions<K> = {
29
28
  iterationType: IterationType;
29
+ extractor: (key: K) => number;
30
30
  };
31
31
  export type NodeDisplayLayout = [string[], number, number, number];
@@ -1,8 +1,8 @@
1
1
  import { BST, BSTNode } from '../../../data-structures';
2
- import type { BinaryTreeOptions, BTNKey } from './binary-tree';
3
- import { Comparator } from "../../common";
4
- export type BSTNodeNested<T> = BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, BSTNode<T, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
5
- export type BSTNested<T, N extends BSTNode<T, N>> = BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, BST<T, N, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
6
- export type BSTOptions = BinaryTreeOptions & {
7
- comparator: Comparator<BTNKey>;
2
+ import type { BinaryTreeOptions } from './binary-tree';
3
+ import { BSTVariant } from "../../common";
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
+ 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
+ export type BSTOptions<K> = BinaryTreeOptions<K> & {
7
+ variant: BSTVariant;
8
8
  };
@@ -4,6 +4,6 @@ export declare enum RBTNColor {
4
4
  RED = 1,
5
5
  BLACK = 0
6
6
  }
7
- export type RedBlackTreeNodeNested<T> = RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, RedBlackTreeNode<T, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
8
- export type RedBlackTreeNested<T, N extends RedBlackTreeNode<T, N>> = RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, RedBlackTree<T, N, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
9
- export type RBTreeOptions = BSTOptions & {};
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
+ 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> & {};
@@ -1,5 +1,5 @@
1
1
  import { TreeMultimap, TreeMultimapNode } from '../../../data-structures';
2
2
  import { AVLTreeOptions } from './avl-tree';
3
- export type TreeMultimapNodeNested<T> = TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
4
- export type TreeMultimapNested<T, N extends TreeMultimapNode<T, N>> = TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, TreeMultimap<T, N, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
5
- export type TreeMultimapOptions = Omit<AVLTreeOptions, 'isMergeDuplicatedNodeByKey'> & {};
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
+ 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> = Omit<AVLTreeOptions<K>, 'isMergeDuplicatedNodeByKey'> & {};
@@ -8,3 +8,7 @@ export type HashMapOptions<K> = {
8
8
  hashFn: (key: K) => string;
9
9
  objHashFn: (key: K) => object;
10
10
  };
11
+ export type HashMapStoreItem<K, V> = {
12
+ key: K;
13
+ value: V;
14
+ };
@@ -9,3 +9,4 @@ export * from './queue';
9
9
  export * from './stack';
10
10
  export * from './tree';
11
11
  export * from './trie';
12
+ export * from './base';
@@ -25,3 +25,4 @@ __exportStar(require("./queue"), exports);
25
25
  __exportStar(require("./stack"), exports);
26
26
  __exportStar(require("./tree"), exports);
27
27
  __exportStar(require("./trie"), exports);
28
+ __exportStar(require("./base"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "directed-graph-typed",
3
- "version": "1.48.0",
3
+ "version": "1.49.0",
4
4
  "description": "Directed Graph. Javascript & Typescript Data Structure.",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -147,6 +147,6 @@
147
147
  "typescript": "^4.9.5"
148
148
  },
149
149
  "dependencies": {
150
- "data-structure-typed": "^1.48.0"
150
+ "data-structure-typed": "^1.48.9"
151
151
  }
152
152
  }
@@ -0,0 +1 @@
1
+ export * from './iterable-base';
@@ -0,0 +1,329 @@
1
+ import { ElementCallback, EntryCallback, ReduceElementCallback, ReduceEntryCallback } from "../../types";
2
+
3
+ export abstract class IterableEntryBase<K = any, V = any> {
4
+
5
+ /**
6
+ * Time Complexity: O(n)
7
+ * Space Complexity: O(1)
8
+ */
9
+
10
+ /**
11
+ * Time Complexity: O(n)
12
+ * Space Complexity: O(1)
13
+ *
14
+ * The function is an implementation of the Symbol.iterator method that returns an iterable iterator.
15
+ * @param {any[]} args - The `args` parameter in the code snippet represents a rest parameter. It
16
+ * allows the function to accept any number of arguments as an array. In this case, the `args`
17
+ * parameter is used to pass any additional arguments to the `_getIterator` method.
18
+ */
19
+ * [Symbol.iterator](...args: any[]): IterableIterator<[K, V]> {
20
+ yield* this._getIterator(...args);
21
+ }
22
+
23
+ /**
24
+ * Time Complexity: O(n)
25
+ * Space Complexity: O(n)
26
+ */
27
+ /**
28
+ * Time Complexity: O(n)
29
+ * Space Complexity: O(n)
30
+ *
31
+ * The function returns an iterator that yields key-value pairs from the object, where the value can
32
+ * be undefined.
33
+ */
34
+ * entries(): IterableIterator<[K, V | undefined]> {
35
+ for (const item of this) {
36
+ yield item;
37
+ }
38
+ }
39
+
40
+ /**
41
+ * Time Complexity: O(n)
42
+ * Space Complexity: O(n)
43
+ */
44
+ /**
45
+ * Time Complexity: O(n)
46
+ * Space Complexity: O(n)
47
+ *
48
+ * The function returns an iterator that yields the keys of a data structure.
49
+ */
50
+ * keys(): IterableIterator<K> {
51
+ for (const item of this) {
52
+ yield item[0];
53
+ }
54
+ }
55
+
56
+ /**
57
+ * Time Complexity: O(n)
58
+ * Space Complexity: O(n)
59
+ */
60
+ /**
61
+ * Time Complexity: O(n)
62
+ * Space Complexity: O(n)
63
+ *
64
+ * The function returns an iterator that yields the values of a collection.
65
+ */
66
+ * values(): IterableIterator<V> {
67
+ for (const item of this) {
68
+ yield item[1];
69
+ }
70
+ }
71
+
72
+ /**
73
+ * Time Complexity: O(n)
74
+ * Space Complexity: O(1)
75
+ */
76
+ /**
77
+ * Time Complexity: O(n)
78
+ * Space Complexity: O(1)
79
+ *
80
+ * The `every` function checks if every element in a collection satisfies a given condition.
81
+ * @param predicate - The `predicate` parameter is a callback function that takes three arguments:
82
+ * `value`, `key`, and `index`. It should return a boolean value indicating whether the condition is
83
+ * met for the current element in the iteration.
84
+ * @param {any} [thisArg] - The `thisArg` parameter is an optional argument that specifies the value
85
+ * to be used as `this` when executing the `predicate` function. If `thisArg` is provided, it will be
86
+ * passed as the first argument to the `predicate` function. If `thisArg` is not provided
87
+ * @returns The `every` method is returning a boolean value. It returns `true` if every element in
88
+ * the collection satisfies the provided predicate function, and `false` otherwise.
89
+ */
90
+ every(predicate: EntryCallback<K, V, boolean>, thisArg?: any): boolean {
91
+ let index = 0;
92
+ for (const item of this) {
93
+ if (!predicate.call(thisArg, item[1], item[0], index++, this)) {
94
+ return false;
95
+ }
96
+ }
97
+ return true;
98
+ }
99
+
100
+ /**
101
+ * Time Complexity: O(n)
102
+ * Space Complexity: O(1)
103
+ */
104
+ /**
105
+ * Time Complexity: O(n)
106
+ * Space Complexity: O(1)
107
+ *
108
+ * The "some" function iterates over a collection and returns true if at least one element satisfies
109
+ * a given predicate.
110
+ * @param predicate - The `predicate` parameter is a callback function that takes three arguments:
111
+ * `value`, `key`, and `index`. It should return a boolean value indicating whether the condition is
112
+ * met for the current element in the iteration.
113
+ * @param {any} [thisArg] - The `thisArg` parameter is an optional argument that specifies the value
114
+ * to be used as the `this` value when executing the `predicate` function. If `thisArg` is provided,
115
+ * it will be passed as the first argument to the `predicate` function. If `thisArg` is
116
+ * @returns a boolean value. It returns true if the predicate function returns true for any pair in
117
+ * the collection, and false otherwise.
118
+ */
119
+ some(predicate: EntryCallback<K, V, boolean>, thisArg?: any): boolean {
120
+ let index = 0;
121
+ for (const item of this) {
122
+ if (predicate.call(thisArg, item[1], item[0], index++, this)) {
123
+ return true;
124
+ }
125
+ }
126
+ return false;
127
+ }
128
+
129
+ /**
130
+ * Time Complexity: O(n)
131
+ * Space Complexity: O(1)
132
+ */
133
+ /**
134
+ * Time Complexity: O(n)
135
+ * Space Complexity: O(1)
136
+ *
137
+ * The `forEach` function iterates over each key-value pair in a collection and executes a callback
138
+ * function for each pair.
139
+ * @param callbackfn - The callback function that will be called for each element in the collection.
140
+ * It takes four parameters: the value of the current element, the key of the current element, the
141
+ * index of the current element, and the collection itself.
142
+ * @param {any} [thisArg] - The `thisArg` parameter is an optional argument that allows you to
143
+ * specify the value of `this` within the callback function. If `thisArg` is provided, it will be
144
+ * used as the `this` value when calling the callback function. If `thisArg` is not provided, `
145
+ */
146
+ forEach(callbackfn: EntryCallback<K, V, void>, thisArg?: any): void {
147
+ let index = 0;
148
+ for (const item of this) {
149
+ const [key, value] = item;
150
+ callbackfn.call(thisArg, value, key, index++, this)
151
+ }
152
+ }
153
+
154
+ /**
155
+ * Time Complexity: O(n)
156
+ * Space Complexity: O(1)
157
+ */
158
+ /**
159
+ * Time Complexity: O(n)
160
+ * Space Complexity: O(1)
161
+ *
162
+ * The `reduce` function iterates over key-value pairs and applies a callback function to each pair,
163
+ * accumulating a single value.
164
+ * @param callbackfn - The callback function that will be called for each element in the collection.
165
+ * It takes four arguments: the current accumulator value, the current value of the element, the key
166
+ * of the element, and the index of the element in the collection. It should return the updated
167
+ * accumulator value.
168
+ * @param {U} initialValue - The `initialValue` parameter is the initial value of the accumulator. It
169
+ * is the value that will be used as the first argument to the `callbackfn` function when reducing
170
+ * the elements of the collection.
171
+ * @returns The `reduce` method is returning the final value of the accumulator after iterating over
172
+ * all the elements in the collection.
173
+ */
174
+ reduce<U>(callbackfn: ReduceEntryCallback<K, V, U>, initialValue: U): U {
175
+ let accumulator = initialValue;
176
+ let index = 0;
177
+ for (const item of this) {
178
+ const [key, value] = item;
179
+ accumulator = callbackfn(accumulator, value, key, index++, this)
180
+ }
181
+ return accumulator;
182
+ }
183
+
184
+ protected abstract _getIterator(...args: any[]): IterableIterator<[K, V]>;
185
+ }
186
+
187
+ export abstract class IterableElementBase<V> {
188
+
189
+ /**
190
+ * Time Complexity: O(n)
191
+ * Space Complexity: O(1)
192
+ */
193
+ /**
194
+ * Time Complexity: O(n)
195
+ * Space Complexity: O(1)
196
+ *
197
+ * The function is an implementation of the Symbol.iterator method that returns an IterableIterator.
198
+ * @param {any[]} args - The `args` parameter in the code snippet represents a rest parameter. It
199
+ * allows the function to accept any number of arguments as an array. In this case, the `args`
200
+ * parameter is used to pass any number of arguments to the `_getIterator` method.
201
+ */
202
+ * [Symbol.iterator](...args: any[]): IterableIterator<V> {
203
+ yield* this._getIterator(...args);
204
+ }
205
+
206
+ /**
207
+ * Time Complexity: O(n)
208
+ * Space Complexity: O(n)
209
+ */
210
+ /**
211
+ * Time Complexity: O(n)
212
+ * Space Complexity: O(n)
213
+ *
214
+ * The function returns an iterator that yields all the values in the object.
215
+ */
216
+ * values(): IterableIterator<V> {
217
+ for (const item of this) {
218
+ yield item;
219
+ }
220
+ }
221
+
222
+ /**
223
+ * Time Complexity: O(n)
224
+ * Space Complexity: O(1)
225
+ */
226
+ /**
227
+ * Time Complexity: O(n)
228
+ * Space Complexity: O(1)
229
+ *
230
+ * The `every` function checks if every element in the array satisfies a given predicate.
231
+ * @param predicate - The `predicate` parameter is a callback function that takes three arguments:
232
+ * the current element being processed, its index, and the array it belongs to. It should return a
233
+ * boolean value indicating whether the element satisfies a certain condition or not.
234
+ * @param {any} [thisArg] - The `thisArg` parameter is an optional argument that specifies the value
235
+ * to be used as `this` when executing the `predicate` function. If `thisArg` is provided, it will be
236
+ * passed as the `this` value to the `predicate` function. If `thisArg` is
237
+ * @returns The `every` method is returning a boolean value. It returns `true` if every element in
238
+ * the array satisfies the provided predicate function, and `false` otherwise.
239
+ */
240
+ every(predicate: ElementCallback<V, boolean>, thisArg?: any): boolean {
241
+ let index = 0;
242
+ for (const item of this) {
243
+ if (!predicate.call(thisArg, item as V, index++, this)) {
244
+ return false;
245
+ }
246
+ }
247
+ return true;
248
+ }
249
+
250
+ /**
251
+ * Time Complexity: O(n)
252
+ * Space Complexity: O(1)
253
+ */
254
+ /**
255
+ * Time Complexity: O(n)
256
+ * Space Complexity: O(1)
257
+ *
258
+ * The "some" function checks if at least one element in a collection satisfies a given predicate.
259
+ * @param predicate - The `predicate` parameter is a callback function that takes three arguments:
260
+ * `value`, `index`, and `array`. It should return a boolean value indicating whether the current
261
+ * element satisfies the condition.
262
+ * @param {any} [thisArg] - The `thisArg` parameter is an optional argument that specifies the value
263
+ * to be used as the `this` value when executing the `predicate` function. If `thisArg` is provided,
264
+ * it will be passed as the `this` value to the `predicate` function. If `thisArg
265
+ * @returns a boolean value. It returns true if the predicate function returns true for any element
266
+ * in the collection, and false otherwise.
267
+ */
268
+ some(predicate: ElementCallback<V, boolean>, thisArg?: any): boolean {
269
+ let index = 0;
270
+ for (const item of this) {
271
+ if (predicate.call(thisArg, item as V, index++, this)) {
272
+ return true;
273
+ }
274
+ }
275
+ return false;
276
+ }
277
+
278
+ /**
279
+ * Time Complexity: O(n)
280
+ * Space Complexity: O(1)
281
+ */
282
+ /**
283
+ * Time Complexity: O(n)
284
+ * Space Complexity: O(1)
285
+ *
286
+ * The `forEach` function iterates over each element in an array-like object and calls a callback
287
+ * function for each element.
288
+ * @param callbackfn - The callbackfn parameter is a function that will be called for each element in
289
+ * the array. It takes three arguments: the current element being processed, the index of the current
290
+ * element, and the array that forEach was called upon.
291
+ * @param {any} [thisArg] - The `thisArg` parameter is an optional argument that specifies the value
292
+ * to be used as `this` when executing the `callbackfn` function. If `thisArg` is provided, it will
293
+ * be passed as the `this` value to the `callbackfn` function. If `thisArg
294
+ */
295
+ forEach(callbackfn: ElementCallback<V, void>, thisArg?: any): void {
296
+ let index = 0;
297
+ for (const item of this) {
298
+ callbackfn.call(thisArg, item as V, index++, this)
299
+ }
300
+ }
301
+
302
+ /**
303
+ * Time Complexity: O(n)
304
+ * Space Complexity: O(1)
305
+ */
306
+ /**
307
+ * Time Complexity: O(n)
308
+ * Space Complexity: O(1)
309
+ *
310
+ * The `reduce` function iterates over the elements of an array-like object and applies a callback
311
+ * function to reduce them into a single value.
312
+ * @param callbackfn - The callbackfn parameter is a function that will be called for each element in
313
+ * the array. It takes four arguments:
314
+ * @param {U} initialValue - The initialValue parameter is the initial value of the accumulator. It
315
+ * is the value that the accumulator starts with before the reduction operation begins.
316
+ * @returns The `reduce` method is returning the final value of the accumulator after iterating over
317
+ * all the elements in the array and applying the callback function to each element.
318
+ */
319
+ reduce<U>(callbackfn: ReduceElementCallback<V, U>, initialValue: U): U {
320
+ let accumulator = initialValue;
321
+ let index = 0;
322
+ for (const item of this) {
323
+ accumulator = callbackfn(accumulator, item as V, index++, this)
324
+ }
325
+ return accumulator;
326
+ }
327
+
328
+ protected abstract _getIterator(...args: any[]): IterableIterator<V>;
329
+ }