graph-typed 2.2.0 → 2.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/dist/cjs/index.cjs +7 -7
  2. package/dist/cjs/index.cjs.map +1 -1
  3. package/dist/cjs-legacy/index.cjs +7 -7
  4. package/dist/cjs-legacy/index.cjs.map +1 -1
  5. package/dist/esm/index.mjs +7 -7
  6. package/dist/esm/index.mjs.map +1 -1
  7. package/dist/esm-legacy/index.mjs +7 -7
  8. package/dist/esm-legacy/index.mjs.map +1 -1
  9. package/dist/types/data-structures/binary-tree/avl-tree.d.ts +3 -1
  10. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +1 -0
  11. package/dist/types/data-structures/binary-tree/bst.d.ts +1 -0
  12. package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +1 -0
  13. package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +1 -0
  14. package/dist/types/types/data-structures/base/base.d.ts +1 -1
  15. package/dist/umd/graph-typed.js +7 -7
  16. package/dist/umd/graph-typed.js.map +1 -1
  17. package/dist/umd/graph-typed.min.js +1 -1
  18. package/dist/umd/graph-typed.min.js.map +1 -1
  19. package/package.json +2 -2
  20. package/src/data-structures/base/iterable-entry-base.ts +4 -4
  21. package/src/data-structures/binary-tree/avl-tree-counter.ts +1 -1
  22. package/src/data-structures/binary-tree/avl-tree-multi-map.ts +1 -1
  23. package/src/data-structures/binary-tree/avl-tree.ts +4 -2
  24. package/src/data-structures/binary-tree/binary-tree.ts +3 -2
  25. package/src/data-structures/binary-tree/bst.ts +2 -1
  26. package/src/data-structures/binary-tree/red-black-tree.ts +2 -1
  27. package/src/data-structures/binary-tree/tree-counter.ts +1 -1
  28. package/src/data-structures/binary-tree/tree-multi-map.ts +2 -1
  29. package/src/data-structures/graph/abstract-graph.ts +3 -3
  30. package/src/data-structures/hash/hash-map.ts +4 -4
  31. package/src/types/data-structures/base/base.ts +1 -1
@@ -125,7 +125,9 @@ export declare class AVLTreeNode<K = any, V = any> {
125
125
  * 4. Order Preservation: Maintains the binary search tree property where left child values are less than the parent, and right child values are greater.
126
126
  * 5. Efficient Lookups: Offers O(log n) search time, where 'n' is the number of nodes, due to its balanced nature.
127
127
  * 6. Complex Insertions and Deletions: Due to rebalancing, these operations are more complex than in a regular BST.
128
- * 7. Path Length: The path length from the root to any leaf is longer compared to an unbalanced BST, but shorter than a linear chain of nodes.@example
128
+ * 7. Path Length: The path length from the root to any leaf is longer compared to an unbalanced BST, but shorter than a linear chain of nodes.
129
+ *
130
+ * @example
129
131
  * // Find elements in a range
130
132
  * // In interval queries, AVL trees, with their strictly balanced structure and lower height, offer better query efficiency, making them ideal for frequent and high-performance interval queries. In contrast, Red-Black trees, with lower update costs, are more suitable for scenarios involving frequent insertions and deletions where the requirements for interval queries are less demanding.
131
133
  * type Datum = { timestamp: Date; temperature: number };
@@ -123,6 +123,7 @@ export declare class BinaryTreeNode<K = any, V = any> {
123
123
  * 3. Depth and Height: Depth is the number of edges from the root to a node; height is the maximum depth in the tree.
124
124
  * 4. Subtrees: Each child of a node forms the root of a subtree.
125
125
  * 5. Leaf Nodes: Nodes without children are leaves.
126
+ *
126
127
  * @example
127
128
  * // determine loan approval using a decision tree
128
129
  * // Decision tree structure
@@ -124,6 +124,7 @@ export declare class BSTNode<K = any, V = any> {
124
124
  * 5. Logarithmic Operations: Ideal operations like insertion, deletion, and searching are O(log n) time-efficient.
125
125
  * 6. Balance Variability: Can become unbalanced; special types maintain balance.
126
126
  * 7. No Auto-Balancing: Standard BSTs don't automatically balance themselves.
127
+ *
127
128
  * @example
128
129
  * // Merge 3 sorted datasets
129
130
  * const dataset1 = new BST<number, string>([
@@ -110,6 +110,7 @@ export declare class RedBlackTreeNode<K = any, V = any> {
110
110
  * @template R
111
111
  * 1. Efficient self-balancing, but not completely balanced. Compared with AVLTree, the addition and deletion efficiency is high, but the query efficiency is slightly lower.
112
112
  * 2. It is BST itself. Compared with Heap which is not completely ordered, RedBlackTree is completely ordered.
113
+ *
113
114
  * @example
114
115
  * // using Red-Black Tree as a price-based index for stock data
115
116
  * // Define the structure of individual stock records
@@ -113,6 +113,7 @@ export declare class TreeMultiMapNode<K = any, V = any> {
113
113
  * @template K
114
114
  * @template V
115
115
  * @template R
116
+ *
116
117
  * @example
117
118
  * // players ranked by score with their equipment
118
119
  * type Equipment = {
@@ -1,6 +1,6 @@
1
1
  import { IterableElementBase, IterableEntryBase } from '../../../data-structures';
2
2
  import { LinearBase } from '../../../data-structures/base/linear-base';
3
- export type EntryCallback<K, V, R> = (key: K, value: V, index: number, original: IterableEntryBase<K, V>) => R;
3
+ export type EntryCallback<K, V, R> = (value: V, key: K, index: number, original: IterableEntryBase<K, V>) => R;
4
4
  export type ElementCallback<E, R, RT> = (element: E, index: number, original: IterableElementBase<E, R>) => RT;
5
5
  export type ReduceEntryCallback<K, V, R> = (accumulator: R, value: V, key: K, index: number, original: IterableEntryBase<K, V>) => R;
6
6
  export type ReduceElementCallback<E, R, U = E> = (accumulator: U, value: E, index: number, self: IterableElementBase<E, R>) => U;
@@ -139,7 +139,7 @@ var graphTyped = (() => {
139
139
  every(predicate, thisArg) {
140
140
  let index = 0;
141
141
  for (const item of this) {
142
- if (!predicate.call(thisArg, item[0], item[1], index++, this)) {
142
+ if (!predicate.call(thisArg, item[1], item[0], index++, this)) {
143
143
  return false;
144
144
  }
145
145
  }
@@ -155,7 +155,7 @@ var graphTyped = (() => {
155
155
  some(predicate, thisArg) {
156
156
  let index = 0;
157
157
  for (const item of this) {
158
- if (predicate.call(thisArg, item[0], item[1], index++, this)) {
158
+ if (predicate.call(thisArg, item[1], item[0], index++, this)) {
159
159
  return true;
160
160
  }
161
161
  }
@@ -171,7 +171,7 @@ var graphTyped = (() => {
171
171
  let index = 0;
172
172
  for (const item of this) {
173
173
  const [key, value] = item;
174
- callbackfn.call(thisArg, key, value, index++, this);
174
+ callbackfn.call(thisArg, value, key, index++, this);
175
175
  }
176
176
  }
177
177
  /**
@@ -185,7 +185,7 @@ var graphTyped = (() => {
185
185
  let index = 0;
186
186
  for (const item of this) {
187
187
  const [key, value] = item;
188
- if (callbackfn.call(thisArg, key, value, index++, this)) return item;
188
+ if (callbackfn.call(thisArg, value, key, index++, this)) return item;
189
189
  }
190
190
  return;
191
191
  }
@@ -2132,7 +2132,7 @@ var graphTyped = (() => {
2132
2132
  const filtered = [];
2133
2133
  let index = 0;
2134
2134
  for (const [key, value] of this) {
2135
- if (predicate.call(thisArg, key, value, index, this)) {
2135
+ if (predicate.call(thisArg, value, key, index, this)) {
2136
2136
  filtered.push([key, value]);
2137
2137
  }
2138
2138
  index++;
@@ -2147,7 +2147,7 @@ var graphTyped = (() => {
2147
2147
  const filtered = [];
2148
2148
  let index = 0;
2149
2149
  for (const [key, value] of this) {
2150
- if (predicate.call(thisArg, key, value, index, this)) {
2150
+ if (predicate.call(thisArg, value, key, index, this)) {
2151
2151
  filtered.push([key, value]);
2152
2152
  }
2153
2153
  index++;
@@ -2158,7 +2158,7 @@ var graphTyped = (() => {
2158
2158
  const mapped = [];
2159
2159
  let index = 0;
2160
2160
  for (const [key, value] of this) {
2161
- mapped.push(callback.call(thisArg, key, value, index, this));
2161
+ mapped.push(callback.call(thisArg, value, key, index, this));
2162
2162
  index++;
2163
2163
  }
2164
2164
  return mapped;