@zengrid/core 1.0.1 → 1.0.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.
- package/dist/index.cjs.js +43 -55
- package/dist/index.esm.js +2 -14
- package/dist/package.json +5 -5
- package/dist/src/a11y/aria-manager.d.ts.map +1 -1
- package/dist/src/a11y/focus-manager.d.ts.map +1 -1
- package/dist/src/a11y/index.d.ts.map +1 -1
- package/dist/src/data/data-accessor/array-accessor.d.ts.map +1 -1
- package/dist/src/data/data-accessor/column-store-accessor.d.ts.map +1 -1
- package/dist/src/data/data-accessor/data-accessor.interface.d.ts.map +1 -1
- package/dist/src/data/data-accessor/index.d.ts.map +1 -1
- package/dist/src/data/data-accessor/sparse-matrix-accessor.d.ts.map +1 -1
- package/dist/src/data/data-manager.d.ts.map +1 -1
- package/dist/src/data/data-source.interface.d.ts.map +1 -1
- package/dist/src/data/grid-data-model.d.ts +2 -2
- package/dist/src/data/grid-data-model.d.ts.map +1 -1
- package/dist/src/data/index-map/index-map.d.ts.map +1 -1
- package/dist/src/data/index-map/index-map.interface.d.ts.map +1 -1
- package/dist/src/data/index-map/index.d.ts.map +1 -1
- package/dist/src/data/index.d.ts.map +1 -1
- package/dist/src/editing/cell-editor.interface.d.ts.map +1 -1
- package/dist/src/editing/date-editor.d.ts.map +1 -1
- package/dist/src/editing/editor-manager.d.ts.map +1 -1
- package/dist/src/editing/index.d.ts.map +1 -1
- package/dist/src/editing/number-editor.d.ts.map +1 -1
- package/dist/src/editing/select-editor.d.ts.map +1 -1
- package/dist/src/editing/text-editor.d.ts.map +1 -1
- package/dist/src/events/event-emitter.d.ts.map +1 -1
- package/dist/src/events/grid-events.d.ts.map +1 -1
- package/dist/src/events/index.d.ts.map +1 -1
- package/dist/src/features/autofill/autofill-manager.d.ts +1 -1
- package/dist/src/features/autofill/autofill-manager.d.ts.map +1 -1
- package/dist/src/features/autofill/index.d.ts.map +1 -1
- package/dist/src/features/column-resize/auto-fit-calculator.d.ts.map +1 -1
- package/dist/src/features/column-resize/column-resize-manager.d.ts.map +1 -1
- package/dist/src/features/column-resize/column-resize-manager.interface.d.ts.map +1 -1
- package/dist/src/features/column-resize/index.d.ts.map +1 -1
- package/dist/src/features/column-resize/resize-constraint-manager.d.ts.map +1 -1
- package/dist/src/features/column-resize/resize-handle-renderer.d.ts.map +1 -1
- package/dist/src/features/column-resize/resize-preview.d.ts.map +1 -1
- package/dist/src/features/column-resize/resize-state-manager.d.ts.map +1 -1
- package/dist/src/features/column-resize/resize-strategies.d.ts.map +1 -1
- package/dist/src/features/column-resize/resize-test-helper.d.ts.map +1 -1
- package/dist/src/features/column-resize/resize-zone-detector.d.ts.map +1 -1
- package/dist/src/features/copy-paste/clipboard-manager.d.ts.map +1 -1
- package/dist/src/features/copy-paste/index.d.ts.map +1 -1
- package/dist/src/features/filtering/adapters/adapter.interface.d.ts.map +1 -1
- package/dist/src/features/filtering/adapters/graphql-adapter.d.ts.map +1 -1
- package/dist/src/features/filtering/adapters/index.d.ts.map +1 -1
- package/dist/src/features/filtering/adapters/rest-adapter.d.ts.map +1 -1
- package/dist/src/features/filtering/adapters/sql-adapter.d.ts.map +1 -1
- package/dist/src/features/filtering/adapters/types.d.ts.map +1 -1
- package/dist/src/features/filtering/column-filter.d.ts.map +1 -1
- package/dist/src/features/filtering/filter-autocomplete.d.ts.map +1 -1
- package/dist/src/features/filtering/filter-cache.d.ts.map +1 -1
- package/dist/src/features/filtering/filter-compiler.d.ts.map +1 -1
- package/dist/src/features/filtering/filter-export-manager.d.ts.map +1 -1
- package/dist/src/features/filtering/filter-index-manager.d.ts +1 -1
- package/dist/src/features/filtering/filter-index-manager.d.ts.map +1 -1
- package/dist/src/features/filtering/filter-manager.d.ts +1 -1
- package/dist/src/features/filtering/filter-manager.d.ts.map +1 -1
- package/dist/src/features/filtering/filter-optimizer.d.ts.map +1 -1
- package/dist/src/features/filtering/filter-query-parser.d.ts.map +1 -1
- package/dist/src/features/filtering/index.d.ts.map +1 -1
- package/dist/src/features/filtering/range-filter-optimizer.d.ts.map +1 -1
- package/dist/src/features/filtering/substring-filter.d.ts.map +1 -1
- package/dist/src/features/filtering/types.d.ts.map +1 -1
- package/dist/src/features/formulas/formula-calculator.d.ts.map +1 -1
- package/dist/src/features/formulas/index.d.ts.map +1 -1
- package/dist/src/features/hit-testing/index.d.ts.map +1 -1
- package/dist/src/features/hit-testing/spatial-hit-tester.d.ts +1 -1
- package/dist/src/features/hit-testing/spatial-hit-tester.d.ts.map +1 -1
- package/dist/src/features/loading/index.d.ts.map +1 -1
- package/dist/src/features/loading/loading-indicator.d.ts.map +1 -1
- package/dist/src/features/pagination/index.d.ts.map +1 -1
- package/dist/src/features/pagination/paginator.d.ts.map +1 -1
- package/dist/src/features/selection/index.d.ts.map +1 -1
- package/dist/src/features/selection/selection-manager.d.ts.map +1 -1
- package/dist/src/features/sorting/index.d.ts.map +1 -1
- package/dist/src/features/sorting/row-sorter.interface.d.ts.map +1 -1
- package/dist/src/features/sorting/single-column-sorter.d.ts.map +1 -1
- package/dist/src/features/sorting/sort-manager.d.ts.map +1 -1
- package/dist/src/features/undo-redo/index.d.ts.map +1 -1
- package/dist/src/features/undo-redo/undo-redo-manager.d.ts.map +1 -1
- package/dist/src/grid.d.ts.map +1 -1
- package/dist/src/i18n/index.d.ts.map +1 -1
- package/dist/src/i18n/locale-manager.d.ts.map +1 -1
- package/dist/src/i18n/rtl-support.d.ts.map +1 -1
- package/dist/src/index.d.ts +4 -4
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/keyboard/index.d.ts.map +1 -1
- package/dist/src/keyboard/keyboard-navigator.d.ts.map +1 -1
- package/dist/src/rendering/cache/index.d.ts.map +1 -1
- package/dist/src/rendering/cache/renderer-cache.d.ts.map +1 -1
- package/dist/src/rendering/cache/renderer-cache.interface.d.ts.map +1 -1
- package/dist/src/rendering/cell-pool/cell-pool.d.ts.map +1 -1
- package/dist/src/rendering/cell-pool/cell-pool.interface.d.ts.map +1 -1
- package/dist/src/rendering/cell-pool/index.d.ts.map +1 -1
- package/dist/src/rendering/cell-positioner/cell-positioner.d.ts.map +1 -1
- package/dist/src/rendering/cell-positioner/cell-positioner.interface.d.ts.map +1 -1
- package/dist/src/rendering/cell-positioner/index.d.ts.map +1 -1
- package/dist/src/rendering/height-provider/height-provider.interface.d.ts.map +1 -1
- package/dist/src/rendering/height-provider/index.d.ts.map +1 -1
- package/dist/src/rendering/height-provider/uniform-height-provider.d.ts.map +1 -1
- package/dist/src/rendering/height-provider/variable-height-provider.d.ts.map +1 -1
- package/dist/src/rendering/renderers/advanced-cell-renderer.d.ts.map +1 -1
- package/dist/src/rendering/renderers/image-renderer.d.ts.map +1 -1
- package/dist/src/rendering/renderers/index.d.ts.map +1 -1
- package/dist/src/rendering/renderers/number-renderer.d.ts.map +1 -1
- package/dist/src/rendering/renderers/renderer-registry.d.ts.map +1 -1
- package/dist/src/rendering/renderers/renderer.interface.d.ts.map +1 -1
- package/dist/src/rendering/renderers/text-renderer.d.ts.map +1 -1
- package/dist/src/rendering/spatial-hit-tester.d.ts +1 -1
- package/dist/src/rendering/spatial-hit-tester.d.ts.map +1 -1
- package/dist/src/rendering/virtual-scroller/index.d.ts.map +1 -1
- package/dist/src/rendering/virtual-scroller/virtual-scroller.d.ts.map +1 -1
- package/dist/src/rendering/virtual-scroller/virtual-scroller.interface.d.ts.map +1 -1
- package/dist/src/rendering/width-provider/index.d.ts.map +1 -1
- package/dist/src/rendering/width-provider/uniform-width-provider.d.ts.map +1 -1
- package/dist/src/rendering/width-provider/variable-width-provider.d.ts.map +1 -1
- package/dist/src/rendering/width-provider/width-provider.interface.d.ts.map +1 -1
- package/dist/src/selection/hit-tester.d.ts.map +1 -1
- package/dist/src/selection/hit-tester.interface.d.ts.map +1 -1
- package/dist/src/selection/index.d.ts.map +1 -1
- package/dist/src/selection/range-utils.d.ts.map +1 -1
- package/dist/src/selection/range-utils.interface.d.ts.map +1 -1
- package/dist/src/shared/algorithms/filter/bloom-filter.d.ts +120 -0
- package/dist/src/shared/algorithms/filter/bloom-filter.d.ts.map +1 -0
- package/dist/src/shared/algorithms/filter/index.d.ts +7 -0
- package/dist/src/shared/algorithms/filter/index.d.ts.map +1 -0
- package/dist/src/shared/algorithms/graph/bfs.d.ts +71 -0
- package/dist/src/shared/algorithms/graph/bfs.d.ts.map +1 -0
- package/dist/src/shared/algorithms/graph/dfs.d.ts +62 -0
- package/dist/src/shared/algorithms/graph/dfs.d.ts.map +1 -0
- package/dist/src/shared/algorithms/graph/graph.interface.d.ts +63 -0
- package/dist/src/shared/algorithms/graph/graph.interface.d.ts.map +1 -0
- package/dist/src/shared/algorithms/graph/index.d.ts +9 -0
- package/dist/src/shared/algorithms/graph/index.d.ts.map +1 -0
- package/dist/src/shared/algorithms/index.d.ts +11 -0
- package/dist/src/shared/algorithms/index.d.ts.map +1 -0
- package/dist/src/shared/algorithms/pattern/index.d.ts +8 -0
- package/dist/src/shared/algorithms/pattern/index.d.ts.map +1 -0
- package/dist/src/shared/algorithms/pattern/sequence-detector.d.ts +62 -0
- package/dist/src/shared/algorithms/pattern/sequence-detector.d.ts.map +1 -0
- package/dist/src/shared/algorithms/search/binary-search.d.ts +86 -0
- package/dist/src/shared/algorithms/search/binary-search.d.ts.map +1 -0
- package/dist/src/shared/algorithms/search/index.d.ts +6 -0
- package/dist/src/shared/algorithms/search/index.d.ts.map +1 -0
- package/dist/src/shared/algorithms/sorting/comparators.d.ts +126 -0
- package/dist/src/shared/algorithms/sorting/comparators.d.ts.map +1 -0
- package/dist/src/shared/algorithms/sorting/index.d.ts +9 -0
- package/dist/src/shared/algorithms/sorting/index.d.ts.map +1 -0
- package/dist/src/shared/algorithms/sorting/sorting.interface.d.ts +38 -0
- package/dist/src/shared/algorithms/sorting/sorting.interface.d.ts.map +1 -0
- package/dist/src/shared/algorithms/sorting/timsort.d.ts +55 -0
- package/dist/src/shared/algorithms/sorting/timsort.d.ts.map +1 -0
- package/dist/src/shared/data-structures/column-store/column-store.d.ts +52 -0
- package/dist/src/shared/data-structures/column-store/column-store.d.ts.map +1 -0
- package/dist/src/shared/data-structures/column-store/column-store.interface.d.ts +155 -0
- package/dist/src/shared/data-structures/column-store/column-store.interface.d.ts.map +1 -0
- package/dist/src/shared/data-structures/column-store/index.d.ts +6 -0
- package/dist/src/shared/data-structures/column-store/index.d.ts.map +1 -0
- package/dist/src/shared/data-structures/command-stack/command-stack.d.ts +61 -0
- package/dist/src/shared/data-structures/command-stack/command-stack.d.ts.map +1 -0
- package/dist/src/shared/data-structures/command-stack/command-stack.interface.d.ts +80 -0
- package/dist/src/shared/data-structures/command-stack/command-stack.interface.d.ts.map +1 -0
- package/dist/src/shared/data-structures/command-stack/index.d.ts +3 -0
- package/dist/src/shared/data-structures/command-stack/index.d.ts.map +1 -0
- package/dist/src/shared/data-structures/dependency-graph/dependency-graph.d.ts +147 -0
- package/dist/src/shared/data-structures/dependency-graph/dependency-graph.d.ts.map +1 -0
- package/dist/src/shared/data-structures/dependency-graph/dependency-graph.interface.d.ts +161 -0
- package/dist/src/shared/data-structures/dependency-graph/dependency-graph.interface.d.ts.map +1 -0
- package/dist/src/shared/data-structures/dependency-graph/index.d.ts +8 -0
- package/dist/src/shared/data-structures/dependency-graph/index.d.ts.map +1 -0
- package/dist/src/shared/data-structures/disjoint-set/disjoint-set.d.ts +84 -0
- package/dist/src/shared/data-structures/disjoint-set/disjoint-set.d.ts.map +1 -0
- package/dist/src/shared/data-structures/disjoint-set/disjoint-set.interface.d.ts +185 -0
- package/dist/src/shared/data-structures/disjoint-set/disjoint-set.interface.d.ts.map +1 -0
- package/dist/src/shared/data-structures/disjoint-set/index.d.ts +7 -0
- package/dist/src/shared/data-structures/disjoint-set/index.d.ts.map +1 -0
- package/dist/src/shared/data-structures/index-map/index-map.d.ts +150 -0
- package/dist/src/shared/data-structures/index-map/index-map.d.ts.map +1 -0
- package/dist/src/shared/data-structures/index-map/index-map.interface.d.ts +186 -0
- package/dist/src/shared/data-structures/index-map/index-map.interface.d.ts.map +1 -0
- package/dist/src/shared/data-structures/index-map/index.d.ts +6 -0
- package/dist/src/shared/data-structures/index-map/index.d.ts.map +1 -0
- package/dist/src/shared/data-structures/index.d.ts +36 -0
- package/dist/src/shared/data-structures/index.d.ts.map +1 -0
- package/dist/src/shared/data-structures/interval-tree/index.d.ts +7 -0
- package/dist/src/shared/data-structures/interval-tree/index.d.ts.map +1 -0
- package/dist/src/shared/data-structures/interval-tree/interval-tree.d.ts +141 -0
- package/dist/src/shared/data-structures/interval-tree/interval-tree.d.ts.map +1 -0
- package/dist/src/shared/data-structures/interval-tree/interval-tree.interface.d.ts +212 -0
- package/dist/src/shared/data-structures/interval-tree/interval-tree.interface.d.ts.map +1 -0
- package/dist/src/shared/data-structures/lru-cache/index.d.ts +3 -0
- package/dist/src/shared/data-structures/lru-cache/index.d.ts.map +1 -0
- package/dist/src/shared/data-structures/lru-cache/lru-cache.d.ts +134 -0
- package/dist/src/shared/data-structures/lru-cache/lru-cache.d.ts.map +1 -0
- package/dist/src/shared/data-structures/lru-cache/lru-cache.interface.d.ts +173 -0
- package/dist/src/shared/data-structures/lru-cache/lru-cache.interface.d.ts.map +1 -0
- package/dist/src/shared/data-structures/prefix-sum-array/index.d.ts +6 -0
- package/dist/src/shared/data-structures/prefix-sum-array/index.d.ts.map +1 -0
- package/dist/src/shared/data-structures/prefix-sum-array/prefix-sum-array.d.ts +63 -0
- package/dist/src/shared/data-structures/prefix-sum-array/prefix-sum-array.d.ts.map +1 -0
- package/dist/src/shared/data-structures/prefix-sum-array/prefix-sum-array.interface.d.ts +80 -0
- package/dist/src/shared/data-structures/prefix-sum-array/prefix-sum-array.interface.d.ts.map +1 -0
- package/dist/src/shared/data-structures/rtree/index.d.ts +8 -0
- package/dist/src/shared/data-structures/rtree/index.d.ts.map +1 -0
- package/dist/src/shared/data-structures/rtree/rtree.d.ts +81 -0
- package/dist/src/shared/data-structures/rtree/rtree.d.ts.map +1 -0
- package/dist/src/shared/data-structures/rtree/rtree.interface.d.ts +143 -0
- package/dist/src/shared/data-structures/rtree/rtree.interface.d.ts.map +1 -0
- package/dist/src/shared/data-structures/segment-tree/index.d.ts +4 -0
- package/dist/src/shared/data-structures/segment-tree/index.d.ts.map +1 -0
- package/dist/src/shared/data-structures/segment-tree/segment-tree.d.ts +134 -0
- package/dist/src/shared/data-structures/segment-tree/segment-tree.d.ts.map +1 -0
- package/dist/src/shared/data-structures/segment-tree/segment-tree.interface.d.ts +202 -0
- package/dist/src/shared/data-structures/segment-tree/segment-tree.interface.d.ts.map +1 -0
- package/dist/src/shared/data-structures/skip-list/index.d.ts +4 -0
- package/dist/src/shared/data-structures/skip-list/index.d.ts.map +1 -0
- package/dist/src/shared/data-structures/skip-list/skip-list.d.ts +137 -0
- package/dist/src/shared/data-structures/skip-list/skip-list.d.ts.map +1 -0
- package/dist/src/shared/data-structures/skip-list/skip-list.interface.d.ts +223 -0
- package/dist/src/shared/data-structures/skip-list/skip-list.interface.d.ts.map +1 -0
- package/dist/src/shared/data-structures/sparse-matrix/index.d.ts +6 -0
- package/dist/src/shared/data-structures/sparse-matrix/index.d.ts.map +1 -0
- package/dist/src/shared/data-structures/sparse-matrix/sparse-matrix.d.ts +44 -0
- package/dist/src/shared/data-structures/sparse-matrix/sparse-matrix.d.ts.map +1 -0
- package/dist/src/shared/data-structures/sparse-matrix/sparse-matrix.interface.d.ts +105 -0
- package/dist/src/shared/data-structures/sparse-matrix/sparse-matrix.interface.d.ts.map +1 -0
- package/dist/src/shared/data-structures/suffix-array/index.d.ts +3 -0
- package/dist/src/shared/data-structures/suffix-array/index.d.ts.map +1 -0
- package/dist/src/shared/data-structures/suffix-array/suffix-array.d.ts +102 -0
- package/dist/src/shared/data-structures/suffix-array/suffix-array.d.ts.map +1 -0
- package/dist/src/shared/data-structures/suffix-array/suffix-array.interface.d.ts +117 -0
- package/dist/src/shared/data-structures/suffix-array/suffix-array.interface.d.ts.map +1 -0
- package/dist/src/shared/data-structures/trie/index.d.ts +8 -0
- package/dist/src/shared/data-structures/trie/index.d.ts.map +1 -0
- package/dist/src/shared/data-structures/trie/trie.d.ts +205 -0
- package/dist/src/shared/data-structures/trie/trie.d.ts.map +1 -0
- package/dist/src/shared/data-structures/trie/trie.interface.d.ts +117 -0
- package/dist/src/shared/data-structures/trie/trie.interface.d.ts.map +1 -0
- package/dist/src/shared/index.d.ts +47 -0
- package/dist/src/shared/index.d.ts.map +1 -0
- package/dist/src/shared/patterns/coordinator.d.ts +90 -0
- package/dist/src/shared/patterns/coordinator.d.ts.map +1 -0
- package/dist/src/shared/patterns/event-emitter.d.ts +106 -0
- package/dist/src/shared/patterns/event-emitter.d.ts.map +1 -0
- package/dist/src/shared/patterns/factory.d.ts +120 -0
- package/dist/src/shared/patterns/factory.d.ts.map +1 -0
- package/dist/src/shared/patterns/index.d.ts +21 -0
- package/dist/src/shared/patterns/index.d.ts.map +1 -0
- package/dist/src/shared/patterns/mediator.d.ts +116 -0
- package/dist/src/shared/patterns/mediator.d.ts.map +1 -0
- package/dist/src/shared/patterns/object-pool.d.ts +178 -0
- package/dist/src/shared/patterns/object-pool.d.ts.map +1 -0
- package/dist/src/shared/patterns/observer.d.ts +89 -0
- package/dist/src/shared/patterns/observer.d.ts.map +1 -0
- package/dist/src/shared/patterns/operation-mode.d.ts +75 -0
- package/dist/src/shared/patterns/operation-mode.d.ts.map +1 -0
- package/dist/src/shared/patterns/state-machine.d.ts +122 -0
- package/dist/src/shared/patterns/state-machine.d.ts.map +1 -0
- package/dist/src/shared/types/common.d.ts +56 -0
- package/dist/src/shared/types/common.d.ts.map +1 -0
- package/dist/src/shared/types/index.d.ts +5 -0
- package/dist/src/shared/types/index.d.ts.map +1 -0
- package/dist/src/shared/utils/index.d.ts +7 -0
- package/dist/src/shared/utils/index.d.ts.map +1 -0
- package/dist/src/shared/utils/timing.d.ts +104 -0
- package/dist/src/shared/utils/timing.d.ts.map +1 -0
- package/dist/src/shared/utils/timing.interface.d.ts +96 -0
- package/dist/src/shared/utils/timing.interface.d.ts.map +1 -0
- package/dist/src/touch/index.d.ts.map +1 -1
- package/dist/src/touch/touch-handler.d.ts.map +1 -1
- package/dist/src/types/index.d.ts.map +1 -1
- package/dist/src/types.d.ts.map +1 -1
- package/package.json +47 -47
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Disjoint Set (Union-Find) implementation for ZenGrid
|
|
3
|
+
*/
|
|
4
|
+
import type { IDisjointSet, DisjointSetOptions, DisjointSetStats } from './disjoint-set.interface';
|
|
5
|
+
/**
|
|
6
|
+
* Disjoint Set implementation with path compression and union by rank
|
|
7
|
+
*/
|
|
8
|
+
export declare class DisjointSet<T> implements IDisjointSet<T> {
|
|
9
|
+
private parent;
|
|
10
|
+
private rank;
|
|
11
|
+
private setSize;
|
|
12
|
+
private elementMap;
|
|
13
|
+
private hashFn;
|
|
14
|
+
private equalityFn;
|
|
15
|
+
constructor(options?: DisjointSetOptions<T>);
|
|
16
|
+
/**
|
|
17
|
+
* Create a new set containing only the given element
|
|
18
|
+
*/
|
|
19
|
+
makeSet(element: T): void;
|
|
20
|
+
/**
|
|
21
|
+
* Find the representative (root) of the set containing the element
|
|
22
|
+
* Uses path compression to optimize future queries
|
|
23
|
+
*/
|
|
24
|
+
find(element: T): T | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Internal find with path compression
|
|
27
|
+
*/
|
|
28
|
+
private _findWithCompression;
|
|
29
|
+
/**
|
|
30
|
+
* Unite the sets containing two elements
|
|
31
|
+
* Uses union by rank to keep trees shallow
|
|
32
|
+
*/
|
|
33
|
+
union(element1: T, element2: T): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Check if two elements are in the same set
|
|
36
|
+
*/
|
|
37
|
+
connected(element1: T, element2: T): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Get the size of the set containing the element
|
|
40
|
+
*/
|
|
41
|
+
getSetSize(element: T): number;
|
|
42
|
+
/**
|
|
43
|
+
* Get all disjoint sets
|
|
44
|
+
*/
|
|
45
|
+
getSets(): Map<T, T[]>;
|
|
46
|
+
/**
|
|
47
|
+
* Get all elements in the same set as the given element
|
|
48
|
+
*/
|
|
49
|
+
getSet(element: T): T[];
|
|
50
|
+
/**
|
|
51
|
+
* Check if an element exists in the data structure
|
|
52
|
+
*/
|
|
53
|
+
has(element: T): boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Remove an element from the data structure
|
|
56
|
+
* Note: This is not a standard operation and has O(n) complexity
|
|
57
|
+
*/
|
|
58
|
+
remove(element: T): boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Clear all sets
|
|
61
|
+
*/
|
|
62
|
+
clear(): void;
|
|
63
|
+
/**
|
|
64
|
+
* Get all elements
|
|
65
|
+
*/
|
|
66
|
+
elements(): T[];
|
|
67
|
+
/**
|
|
68
|
+
* Get statistics about the disjoint set
|
|
69
|
+
*/
|
|
70
|
+
getStats(): DisjointSetStats;
|
|
71
|
+
/**
|
|
72
|
+
* Number of elements in the data structure
|
|
73
|
+
*/
|
|
74
|
+
get size(): number;
|
|
75
|
+
/**
|
|
76
|
+
* Number of disjoint sets
|
|
77
|
+
*/
|
|
78
|
+
get numSets(): number;
|
|
79
|
+
/**
|
|
80
|
+
* Whether the data structure is empty
|
|
81
|
+
*/
|
|
82
|
+
get isEmpty(): boolean;
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=disjoint-set.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"disjoint-set.d.ts","sourceRoot":"","sources":["../../../../../src/shared/data-structures/disjoint-set/disjoint-set.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EACV,YAAY,EACZ,kBAAkB,EAClB,gBAAgB,EACjB,MAAM,0BAA0B,CAAC;AAmBlC;;GAEG;AACH,qBAAa,WAAW,CAAC,CAAC,CAAE,YAAW,YAAY,CAAC,CAAC,CAAC;IACpD,OAAO,CAAC,MAAM,CAA0B;IACxC,OAAO,CAAC,IAAI,CAA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+
* Efficient data structure for managing merged cells and connected components
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Disjoint Set statistics
|
|
7
|
+
*/
|
|
8
|
+
export interface DisjointSetStats {
|
|
9
|
+
/** Total number of elements */
|
|
10
|
+
totalElements: number;
|
|
11
|
+
/** Number of disjoint sets */
|
|
12
|
+
numSets: number;
|
|
13
|
+
/** Size of the largest set */
|
|
14
|
+
largestSetSize: number;
|
|
15
|
+
/** Average set size */
|
|
16
|
+
averageSetSize: number;
|
|
17
|
+
/** Memory usage estimate in bytes */
|
|
18
|
+
memoryBytes: number;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Disjoint Set interface (Union-Find)
|
|
22
|
+
*
|
|
23
|
+
* A data structure for tracking a partition of elements into disjoint sets.
|
|
24
|
+
* Uses path compression and union by rank for near-constant time operations.
|
|
25
|
+
*
|
|
26
|
+
* Use cases:
|
|
27
|
+
* - Managing merged cells in spreadsheets
|
|
28
|
+
* - Tracking connected components in graphs
|
|
29
|
+
* - Detecting cycles in undirected graphs
|
|
30
|
+
* - Kruskal's minimum spanning tree algorithm
|
|
31
|
+
* - Image segmentation
|
|
32
|
+
* - Network connectivity
|
|
33
|
+
*
|
|
34
|
+
* Performance:
|
|
35
|
+
* - makeSet: O(1)
|
|
36
|
+
* - find: O(α(n)) amortized, where α is inverse Ackermann function (effectively O(1))
|
|
37
|
+
* - union: O(α(n)) amortized
|
|
38
|
+
* - connected: O(α(n)) amortized
|
|
39
|
+
* - Space: O(n)
|
|
40
|
+
*
|
|
41
|
+
* Optimizations:
|
|
42
|
+
* - Path compression: Makes find operations extremely fast
|
|
43
|
+
* - Union by rank: Keeps trees shallow for better performance
|
|
44
|
+
* - Both optimizations together give near-constant time complexity
|
|
45
|
+
*/
|
|
46
|
+
export interface IDisjointSet<T> {
|
|
47
|
+
/**
|
|
48
|
+
* Create a new set containing only the given element
|
|
49
|
+
* If element already exists, this is a no-op
|
|
50
|
+
* @param element - The element to create a set for
|
|
51
|
+
* @complexity O(1)
|
|
52
|
+
*/
|
|
53
|
+
makeSet(element: T): void;
|
|
54
|
+
/**
|
|
55
|
+
* Find the representative (root) of the set containing the element
|
|
56
|
+
* Uses path compression to optimize future queries
|
|
57
|
+
* @param element - The element to find
|
|
58
|
+
* @returns The representative element, or undefined if element doesn't exist
|
|
59
|
+
* @complexity O(α(n)) amortized
|
|
60
|
+
*/
|
|
61
|
+
find(element: T): T | undefined;
|
|
62
|
+
/**
|
|
63
|
+
* Unite the sets containing two elements
|
|
64
|
+
* Uses union by rank to keep trees shallow
|
|
65
|
+
* @param element1 - First element
|
|
66
|
+
* @param element2 - Second element
|
|
67
|
+
* @returns true if sets were merged, false if already in same set or element doesn't exist
|
|
68
|
+
* @complexity O(α(n)) amortized
|
|
69
|
+
*/
|
|
70
|
+
union(element1: T, element2: T): boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Check if two elements are in the same set
|
|
73
|
+
* @param element1 - First element
|
|
74
|
+
* @param element2 - Second element
|
|
75
|
+
* @returns true if both elements exist and are in the same set
|
|
76
|
+
* @complexity O(α(n)) amortized
|
|
77
|
+
*/
|
|
78
|
+
connected(element1: T, element2: T): boolean;
|
|
79
|
+
/**
|
|
80
|
+
* Get the size of the set containing the element
|
|
81
|
+
* @param element - The element to query
|
|
82
|
+
* @returns Size of the set, or 0 if element doesn't exist
|
|
83
|
+
* @complexity O(α(n)) amortized
|
|
84
|
+
*/
|
|
85
|
+
getSetSize(element: T): number;
|
|
86
|
+
/**
|
|
87
|
+
* Get all disjoint sets
|
|
88
|
+
* @returns Map from representative element to array of all elements in that set
|
|
89
|
+
* @complexity O(n)
|
|
90
|
+
*/
|
|
91
|
+
getSets(): Map<T, T[]>;
|
|
92
|
+
/**
|
|
93
|
+
* Get all elements in the same set as the given element
|
|
94
|
+
* @param element - The element to query
|
|
95
|
+
* @returns Array of all elements in the same set, or empty array if element doesn't exist
|
|
96
|
+
* @complexity O(n) - needs to scan all elements
|
|
97
|
+
*/
|
|
98
|
+
getSet(element: T): T[];
|
|
99
|
+
/**
|
|
100
|
+
* Check if an element exists in the data structure
|
|
101
|
+
* @param element - The element to check
|
|
102
|
+
* @complexity O(1)
|
|
103
|
+
*/
|
|
104
|
+
has(element: T): boolean;
|
|
105
|
+
/**
|
|
106
|
+
* Remove an element from the data structure
|
|
107
|
+
* Note: This is not a standard operation for Disjoint Set and has O(n) complexity
|
|
108
|
+
* @param element - The element to remove
|
|
109
|
+
* @returns true if element was found and removed
|
|
110
|
+
* @complexity O(n)
|
|
111
|
+
*/
|
|
112
|
+
remove(element: T): boolean;
|
|
113
|
+
/**
|
|
114
|
+
* Clear all sets
|
|
115
|
+
* @complexity O(1)
|
|
116
|
+
*/
|
|
117
|
+
clear(): void;
|
|
118
|
+
/**
|
|
119
|
+
* Get all elements
|
|
120
|
+
* @returns Array of all elements
|
|
121
|
+
* @complexity O(n)
|
|
122
|
+
*/
|
|
123
|
+
elements(): T[];
|
|
124
|
+
/**
|
|
125
|
+
* Get statistics about the disjoint set
|
|
126
|
+
*/
|
|
127
|
+
getStats(): DisjointSetStats;
|
|
128
|
+
/**
|
|
129
|
+
* Number of elements in the data structure
|
|
130
|
+
*/
|
|
131
|
+
readonly size: number;
|
|
132
|
+
/**
|
|
133
|
+
* Number of disjoint sets
|
|
134
|
+
*/
|
|
135
|
+
readonly numSets: number;
|
|
136
|
+
/**
|
|
137
|
+
* Whether the data structure is empty
|
|
138
|
+
*/
|
|
139
|
+
readonly isEmpty: boolean;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Options for creating a Disjoint Set
|
|
143
|
+
*/
|
|
144
|
+
export interface DisjointSetOptions<T> {
|
|
145
|
+
/**
|
|
146
|
+
* Custom hash function for elements
|
|
147
|
+
* If not provided, uses JSON.stringify for objects or toString for primitives
|
|
148
|
+
*/
|
|
149
|
+
hashFn?: (element: T) => string | number;
|
|
150
|
+
/**
|
|
151
|
+
* Custom equality function
|
|
152
|
+
* If not provided, uses strict equality (===)
|
|
153
|
+
*/
|
|
154
|
+
equalityFn?: (a: T, b: T) => boolean;
|
|
155
|
+
/**
|
|
156
|
+
* Initial elements to create sets for
|
|
157
|
+
*/
|
|
158
|
+
initialElements?: T[];
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Utility functions for Disjoint Set
|
|
162
|
+
*/
|
|
163
|
+
export declare const DisjointSetUtils: {
|
|
164
|
+
/**
|
|
165
|
+
* Calculate expected memory usage
|
|
166
|
+
* @param n - Number of elements
|
|
167
|
+
* @returns Estimated memory in bytes
|
|
168
|
+
*/
|
|
169
|
+
estimateMemory(n: number): number;
|
|
170
|
+
/**
|
|
171
|
+
* Check if operations are effectively O(1)
|
|
172
|
+
* For practical purposes, α(n) ≤ 4 for any realistic n
|
|
173
|
+
*/
|
|
174
|
+
inverseAckermann(n: number): number;
|
|
175
|
+
/**
|
|
176
|
+
* Create a grid coordinate hash function for merged cells
|
|
177
|
+
* Useful for grid applications where elements are [row, col] coordinates
|
|
178
|
+
*/
|
|
179
|
+
gridHashFn(element: [number, number]): string;
|
|
180
|
+
/**
|
|
181
|
+
* Create equality function for grid coordinates
|
|
182
|
+
*/
|
|
183
|
+
gridEqualityFn(a: [number, number], b: [number, number]): boolean;
|
|
184
|
+
};
|
|
185
|
+
//# sourceMappingURL=disjoint-set.interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"disjoint-set.interface.d.ts","sourceRoot":"","sources":["../../../../../src/shared/data-structures/disjoint-set/disjoint-set.interface.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,+BAA+B;IAC/B,aAAa,EAAE,MAAM,CAAC;IACtB,8BAA8B;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,8BAA8B;IAC9B,cAAc,EAAE,MAAM,CAAC;IACvB,uBAAuB;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,qCAAqC;IACrC,WAAW,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AAC,OAAO,EAAE,CAAC,KAAK,MAAM,GAAG,MAAM,CAAC;IAEzC;;;OAGG;IACH,UAAU,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,OAAO,CAAC;IAErC;;OAEG;IACH,eAAe,CAAC,EAAE,CAAC,EAAE,CAAC;CACvB;AAED;;GAEG;AACH,eAAO,MAAM,gBAAgB;IAC3B;;;;OAIG;sBACe,MAAM,GAAG,MAAM;IAOjC;;;OAGG;wBACiB,MAAM,GAAG,MAAM;IAUnC;;;OAGG;wBACiB,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM;IAI7C;;OAEG;sBACe,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO;CAGlE,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Disjoint Set (Union-Find) for ZenGrid
|
|
3
|
+
*/
|
|
4
|
+
export { DisjointSet } from './disjoint-set';
|
|
5
|
+
export type { IDisjointSet, DisjointSetOptions, DisjointSetStats, } from './disjoint-set.interface';
|
|
6
|
+
export { DisjointSetUtils } from './disjoint-set.interface';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/shared/data-structures/disjoint-set/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,YAAY,EACV,YAAY,EACZ,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC"}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IndexMap implementation
|
|
3
|
+
* Provides O(1) bidirectional lookup with maintained insertion order
|
|
4
|
+
*/
|
|
5
|
+
import type { IIndexMap, IndexMapEntry, IndexMapOptions } from './index-map.interface';
|
|
6
|
+
/**
|
|
7
|
+
* IndexMap - A hybrid data structure combining Map and Array benefits
|
|
8
|
+
*
|
|
9
|
+
* Features:
|
|
10
|
+
* - O(1) key → value lookup
|
|
11
|
+
* - O(1) index → entry lookup
|
|
12
|
+
* - O(1) key → index lookup
|
|
13
|
+
* - Optional O(1) value → key reverse lookup
|
|
14
|
+
* - Maintains insertion order
|
|
15
|
+
*
|
|
16
|
+
* Implementation:
|
|
17
|
+
* - Uses Map for key → {value, index} mapping
|
|
18
|
+
* - Uses Array for index → {key, value} mapping
|
|
19
|
+
* - Optional Map for value → key[] reverse mapping
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* const map = new IndexMap<string, number>();
|
|
24
|
+
* map.set('a', 1); // index 0
|
|
25
|
+
* map.set('b', 2); // index 1
|
|
26
|
+
* map.set('c', 3); // index 2
|
|
27
|
+
*
|
|
28
|
+
* map.get('b'); // 2
|
|
29
|
+
* map.getByIndex(1); // { key: 'b', value: 2, index: 1 }
|
|
30
|
+
* map.indexOf('c'); // 2
|
|
31
|
+
* map.getValueByIndex(0); // 1
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export declare class IndexMap<K, V> implements IIndexMap<K, V> {
|
|
35
|
+
private keyToData;
|
|
36
|
+
private indexToEntry;
|
|
37
|
+
private valueToKeys?;
|
|
38
|
+
private readonly reverseMapping;
|
|
39
|
+
constructor(options?: IndexMapOptions);
|
|
40
|
+
/**
|
|
41
|
+
* Set a key-value pair
|
|
42
|
+
*/
|
|
43
|
+
set(key: K, value: V): number;
|
|
44
|
+
/**
|
|
45
|
+
* Get value by key
|
|
46
|
+
*/
|
|
47
|
+
get(key: K): V | undefined;
|
|
48
|
+
/**
|
|
49
|
+
* Get entry by index
|
|
50
|
+
*/
|
|
51
|
+
getByIndex(index: number): IndexMapEntry<K, V> | undefined;
|
|
52
|
+
/**
|
|
53
|
+
* Get key by index
|
|
54
|
+
*/
|
|
55
|
+
getKeyByIndex(index: number): K | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* Get value by index
|
|
58
|
+
*/
|
|
59
|
+
getValueByIndex(index: number): V | undefined;
|
|
60
|
+
/**
|
|
61
|
+
* Get the index of a key
|
|
62
|
+
*/
|
|
63
|
+
indexOf(key: K): number;
|
|
64
|
+
/**
|
|
65
|
+
* Reverse lookup: get key(s) by value
|
|
66
|
+
*/
|
|
67
|
+
getKeysByValue(value: V): K[];
|
|
68
|
+
/**
|
|
69
|
+
* Check if a key exists
|
|
70
|
+
*/
|
|
71
|
+
has(key: K): boolean;
|
|
72
|
+
/**
|
|
73
|
+
* Check if a value exists
|
|
74
|
+
*/
|
|
75
|
+
hasValue(value: V): boolean;
|
|
76
|
+
/**
|
|
77
|
+
* Delete an entry by key
|
|
78
|
+
* Reindexes all subsequent entries
|
|
79
|
+
*/
|
|
80
|
+
delete(key: K): boolean;
|
|
81
|
+
/**
|
|
82
|
+
* Delete an entry by index
|
|
83
|
+
*/
|
|
84
|
+
deleteByIndex(index: number): boolean;
|
|
85
|
+
/**
|
|
86
|
+
* Clear all entries
|
|
87
|
+
*/
|
|
88
|
+
clear(): void;
|
|
89
|
+
/**
|
|
90
|
+
* Get all keys in insertion order
|
|
91
|
+
*/
|
|
92
|
+
keys(): K[];
|
|
93
|
+
/**
|
|
94
|
+
* Get all values in insertion order
|
|
95
|
+
*/
|
|
96
|
+
values(): V[];
|
|
97
|
+
/**
|
|
98
|
+
* Get all entries in insertion order
|
|
99
|
+
*/
|
|
100
|
+
entries(): [K, V][];
|
|
101
|
+
/**
|
|
102
|
+
* Iterate over entries
|
|
103
|
+
*/
|
|
104
|
+
forEach(callback: (value: V, key: K, index: number) => void): void;
|
|
105
|
+
/**
|
|
106
|
+
* Find the first key that satisfies a predicate
|
|
107
|
+
*/
|
|
108
|
+
find(predicate: (value: V, key: K, index: number) => boolean): K | undefined;
|
|
109
|
+
/**
|
|
110
|
+
* Filter entries by a predicate
|
|
111
|
+
*/
|
|
112
|
+
filter(predicate: (value: V, key: K, index: number) => boolean): IIndexMap<K, V>;
|
|
113
|
+
/**
|
|
114
|
+
* Map values to a new IndexMap
|
|
115
|
+
*/
|
|
116
|
+
map<U>(mapper: (value: V, key: K, index: number) => U): IIndexMap<K, U>;
|
|
117
|
+
/**
|
|
118
|
+
* Number of entries
|
|
119
|
+
*/
|
|
120
|
+
get size(): number;
|
|
121
|
+
/**
|
|
122
|
+
* Whether reverse mapping is enabled
|
|
123
|
+
*/
|
|
124
|
+
get hasReverseMapping(): boolean;
|
|
125
|
+
/**
|
|
126
|
+
* Create IndexMap from an array of entries
|
|
127
|
+
*/
|
|
128
|
+
static from<K, V>(entries: Iterable<[K, V]>, options?: IndexMapOptions): IndexMap<K, V>;
|
|
129
|
+
/**
|
|
130
|
+
* Create IndexMap from a regular Map
|
|
131
|
+
*/
|
|
132
|
+
static fromMap<K, V>(source: Map<K, V>, options?: IndexMapOptions): IndexMap<K, V>;
|
|
133
|
+
/**
|
|
134
|
+
* Create IndexMap from an object
|
|
135
|
+
*/
|
|
136
|
+
static fromObject<V>(obj: Record<string, V>, options?: IndexMapOptions): IndexMap<string, V>;
|
|
137
|
+
/**
|
|
138
|
+
* Convert to a plain object (only works with string keys)
|
|
139
|
+
*/
|
|
140
|
+
toObject(): Record<string, V>;
|
|
141
|
+
/**
|
|
142
|
+
* Convert to a regular Map
|
|
143
|
+
*/
|
|
144
|
+
toMap(): Map<K, V>;
|
|
145
|
+
/**
|
|
146
|
+
* Get a string representation for debugging
|
|
147
|
+
*/
|
|
148
|
+
toString(): string;
|
|
149
|
+
}
|
|
150
|
+
//# sourceMappingURL=index-map.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-map.d.ts","sourceRoot":"","sources":["../../../../../src/shared/data-structures/index-map/index-map.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAA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C,EAAE,CAAC,CAAC;IAIjB;;OAEG;IACH,MAAM,CAAC,UAAU,CAAC,CAAC,EACjB,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,EACtB,OAAO,CAAC,EAAE,eAAe,GACxB,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;IAQtB;;OAEG;IACH,QAAQ,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;IAQ7B;;OAEG;IACH,KAAK,IAAI,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC;IAIlB;;OAEG;IACH,QAAQ,IAAI,MAAM;CAKnB"}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IndexMap interfaces for ZenGrid
|
|
3
|
+
* Provides O(1) bidirectional lookup: key → value, index → entry, and optionally value → key
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Entry in the IndexMap containing both key and value
|
|
7
|
+
*/
|
|
8
|
+
export interface IndexMapEntry<K, V> {
|
|
9
|
+
key: K;
|
|
10
|
+
value: V;
|
|
11
|
+
index: number;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* IndexMap interface
|
|
15
|
+
*
|
|
16
|
+
* A data structure that combines the benefits of Map and Array:
|
|
17
|
+
* - O(1) key → value lookup (like Map)
|
|
18
|
+
* - O(1) index → entry lookup (like Array)
|
|
19
|
+
* - O(1) key → index lookup
|
|
20
|
+
* - Maintains insertion order
|
|
21
|
+
* - Optional O(1) value → key reverse lookup
|
|
22
|
+
*
|
|
23
|
+
* Use cases:
|
|
24
|
+
* - Column/row mappings where you need both name and index access
|
|
25
|
+
* - Ordered collections with fast lookup by both key and position
|
|
26
|
+
* - Maintaining insertion order while allowing random access
|
|
27
|
+
*/
|
|
28
|
+
export interface IIndexMap<K, V> {
|
|
29
|
+
/**
|
|
30
|
+
* Set a key-value pair
|
|
31
|
+
* If key exists, updates the value without changing index
|
|
32
|
+
* If key is new, appends to the end
|
|
33
|
+
* @param key - The key
|
|
34
|
+
* @param value - The value
|
|
35
|
+
* @returns The index of the entry
|
|
36
|
+
* @complexity O(1)
|
|
37
|
+
*/
|
|
38
|
+
set(key: K, value: V): number;
|
|
39
|
+
/**
|
|
40
|
+
* Get value by key
|
|
41
|
+
* @param key - The key to look up
|
|
42
|
+
* @returns The value or undefined if not found
|
|
43
|
+
* @complexity O(1)
|
|
44
|
+
*/
|
|
45
|
+
get(key: K): V | undefined;
|
|
46
|
+
/**
|
|
47
|
+
* Get entry by index
|
|
48
|
+
* @param index - The index (0-based)
|
|
49
|
+
* @returns The entry or undefined if out of bounds
|
|
50
|
+
* @complexity O(1)
|
|
51
|
+
*/
|
|
52
|
+
getByIndex(index: number): IndexMapEntry<K, V> | undefined;
|
|
53
|
+
/**
|
|
54
|
+
* Get key by index
|
|
55
|
+
* @param index - The index (0-based)
|
|
56
|
+
* @returns The key or undefined if out of bounds
|
|
57
|
+
* @complexity O(1)
|
|
58
|
+
*/
|
|
59
|
+
getKeyByIndex(index: number): K | undefined;
|
|
60
|
+
/**
|
|
61
|
+
* Get value by index
|
|
62
|
+
* @param index - The index (0-based)
|
|
63
|
+
* @returns The value or undefined if out of bounds
|
|
64
|
+
* @complexity O(1)
|
|
65
|
+
*/
|
|
66
|
+
getValueByIndex(index: number): V | undefined;
|
|
67
|
+
/**
|
|
68
|
+
* Get the index of a key
|
|
69
|
+
* @param key - The key to look up
|
|
70
|
+
* @returns The index or -1 if not found
|
|
71
|
+
* @complexity O(1)
|
|
72
|
+
*/
|
|
73
|
+
indexOf(key: K): number;
|
|
74
|
+
/**
|
|
75
|
+
* Get the key(s) for a given value (reverse lookup)
|
|
76
|
+
* Only available when enableReverseMapping is true
|
|
77
|
+
* @param value - The value to find
|
|
78
|
+
* @returns Array of keys that map to this value (empty if not found or reverse mapping disabled)
|
|
79
|
+
* @complexity O(1) if reverse mapping enabled, O(n) if disabled
|
|
80
|
+
*/
|
|
81
|
+
getKeysByValue(value: V): K[];
|
|
82
|
+
/**
|
|
83
|
+
* Check if a key exists
|
|
84
|
+
* @param key - The key to check
|
|
85
|
+
* @complexity O(1)
|
|
86
|
+
*/
|
|
87
|
+
has(key: K): boolean;
|
|
88
|
+
/**
|
|
89
|
+
* Check if a value exists
|
|
90
|
+
* @param value - The value to check
|
|
91
|
+
* @complexity O(1) if reverse mapping enabled, O(n) if disabled
|
|
92
|
+
*/
|
|
93
|
+
hasValue(value: V): boolean;
|
|
94
|
+
/**
|
|
95
|
+
* Delete an entry by key
|
|
96
|
+
* Reindexes all subsequent entries
|
|
97
|
+
* @param key - The key to delete
|
|
98
|
+
* @returns true if the entry existed and was deleted
|
|
99
|
+
* @complexity O(n) due to reindexing
|
|
100
|
+
*/
|
|
101
|
+
delete(key: K): boolean;
|
|
102
|
+
/**
|
|
103
|
+
* Delete an entry by index
|
|
104
|
+
* Reindexes all subsequent entries
|
|
105
|
+
* @param index - The index to delete
|
|
106
|
+
* @returns true if the index was valid and entry was deleted
|
|
107
|
+
* @complexity O(n) due to reindexing
|
|
108
|
+
*/
|
|
109
|
+
deleteByIndex(index: number): boolean;
|
|
110
|
+
/**
|
|
111
|
+
* Clear all entries
|
|
112
|
+
* @complexity O(1)
|
|
113
|
+
*/
|
|
114
|
+
clear(): void;
|
|
115
|
+
/**
|
|
116
|
+
* Get all keys in insertion order
|
|
117
|
+
* @returns Array of keys
|
|
118
|
+
* @complexity O(n)
|
|
119
|
+
*/
|
|
120
|
+
keys(): K[];
|
|
121
|
+
/**
|
|
122
|
+
* Get all values in insertion order
|
|
123
|
+
* @returns Array of values
|
|
124
|
+
* @complexity O(n)
|
|
125
|
+
*/
|
|
126
|
+
values(): V[];
|
|
127
|
+
/**
|
|
128
|
+
* Get all entries in insertion order
|
|
129
|
+
* @returns Array of [key, value] tuples
|
|
130
|
+
* @complexity O(n)
|
|
131
|
+
*/
|
|
132
|
+
entries(): [K, V][];
|
|
133
|
+
/**
|
|
134
|
+
* Iterate over entries
|
|
135
|
+
* @param callback - Function to call for each entry
|
|
136
|
+
* @complexity O(n)
|
|
137
|
+
*/
|
|
138
|
+
forEach(callback: (value: V, key: K, index: number) => void): void;
|
|
139
|
+
/**
|
|
140
|
+
* Find the first key that satisfies a predicate
|
|
141
|
+
* @param predicate - Test function
|
|
142
|
+
* @returns The key or undefined
|
|
143
|
+
* @complexity O(n)
|
|
144
|
+
*/
|
|
145
|
+
find(predicate: (value: V, key: K, index: number) => boolean): K | undefined;
|
|
146
|
+
/**
|
|
147
|
+
* Filter entries by a predicate
|
|
148
|
+
* @param predicate - Test function
|
|
149
|
+
* @returns New IndexMap with entries that pass the test
|
|
150
|
+
* @complexity O(n)
|
|
151
|
+
*/
|
|
152
|
+
filter(predicate: (value: V, key: K, index: number) => boolean): IIndexMap<K, V>;
|
|
153
|
+
/**
|
|
154
|
+
* Map values to a new IndexMap
|
|
155
|
+
* @param mapper - Transform function
|
|
156
|
+
* @returns New IndexMap with transformed values
|
|
157
|
+
* @complexity O(n)
|
|
158
|
+
*/
|
|
159
|
+
map<U>(mapper: (value: V, key: K, index: number) => U): IIndexMap<K, U>;
|
|
160
|
+
/**
|
|
161
|
+
* Number of entries
|
|
162
|
+
*/
|
|
163
|
+
readonly size: number;
|
|
164
|
+
/**
|
|
165
|
+
* Whether reverse value → key mapping is enabled
|
|
166
|
+
*/
|
|
167
|
+
readonly hasReverseMapping: boolean;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Options for creating an IndexMap
|
|
171
|
+
*/
|
|
172
|
+
export interface IndexMapOptions {
|
|
173
|
+
/**
|
|
174
|
+
* Enable bidirectional value → key lookup
|
|
175
|
+
* Maintains a reverse map for O(1) value → key queries
|
|
176
|
+
* Increases memory usage but enables fast reverse lookups
|
|
177
|
+
* @default false
|
|
178
|
+
*/
|
|
179
|
+
enableReverseMapping?: boolean;
|
|
180
|
+
/**
|
|
181
|
+
* Initial capacity hint for optimization
|
|
182
|
+
* @default 16
|
|
183
|
+
*/
|
|
184
|
+
initialCapacity?: number;
|
|
185
|
+
}
|
|
186
|
+
//# sourceMappingURL=index-map.interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-map.interface.d.ts","sourceRoot":"","sources":["../../../../../src/shared/data-structures/index-map/index-map.interface.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,MAAM,WAAW,aAAa,CAAC,CAAC,EAAE,CAAC;IACjC,GAAG,EAAE,CAAC,CAAC;IACP,KAAK,EAAE,CAAC,CAAC;IACT,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,SAAS,CAAC,CAAC,EAAE,CAAC;IAC7B;;;;;;;;OAQG;IACH,GAAG,CAAC,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,MAAM,CAAC;IAE9B;;;;;OAKG;IACH,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC;IAE3B;;;;;OAKG;IACH,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,SAAS,CAAC;IAE3D;;;;;OAKG;IACH,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS,CAAC;IAE5C;;;;;OAKG;IACH,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS,CAAC;IAE9C;;;;;OAKG;IACH,OAAO,CAAC,GAAG,EAAE,CAAC,GAAG,MAAM,CAAC;IAExB;;;;;;OAMG;IACH,cAAc,CAAC,KAAK,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC;IAE9B;;;;OAIG;IACH,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,OAAO,CAAC;IAErB;;;;OAIG;IACH,QAAQ,CAAC,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC;IAE5B;;;;;;OAMG;IACH,MAAM,CAAC,GAAG,EAAE,CAAC,GAAG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