graph-typed 2.4.2 → 2.4.4

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 (51) hide show
  1. package/dist/cjs/index.cjs +6 -14
  2. package/dist/cjs/index.cjs.map +1 -1
  3. package/dist/cjs-legacy/index.cjs +6 -14
  4. package/dist/cjs-legacy/index.cjs.map +1 -1
  5. package/dist/esm/index.mjs +6 -14
  6. package/dist/esm/index.mjs.map +1 -1
  7. package/dist/esm-legacy/index.mjs +6 -14
  8. package/dist/esm-legacy/index.mjs.map +1 -1
  9. package/dist/types/data-structures/base/iterable-element-base.d.ts +1 -1
  10. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +5 -5
  11. package/dist/types/data-structures/binary-tree/bst.d.ts +1 -1
  12. package/dist/types/data-structures/binary-tree/tree-map.d.ts +10 -0
  13. package/dist/types/data-structures/binary-tree/tree-set.d.ts +10 -0
  14. package/dist/types/data-structures/graph/directed-graph.d.ts +2 -2
  15. package/dist/types/data-structures/graph/undirected-graph.d.ts +2 -2
  16. package/dist/types/data-structures/hash/hash-map.d.ts +2 -2
  17. package/dist/types/data-structures/heap/heap.d.ts +3 -7
  18. package/dist/types/types/data-structures/binary-tree/avl-tree.d.ts +1 -1
  19. package/dist/types/types/data-structures/binary-tree/red-black-tree.d.ts +1 -1
  20. package/dist/types/types/data-structures/linked-list/doubly-linked-list.d.ts +1 -1
  21. package/dist/types/types/data-structures/linked-list/singly-linked-list.d.ts +1 -1
  22. package/dist/types/types/data-structures/priority-queue/priority-queue.d.ts +1 -1
  23. package/dist/types/types/data-structures/stack/stack.d.ts +1 -1
  24. package/dist/umd/graph-typed.js +6 -14
  25. package/dist/umd/graph-typed.js.map +1 -1
  26. package/dist/umd/graph-typed.min.js +1 -1
  27. package/dist/umd/graph-typed.min.js.map +1 -1
  28. package/package.json +2 -2
  29. package/src/data-structures/base/iterable-element-base.ts +2 -2
  30. package/src/data-structures/binary-tree/binary-tree.ts +8 -7
  31. package/src/data-structures/binary-tree/bst.ts +1 -1
  32. package/src/data-structures/binary-tree/tree-map.ts +16 -0
  33. package/src/data-structures/binary-tree/tree-multi-set.ts +5 -5
  34. package/src/data-structures/binary-tree/tree-set.ts +16 -0
  35. package/src/data-structures/graph/abstract-graph.ts +18 -18
  36. package/src/data-structures/graph/directed-graph.ts +4 -4
  37. package/src/data-structures/graph/map-graph.ts +1 -1
  38. package/src/data-structures/graph/undirected-graph.ts +4 -4
  39. package/src/data-structures/hash/hash-map.ts +6 -4
  40. package/src/data-structures/heap/heap.ts +17 -14
  41. package/src/data-structures/linked-list/doubly-linked-list.ts +4 -4
  42. package/src/data-structures/linked-list/singly-linked-list.ts +15 -9
  43. package/src/data-structures/queue/deque.ts +1 -1
  44. package/src/data-structures/stack/stack.ts +1 -1
  45. package/src/data-structures/trie/trie.ts +10 -5
  46. package/src/types/data-structures/binary-tree/avl-tree.ts +1 -1
  47. package/src/types/data-structures/binary-tree/red-black-tree.ts +1 -1
  48. package/src/types/data-structures/linked-list/doubly-linked-list.ts +1 -1
  49. package/src/types/data-structures/linked-list/singly-linked-list.ts +1 -1
  50. package/src/types/data-structures/priority-queue/priority-queue.ts +1 -1
  51. package/src/types/data-structures/stack/stack.ts +1 -1
@@ -779,11 +779,6 @@ var _Heap = class _Heap extends IterableElementBase {
779
779
  }
780
780
  return out;
781
781
  }
782
- /**
783
- * Get the comparator used to order elements.
784
- * @remarks Time O(1), Space O(1)
785
- * @returns Comparator function.
786
- */
787
782
  /**
788
783
  * Get the comparator used to order elements.
789
784
  * @remarks Time O(1), Space O(1)
@@ -832,8 +827,7 @@ var _Heap = class _Heap extends IterableElementBase {
832
827
  */
833
828
  _createInstance(options) {
834
829
  const Ctor = this.constructor;
835
- const next = new Ctor([], { comparator: this.comparator, toElementFn: this.toElementFn, ...options != null ? options : {} });
836
- return next;
830
+ return new Ctor([], { comparator: this.comparator, toElementFn: this.toElementFn, ...options != null ? options : {} });
837
831
  }
838
832
  /**
839
833
  * (Protected) Create a like-kind instance seeded by elements.
@@ -2171,8 +2165,8 @@ var _AbstractGraph = class _AbstractGraph extends IterableEntryBase {
2171
2165
  const Ctor = this.constructor;
2172
2166
  const instance = new Ctor();
2173
2167
  const graph = _options == null ? void 0 : _options.graph;
2174
- if (graph) instance._options = { ...instance._options, ...graph };
2175
- else instance._options = { ...instance._options, ...this._options };
2168
+ if (graph) instance["_options"] = { ...instance["_options"], ...graph };
2169
+ else instance["_options"] = { ...instance["_options"], ...this._options };
2176
2170
  return instance;
2177
2171
  }
2178
2172
  /**
@@ -2205,12 +2199,10 @@ var _AbstractGraph = class _AbstractGraph extends IterableEntryBase {
2205
2199
  const [va, vb] = ends;
2206
2200
  const ka = va.key;
2207
2201
  const kb = vb.key;
2208
- const hasA = g.hasVertex ? g.hasVertex(ka) : false;
2209
- const hasB = g.hasVertex ? g.hasVertex(kb) : false;
2202
+ const hasA = typeof g.hasVertex === "function" ? g.hasVertex(ka) : false;
2203
+ const hasB = typeof g.hasVertex === "function" ? g.hasVertex(kb) : false;
2210
2204
  if (hasA && hasB) {
2211
- const w = e.weight;
2212
- const val = e.value;
2213
- const newEdge = g.createEdge(ka, kb, w, val);
2205
+ const newEdge = g.createEdge(ka, kb, e.weight, e.value);
2214
2206
  g._addEdge(newEdge);
2215
2207
  }
2216
2208
  }