tree-multimap-typed 1.51.8 → 1.52.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. package/dist/data-structures/base/index.d.ts +2 -1
  2. package/dist/data-structures/base/index.js +2 -1
  3. package/dist/data-structures/base/iterable-element-base.d.ts +171 -0
  4. package/dist/data-structures/base/iterable-element-base.js +225 -0
  5. package/dist/data-structures/base/{iterable-base.d.ts → iterable-entry-base.d.ts} +4 -147
  6. package/dist/data-structures/base/{iterable-base.js → iterable-entry-base.js} +12 -189
  7. package/dist/data-structures/binary-tree/avl-tree-multi-map.d.ts +106 -68
  8. package/dist/data-structures/binary-tree/avl-tree-multi-map.js +119 -87
  9. package/dist/data-structures/binary-tree/avl-tree.d.ts +82 -62
  10. package/dist/data-structures/binary-tree/avl-tree.js +78 -59
  11. package/dist/data-structures/binary-tree/binary-tree.d.ts +333 -241
  12. package/dist/data-structures/binary-tree/binary-tree.js +478 -366
  13. package/dist/data-structures/binary-tree/bst.d.ts +202 -212
  14. package/dist/data-structures/binary-tree/bst.js +208 -250
  15. package/dist/data-structures/binary-tree/rb-tree.d.ts +73 -74
  16. package/dist/data-structures/binary-tree/rb-tree.js +107 -98
  17. package/dist/data-structures/binary-tree/tree-multi-map.d.ts +92 -75
  18. package/dist/data-structures/binary-tree/tree-multi-map.js +105 -93
  19. package/dist/data-structures/graph/abstract-graph.d.ts +10 -15
  20. package/dist/data-structures/graph/abstract-graph.js +10 -15
  21. package/dist/data-structures/graph/directed-graph.js +2 -1
  22. package/dist/data-structures/hash/hash-map.d.ts +33 -40
  23. package/dist/data-structures/hash/hash-map.js +40 -55
  24. package/dist/data-structures/heap/heap.d.ts +43 -114
  25. package/dist/data-structures/heap/heap.js +59 -127
  26. package/dist/data-structures/heap/max-heap.d.ts +50 -4
  27. package/dist/data-structures/heap/max-heap.js +76 -10
  28. package/dist/data-structures/heap/min-heap.d.ts +51 -5
  29. package/dist/data-structures/heap/min-heap.js +68 -11
  30. package/dist/data-structures/linked-list/doubly-linked-list.d.ts +22 -28
  31. package/dist/data-structures/linked-list/doubly-linked-list.js +26 -28
  32. package/dist/data-structures/linked-list/singly-linked-list.d.ts +22 -25
  33. package/dist/data-structures/linked-list/singly-linked-list.js +29 -26
  34. package/dist/data-structures/priority-queue/max-priority-queue.d.ts +50 -4
  35. package/dist/data-structures/priority-queue/max-priority-queue.js +79 -10
  36. package/dist/data-structures/priority-queue/min-priority-queue.d.ts +51 -5
  37. package/dist/data-structures/priority-queue/min-priority-queue.js +71 -11
  38. package/dist/data-structures/priority-queue/priority-queue.d.ts +50 -4
  39. package/dist/data-structures/priority-queue/priority-queue.js +70 -1
  40. package/dist/data-structures/queue/deque.d.ts +28 -20
  41. package/dist/data-structures/queue/deque.js +45 -24
  42. package/dist/data-structures/queue/queue.d.ts +8 -29
  43. package/dist/data-structures/queue/queue.js +15 -32
  44. package/dist/data-structures/stack/stack.d.ts +17 -22
  45. package/dist/data-structures/stack/stack.js +25 -24
  46. package/dist/data-structures/trie/trie.d.ts +19 -14
  47. package/dist/data-structures/trie/trie.js +27 -16
  48. package/dist/index.d.ts +6 -0
  49. package/dist/index.js +6 -0
  50. package/dist/interfaces/binary-tree.d.ts +7 -7
  51. package/dist/types/common.d.ts +1 -23
  52. package/dist/types/data-structures/base/base.d.ts +5 -2
  53. package/dist/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +3 -4
  54. package/dist/types/data-structures/binary-tree/avl-tree.d.ts +3 -4
  55. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +22 -5
  56. package/dist/types/data-structures/binary-tree/bst.d.ts +7 -5
  57. package/dist/types/data-structures/binary-tree/rb-tree.d.ts +3 -4
  58. package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +3 -4
  59. package/dist/types/data-structures/heap/heap.d.ts +3 -2
  60. package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +2 -1
  61. package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +2 -1
  62. package/dist/types/data-structures/priority-queue/priority-queue.d.ts +1 -1
  63. package/dist/types/data-structures/queue/deque.d.ts +4 -2
  64. package/dist/types/data-structures/queue/queue.d.ts +2 -1
  65. package/dist/types/data-structures/stack/stack.d.ts +2 -1
  66. package/dist/types/data-structures/trie/trie.d.ts +3 -2
  67. package/dist/utils/utils.js +3 -5
  68. package/package.json +2 -2
  69. package/src/data-structures/base/index.ts +2 -1
  70. package/src/data-structures/base/iterable-element-base.ts +250 -0
  71. package/src/data-structures/base/{iterable-base.ts → iterable-entry-base.ts} +22 -213
  72. package/src/data-structures/binary-tree/avl-tree-multi-map.ts +146 -97
  73. package/src/data-structures/binary-tree/avl-tree.ts +97 -70
  74. package/src/data-structures/binary-tree/binary-tree.ts +591 -455
  75. package/src/data-structures/binary-tree/bst.ts +266 -293
  76. package/src/data-structures/binary-tree/rb-tree.ts +124 -104
  77. package/src/data-structures/binary-tree/tree-multi-map.ts +128 -103
  78. package/src/data-structures/graph/abstract-graph.ts +10 -10
  79. package/src/data-structures/graph/directed-graph.ts +2 -1
  80. package/src/data-structures/hash/hash-map.ts +46 -53
  81. package/src/data-structures/heap/heap.ts +71 -152
  82. package/src/data-structures/heap/max-heap.ts +88 -13
  83. package/src/data-structures/heap/min-heap.ts +78 -15
  84. package/src/data-structures/linked-list/doubly-linked-list.ts +32 -32
  85. package/src/data-structures/linked-list/singly-linked-list.ts +37 -29
  86. package/src/data-structures/priority-queue/max-priority-queue.ts +94 -13
  87. package/src/data-structures/priority-queue/min-priority-queue.ts +84 -15
  88. package/src/data-structures/priority-queue/priority-queue.ts +81 -4
  89. package/src/data-structures/queue/deque.ts +52 -27
  90. package/src/data-structures/queue/queue.ts +23 -37
  91. package/src/data-structures/stack/stack.ts +31 -26
  92. package/src/data-structures/trie/trie.ts +35 -20
  93. package/src/index.ts +6 -0
  94. package/src/interfaces/binary-tree.ts +10 -10
  95. package/src/types/common.ts +2 -25
  96. package/src/types/data-structures/base/base.ts +14 -6
  97. package/src/types/data-structures/binary-tree/avl-tree-multi-map.ts +3 -4
  98. package/src/types/data-structures/binary-tree/avl-tree.ts +3 -4
  99. package/src/types/data-structures/binary-tree/binary-tree.ts +26 -6
  100. package/src/types/data-structures/binary-tree/bst.ts +11 -5
  101. package/src/types/data-structures/binary-tree/rb-tree.ts +3 -4
  102. package/src/types/data-structures/binary-tree/tree-multi-map.ts +3 -4
  103. package/src/types/data-structures/heap/heap.ts +4 -1
  104. package/src/types/data-structures/linked-list/doubly-linked-list.ts +3 -1
  105. package/src/types/data-structures/linked-list/singly-linked-list.ts +3 -1
  106. package/src/types/data-structures/priority-queue/priority-queue.ts +1 -1
  107. package/src/types/data-structures/queue/deque.ts +6 -1
  108. package/src/types/data-structures/queue/queue.ts +3 -1
  109. package/src/types/data-structures/stack/stack.ts +3 -1
  110. package/src/types/data-structures/trie/trie.ts +3 -1
  111. package/src/utils/utils.ts +3 -3
@@ -1,9 +1,11 @@
1
1
  import { BST, BSTNode } from '../../../data-structures';
2
2
  import type { BinaryTreeOptions } from './binary-tree';
3
- import { Comparator } from "../../common";
4
- import { Comparable } from "../../utils";
5
- export type BSTNodeNested<K extends Comparable, 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>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
6
- export type BSTNested<K extends Comparable, 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>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
7
- export type BSTOptions<K> = BinaryTreeOptions & {
3
+ import { Comparator } 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, R, NODE extends BSTNode<K, V, NODE>> = BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, BST<K, V, R, NODE, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
6
+ export type BSTOptions<K, V, R> = BinaryTreeOptions<K, V, R> & {
8
7
  comparator?: Comparator<K>;
9
8
  };
9
+ export type OptBSTNKey<K> = K | undefined;
10
+ export type OptBSTN<NODE> = NODE | undefined;
11
+ export type BSTNKeyOrNode<K, NODE> = OptBSTNKey<K> | NODE;
@@ -1,7 +1,6 @@
1
1
  import { RedBlackTree, RedBlackTreeNode } from '../../../data-structures';
2
2
  import type { BSTOptions } from "./bst";
3
- import { Comparable } from "../../utils";
4
3
  export type RBTNColor = 'RED' | 'BLACK';
5
- export type RedBlackTreeNodeNested<K extends Comparable, 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>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
6
- export type RedBlackTreeNested<K extends Comparable, 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>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
7
- export type RBTreeOptions<K> = BSTOptions<K> & {};
4
+ 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>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
5
+ export type RedBlackTreeNested<K, V, R, NODE extends RedBlackTreeNode<K, V, NODE>> = RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, RedBlackTree<K, V, R, NODE, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
6
+ export type RBTreeOptions<K, V, R> = BSTOptions<K, V, R> & {};
@@ -1,6 +1,5 @@
1
1
  import { TreeMultiMap, TreeMultiMapNode } from '../../../data-structures';
2
2
  import type { RBTreeOptions } from './rb-tree';
3
- import { Comparable } from "../../utils";
4
- export type TreeMultiMapNodeNested<K extends Comparable, 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>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
5
- export type TreeMultiMapNested<K extends Comparable, 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>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
6
- export type TreeMultiMapOptions<K> = RBTreeOptions<K> & {};
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, R, NODE extends TreeMultiMapNode<K, V, NODE>> = TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, TreeMultiMap<K, V, R, NODE, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
5
+ export type TreeMultiMapOptions<K, V, R> = RBTreeOptions<K, V, R> & {};
@@ -1,4 +1,5 @@
1
1
  import { Comparator } from '../../common';
2
- export type HeapOptions<T> = {
3
- comparator?: Comparator<T>;
2
+ import { IterableElementBaseOptions } from '../base';
3
+ export type HeapOptions<E, R> = IterableElementBaseOptions<E, R> & {
4
+ comparator?: Comparator<E>;
4
5
  };
@@ -1 +1,2 @@
1
- export {};
1
+ import { IterableElementBaseOptions } from '../base';
2
+ export type DoublyLinkedListOptions<E, R> = IterableElementBaseOptions<E, R> & {};
@@ -1 +1,2 @@
1
- export {};
1
+ import { IterableElementBaseOptions } from '../base';
2
+ export type SinglyLinkedListOptions<E, R> = IterableElementBaseOptions<E, R> & {};
@@ -1,2 +1,2 @@
1
1
  import { HeapOptions } from '../heap';
2
- export type PriorityQueueOptions<T> = HeapOptions<T> & {};
2
+ export type PriorityQueueOptions<E, R> = HeapOptions<E, R> & {};
@@ -1,3 +1,5 @@
1
- export type DequeOptions = {
1
+ import { IterableElementBaseOptions } from '../base';
2
+ export type DequeOptions<E, R> = {
2
3
  bucketSize?: number;
3
- };
4
+ maxLen?: number;
5
+ } & IterableElementBaseOptions<E, R>;
@@ -1 +1,2 @@
1
- export {};
1
+ import { IterableElementBaseOptions } from '../base';
2
+ export type QueueOptions<E, R> = IterableElementBaseOptions<E, R> & {};
@@ -1 +1,2 @@
1
- export {};
1
+ import { IterableElementBaseOptions } from '../base';
2
+ export type StackOptions<E, R> = IterableElementBaseOptions<E, R> & {};
@@ -1,3 +1,4 @@
1
- export type TrieOptions = {
1
+ import { IterableElementBaseOptions } from '../base';
2
+ export type TrieOptions<R> = {
2
3
  caseSensitive?: boolean;
3
- };
4
+ } & IterableElementBaseOptions<string, R>;
@@ -95,7 +95,7 @@ exports.roundFixed = roundFixed;
95
95
  function isComparable(key) {
96
96
  const keyType = typeof key;
97
97
  if (keyType === 'number')
98
- return isNaN(key);
98
+ return !isNaN(key);
99
99
  if (keyType === 'string')
100
100
  return true;
101
101
  if (keyType === 'bigint')
@@ -111,10 +111,8 @@ function isComparable(key) {
111
111
  if (keyType === 'object') {
112
112
  if (key === null)
113
113
  return true;
114
- if (typeof key.valueOf === 'function')
115
- return isComparable(key.valueOf());
116
- if (typeof key.toString === 'function')
117
- return isComparable(key.toString());
114
+ // if (typeof key.valueOf === 'function') return isComparable(key.valueOf()); // This will keep recursing because every object has a valueOf method.
115
+ // if (typeof key.toString === 'function') return isComparable(key.toString()); // This will also keep recursing because every string type has a toString method.
118
116
  return false;
119
117
  }
120
118
  return false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tree-multimap-typed",
3
- "version": "1.51.8",
3
+ "version": "1.52.1",
4
4
  "description": "Tree Multiset, AVLTree, BST, Binary Tree. Javascript & Typescript Data Structure.",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -179,6 +179,6 @@
179
179
  "typescript": "^4.9.5"
180
180
  },
181
181
  "dependencies": {
182
- "data-structure-typed": "^1.51.8"
182
+ "data-structure-typed": "^1.52.1"
183
183
  }
184
184
  }
@@ -1 +1,2 @@
1
- export * from './iterable-base';
1
+ export * from './iterable-entry-base';
2
+ export * from './iterable-element-base';
@@ -0,0 +1,250 @@
1
+ import { ElementCallback, IterableElementBaseOptions, ReduceElementCallback } from '../../types';
2
+
3
+ export abstract class IterableElementBase<E, R, C> {
4
+ /**
5
+ * The protected constructor initializes the options for the IterableElementBase class, including the
6
+ * toElementFn function.
7
+ * @param [options] - An optional object that contains the following properties:
8
+ */
9
+ protected constructor(options?: IterableElementBaseOptions<E, R>) {
10
+ if (options) {
11
+ const { toElementFn } = options;
12
+ if (typeof toElementFn === 'function') this._toElementFn = toElementFn;
13
+ else if (toElementFn) throw new TypeError('toElementFn must be a function type');
14
+ }
15
+ }
16
+
17
+ abstract get size(): number;
18
+
19
+ protected _toElementFn?: (rawElement: R) => E;
20
+
21
+ /**
22
+ * The function returns the _toElementFn property, which is a function that converts a raw element to
23
+ * a specific type.
24
+ * @returns The function `get toElementFn()` is returning either a function that takes a raw element
25
+ * `rawElement` of type `R` and returns an element `E`, or `undefined` if no function is assigned to
26
+ * `_toElementFn`.
27
+ */
28
+ get toElementFn(): ((rawElement: R) => E) | undefined {
29
+ return this._toElementFn;
30
+ }
31
+
32
+ /**
33
+ * Time Complexity: O(n)
34
+ * Space Complexity: O(1)
35
+ */
36
+ /**
37
+ * Time Complexity: O(n)
38
+ * Space Complexity: O(1)
39
+ *
40
+ * The function is an implementation of the Symbol.iterator method that returns an IterableIterator.
41
+ * @param {any[]} args - The `args` parameter in the code snippet represents a rest parameter. It
42
+ * allows the function to accept any number of arguments as an array. In this case, the `args`
43
+ * parameter is used to pass any number of arguments to the `_getIterator` method.
44
+ */
45
+ * [Symbol.iterator](...args: any[]): IterableIterator<E> {
46
+ yield* this._getIterator(...args);
47
+ }
48
+
49
+ /**
50
+ * Time Complexity: O(n)
51
+ * Space Complexity: O(n)
52
+ */
53
+ /**
54
+ * Time Complexity: O(n)
55
+ * Space Complexity: O(n)
56
+ *
57
+ * The function returns an iterator that yields all the values in the object.
58
+ */
59
+ * values(): IterableIterator<E> {
60
+ for (const item of this) {
61
+ yield item;
62
+ }
63
+ }
64
+
65
+ /**
66
+ * Time Complexity: O(n)
67
+ * Space Complexity: O(1)
68
+ */
69
+ /**
70
+ * Time Complexity: O(n)
71
+ * Space Complexity: O(1)
72
+ *
73
+ * The `every` function checks if every element in the array satisfies a given predicate.
74
+ * @param predicate - The `predicate` parameter is a callback function that takes three arguments:
75
+ * the current element being processed, its index, and the array it belongs to. It should return a
76
+ * boolean value indicating whether the element satisfies a certain condition or not.
77
+ * @param {any} [thisArg] - The `thisArg` parameter is an optional argument that specifies the value
78
+ * to be used as `this` when executing the `predicate` function. If `thisArg` is provided, it will be
79
+ * passed as the `this` value to the `predicate` function. If `thisArg` is
80
+ * @returns The `every` method is returning a boolean value. It returns `true` if every element in
81
+ * the array satisfies the provided predicate function, and `false` otherwise.
82
+ */
83
+ every(predicate: ElementCallback<E, R, boolean, C>, thisArg?: any): boolean {
84
+ let index = 0;
85
+ for (const item of this) {
86
+ if (!predicate.call(thisArg, item, index++, this)) {
87
+ return false;
88
+ }
89
+ }
90
+ return true;
91
+ }
92
+
93
+ /**
94
+ * Time Complexity: O(n)
95
+ * Space Complexity: O(1)
96
+ */
97
+
98
+ /**
99
+ * Time Complexity: O(n)
100
+ * Space Complexity: O(1)
101
+ */
102
+ /**
103
+ * Time Complexity: O(n)
104
+ * Space Complexity: O(1)
105
+ *
106
+ * The "some" function checks if at least one element in a collection satisfies a given predicate.
107
+ * @param predicate - The `predicate` parameter is a callback function that takes three arguments:
108
+ * `value`, `index`, and `array`. It should return a boolean value indicating whether the current
109
+ * element satisfies the condition.
110
+ * @param {any} [thisArg] - The `thisArg` parameter is an optional argument that specifies the value
111
+ * to be used as the `this` value when executing the `predicate` function. If `thisArg` is provided,
112
+ * it will be passed as the `this` value to the `predicate` function. If `thisArg
113
+ * @returns a boolean value. It returns true if the predicate function returns true for any element
114
+ * in the collection, and false otherwise.
115
+ */
116
+ some(predicate: ElementCallback<E, R, boolean, C>, thisArg?: any): boolean {
117
+ let index = 0;
118
+ for (const item of this) {
119
+ if (predicate.call(thisArg, item, index++, this)) {
120
+ return true;
121
+ }
122
+ }
123
+ return false;
124
+ }
125
+
126
+ /**
127
+ * Time Complexity: O(n)
128
+ * Space Complexity: O(1)
129
+ */
130
+
131
+ /**
132
+ * Time Complexity: O(n)
133
+ * Space Complexity: O(1)
134
+ *
135
+ * The `forEach` function iterates over each element in an array-like object and calls a callback
136
+ * function for each element.
137
+ * @param callbackfn - The callbackfn parameter is a function that will be called for each element in
138
+ * the array. It takes three arguments: the current element being processed, the index of the current
139
+ * element, and the array that forEach was called upon.
140
+ * @param {any} [thisArg] - The `thisArg` parameter is an optional argument that specifies the value
141
+ * to be used as `this` when executing the `callbackfn` function. If `thisArg` is provided, it will
142
+ * be passed as the `this` value to the `callbackfn` function. If `thisArg
143
+ */
144
+ forEach(callbackfn: ElementCallback<E, R, void, C>, thisArg?: any): void {
145
+ let index = 0;
146
+ for (const item of this) {
147
+ callbackfn.call(thisArg, item, index++, this);
148
+ }
149
+ }
150
+
151
+ /**
152
+ * Time Complexity: O(n)
153
+ * Space Complexity: O(1)
154
+ */
155
+
156
+ /**
157
+ * Time Complexity: O(n)
158
+ * Space Complexity: O(1)
159
+ *
160
+ * The `find` function iterates over the elements of an array-like object and returns the first
161
+ * element that satisfies the provided callback function.
162
+ * @param callbackfn - The callbackfn parameter is a function that will be called for each element in
163
+ * the array. It takes three arguments: the current element being processed, the index of the current
164
+ * element, and the array itself. The function should return a boolean value indicating whether the
165
+ * current element matches the desired condition.
166
+ * @param {any} [thisArg] - The `thisArg` parameter is an optional argument that specifies the value
167
+ * to be used as `this` when executing the `callbackfn` function. If `thisArg` is provided, it will
168
+ * be passed as the `this` value to the `callbackfn` function. If `thisArg
169
+ * @returns The `find` method returns the first element in the array that satisfies the provided
170
+ * callback function. If no element satisfies the callback function, `undefined` is returned.
171
+ */
172
+ find(callbackfn: ElementCallback<E, R, boolean, C>, thisArg?: any): E | undefined {
173
+ let index = 0;
174
+ for (const item of this) {
175
+ if (callbackfn.call(thisArg, item, index++, this)) return item;
176
+ }
177
+
178
+ return;
179
+ }
180
+
181
+ /**
182
+ * Time Complexity: O(n)
183
+ * Space Complexity: O(1)
184
+ *
185
+ * The function checks if a given element exists in a collection.
186
+ * @param {E} element - The parameter "element" is of type E, which means it can be any type. It
187
+ * represents the element that we want to check for existence in the collection.
188
+ * @returns a boolean value. It returns true if the element is found in the collection, and false
189
+ * otherwise.
190
+ */
191
+ has(element: E): boolean {
192
+ for (const ele of this) {
193
+ if (ele === element) return true;
194
+ }
195
+ return false;
196
+ }
197
+
198
+ /**
199
+ * Time Complexity: O(n)
200
+ * Space Complexity: O(1)
201
+ */
202
+ /**
203
+ * Time Complexity: O(n)
204
+ * Space Complexity: O(1)
205
+ *
206
+ * The `reduce` function iterates over the elements of an array-like object and applies a callback
207
+ * function to reduce them into a single value.
208
+ * @param callbackfn - The callbackfn parameter is a function that will be called for each element in
209
+ * the array. It takes four arguments:
210
+ * @param {U} initialValue - The initialValue parameter is the initial value of the accumulator. It
211
+ * is the value that the accumulator starts with before the reduction operation begins.
212
+ * @returns The `reduce` method is returning the final value of the accumulator after iterating over
213
+ * all the elements in the array and applying the callback function to each element.
214
+ */
215
+ reduce<U>(callbackfn: ReduceElementCallback<E, R, U, C>, initialValue: U): U {
216
+ let accumulator = initialValue;
217
+ let index = 0;
218
+ for (const item of this) {
219
+ accumulator = callbackfn(accumulator, item as E, index++, this);
220
+ }
221
+ return accumulator;
222
+ }
223
+
224
+ /**
225
+ * Time Complexity: O(n)
226
+ * Space Complexity: O(n)
227
+ */
228
+
229
+ /**
230
+ * Time Complexity: O(n)
231
+ * Space Complexity: O(n)
232
+ *
233
+ * The print function logs the elements of an array to the console.
234
+ */
235
+ print(): void {
236
+ console.log([...this]);
237
+ }
238
+
239
+ abstract isEmpty(): boolean;
240
+
241
+ abstract clear(): void;
242
+
243
+ abstract clone(): C;
244
+
245
+ abstract map(...args: any[]): any;
246
+
247
+ abstract filter(...args: any[]): any;
248
+
249
+ protected abstract _getIterator(...args: any[]): IterableIterator<E>;
250
+ }