@zengrid/shared 1.0.3 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/dist/README.md +48 -0
- package/dist/index.cjs.default.js +1 -0
- package/dist/index.cjs.js +8696 -0
- package/dist/index.cjs.mjs +2 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.esm.js +8640 -0
- package/dist/package.json +54 -0
- package/dist/src/algorithms/filter/bloom-filter.d.ts +120 -0
- package/dist/src/algorithms/filter/bloom-filter.d.ts.map +1 -0
- package/dist/src/algorithms/filter/index.d.ts +7 -0
- package/dist/src/algorithms/filter/index.d.ts.map +1 -0
- package/dist/src/algorithms/graph/bfs.d.ts +71 -0
- package/dist/src/algorithms/graph/bfs.d.ts.map +1 -0
- package/dist/src/algorithms/graph/dfs.d.ts +62 -0
- package/dist/src/algorithms/graph/dfs.d.ts.map +1 -0
- package/dist/src/algorithms/graph/graph.interface.d.ts +63 -0
- package/dist/src/algorithms/graph/graph.interface.d.ts.map +1 -0
- package/dist/src/algorithms/graph/index.d.ts +9 -0
- package/dist/src/algorithms/graph/index.d.ts.map +1 -0
- package/dist/src/algorithms/index.d.ts +11 -0
- package/dist/src/algorithms/index.d.ts.map +1 -0
- package/dist/src/algorithms/pattern/index.d.ts +8 -0
- package/dist/src/algorithms/pattern/index.d.ts.map +1 -0
- package/dist/src/algorithms/pattern/sequence-detector.d.ts +62 -0
- package/dist/src/algorithms/pattern/sequence-detector.d.ts.map +1 -0
- package/dist/src/algorithms/search/binary-search.d.ts +86 -0
- package/dist/src/algorithms/search/binary-search.d.ts.map +1 -0
- package/dist/src/algorithms/search/index.d.ts +6 -0
- package/dist/src/algorithms/search/index.d.ts.map +1 -0
- package/dist/src/algorithms/sorting/comparators.d.ts +126 -0
- package/dist/src/algorithms/sorting/comparators.d.ts.map +1 -0
- package/dist/src/algorithms/sorting/index.d.ts +9 -0
- package/dist/src/algorithms/sorting/index.d.ts.map +1 -0
- package/dist/src/algorithms/sorting/sorting.interface.d.ts +38 -0
- package/dist/src/algorithms/sorting/sorting.interface.d.ts.map +1 -0
- package/dist/src/algorithms/sorting/timsort-gallop.d.ts +21 -0
- package/dist/src/algorithms/sorting/timsort-gallop.d.ts.map +1 -0
- package/dist/src/algorithms/sorting/timsort-merge.d.ts +6 -0
- package/dist/src/algorithms/sorting/timsort-merge.d.ts.map +1 -0
- package/dist/src/algorithms/sorting/timsort-run.d.ts +38 -0
- package/dist/src/algorithms/sorting/timsort-run.d.ts.map +1 -0
- package/dist/src/algorithms/sorting/timsort.d.ts +55 -0
- package/dist/src/algorithms/sorting/timsort.d.ts.map +1 -0
- package/dist/src/algorithms/sorting/timsort.interface.d.ts +32 -0
- package/dist/src/algorithms/sorting/timsort.interface.d.ts.map +1 -0
- package/dist/src/data-structures/column-store/column-store.d.ts +52 -0
- package/dist/src/data-structures/column-store/column-store.d.ts.map +1 -0
- package/dist/src/data-structures/column-store/column-store.interface.d.ts +155 -0
- package/dist/src/data-structures/column-store/column-store.interface.d.ts.map +1 -0
- package/dist/src/data-structures/column-store/index.d.ts +6 -0
- package/dist/src/data-structures/column-store/index.d.ts.map +1 -0
- package/dist/src/data-structures/command-stack/command-stack.d.ts +61 -0
- package/dist/src/data-structures/command-stack/command-stack.d.ts.map +1 -0
- package/dist/src/data-structures/command-stack/command-stack.interface.d.ts +80 -0
- package/dist/src/data-structures/command-stack/command-stack.interface.d.ts.map +1 -0
- package/dist/src/data-structures/command-stack/index.d.ts +3 -0
- package/dist/src/data-structures/command-stack/index.d.ts.map +1 -0
- package/dist/src/data-structures/dependency-graph/dependency-graph.d.ts +147 -0
- package/dist/src/data-structures/dependency-graph/dependency-graph.d.ts.map +1 -0
- package/dist/src/data-structures/dependency-graph/dependency-graph.interface.d.ts +161 -0
- package/dist/src/data-structures/dependency-graph/dependency-graph.interface.d.ts.map +1 -0
- package/dist/src/data-structures/dependency-graph/index.d.ts +8 -0
- package/dist/src/data-structures/dependency-graph/index.d.ts.map +1 -0
- package/dist/src/data-structures/disjoint-set/disjoint-set.d.ts +84 -0
- package/dist/src/data-structures/disjoint-set/disjoint-set.d.ts.map +1 -0
- package/dist/src/data-structures/disjoint-set/disjoint-set.interface.d.ts +185 -0
- package/dist/src/data-structures/disjoint-set/disjoint-set.interface.d.ts.map +1 -0
- package/dist/src/data-structures/disjoint-set/index.d.ts +7 -0
- package/dist/src/data-structures/disjoint-set/index.d.ts.map +1 -0
- package/dist/src/data-structures/index-map/index-map.d.ts +150 -0
- package/dist/src/data-structures/index-map/index-map.d.ts.map +1 -0
- package/dist/src/data-structures/index-map/index-map.interface.d.ts +186 -0
- package/dist/src/data-structures/index-map/index-map.interface.d.ts.map +1 -0
- package/dist/src/data-structures/index-map/index.d.ts +6 -0
- package/dist/src/data-structures/index-map/index.d.ts.map +1 -0
- package/dist/src/data-structures/index.d.ts +36 -0
- package/dist/src/data-structures/index.d.ts.map +1 -0
- package/dist/src/data-structures/interval-tree/index.d.ts +7 -0
- package/dist/src/data-structures/interval-tree/index.d.ts.map +1 -0
- package/dist/src/data-structures/interval-tree/interval-tree.d.ts +58 -0
- package/dist/src/data-structures/interval-tree/interval-tree.d.ts.map +1 -0
- package/dist/src/data-structures/interval-tree/interval-tree.interface.d.ts +212 -0
- package/dist/src/data-structures/interval-tree/interval-tree.interface.d.ts.map +1 -0
- package/dist/src/data-structures/interval-tree/node.d.ts +34 -0
- package/dist/src/data-structures/interval-tree/node.d.ts.map +1 -0
- package/dist/src/data-structures/interval-tree/operations/balance.d.ts +34 -0
- package/dist/src/data-structures/interval-tree/operations/balance.d.ts.map +1 -0
- package/dist/src/data-structures/interval-tree/operations/delete.d.ts +26 -0
- package/dist/src/data-structures/interval-tree/operations/delete.d.ts.map +1 -0
- package/dist/src/data-structures/interval-tree/operations/insert.d.ts +19 -0
- package/dist/src/data-structures/interval-tree/operations/insert.d.ts.map +1 -0
- package/dist/src/data-structures/interval-tree/operations/search.d.ts +46 -0
- package/dist/src/data-structures/interval-tree/operations/search.d.ts.map +1 -0
- package/dist/src/data-structures/interval-tree/operations/traversal.d.ts +29 -0
- package/dist/src/data-structures/interval-tree/operations/traversal.d.ts.map +1 -0
- package/dist/src/data-structures/interval-tree/operations/utilities.d.ts +30 -0
- package/dist/src/data-structures/interval-tree/operations/utilities.d.ts.map +1 -0
- package/dist/src/data-structures/lru-cache/index.d.ts +3 -0
- package/dist/src/data-structures/lru-cache/index.d.ts.map +1 -0
- package/dist/src/data-structures/lru-cache/lru-cache.d.ts +134 -0
- package/dist/src/data-structures/lru-cache/lru-cache.d.ts.map +1 -0
- package/dist/src/data-structures/lru-cache/lru-cache.interface.d.ts +173 -0
- package/dist/src/data-structures/lru-cache/lru-cache.interface.d.ts.map +1 -0
- package/dist/src/data-structures/prefix-sum-array/index.d.ts +6 -0
- package/dist/src/data-structures/prefix-sum-array/index.d.ts.map +1 -0
- package/dist/src/data-structures/prefix-sum-array/prefix-sum-array.d.ts +63 -0
- package/dist/src/data-structures/prefix-sum-array/prefix-sum-array.d.ts.map +1 -0
- package/dist/src/data-structures/prefix-sum-array/prefix-sum-array.interface.d.ts +80 -0
- package/dist/src/data-structures/prefix-sum-array/prefix-sum-array.interface.d.ts.map +1 -0
- package/dist/src/data-structures/ring-buffer.d.ts +96 -0
- package/dist/src/data-structures/ring-buffer.d.ts.map +1 -0
- package/dist/src/data-structures/rtree/index.d.ts +8 -0
- package/dist/src/data-structures/rtree/index.d.ts.map +1 -0
- package/dist/src/data-structures/rtree/rtree.d.ts +81 -0
- package/dist/src/data-structures/rtree/rtree.d.ts.map +1 -0
- package/dist/src/data-structures/rtree/rtree.interface.d.ts +143 -0
- package/dist/src/data-structures/rtree/rtree.interface.d.ts.map +1 -0
- package/dist/src/data-structures/segment-tree/aggregation-config.d.ts +6 -0
- package/dist/src/data-structures/segment-tree/aggregation-config.d.ts.map +1 -0
- package/dist/src/data-structures/segment-tree/index.d.ts +4 -0
- package/dist/src/data-structures/segment-tree/index.d.ts.map +1 -0
- package/dist/src/data-structures/segment-tree/lazy-propagation.d.ts +5 -0
- package/dist/src/data-structures/segment-tree/lazy-propagation.d.ts.map +1 -0
- package/dist/src/data-structures/segment-tree/segment-tree.d.ts +30 -0
- package/dist/src/data-structures/segment-tree/segment-tree.d.ts.map +1 -0
- package/dist/src/data-structures/segment-tree/segment-tree.interface.d.ts +202 -0
- package/dist/src/data-structures/segment-tree/segment-tree.interface.d.ts.map +1 -0
- package/dist/src/data-structures/segment-tree/tree-builder.d.ts +3 -0
- package/dist/src/data-structures/segment-tree/tree-builder.d.ts.map +1 -0
- package/dist/src/data-structures/segment-tree/tree-query.d.ts +3 -0
- package/dist/src/data-structures/segment-tree/tree-query.d.ts.map +1 -0
- package/dist/src/data-structures/segment-tree/tree-search.d.ts +2 -0
- package/dist/src/data-structures/segment-tree/tree-search.d.ts.map +1 -0
- package/dist/src/data-structures/segment-tree/tree-update.d.ts +4 -0
- package/dist/src/data-structures/segment-tree/tree-update.d.ts.map +1 -0
- package/dist/src/data-structures/segment-tree/tree-validation.d.ts +3 -0
- package/dist/src/data-structures/segment-tree/tree-validation.d.ts.map +1 -0
- package/dist/src/data-structures/skip-list/index.d.ts +4 -0
- package/dist/src/data-structures/skip-list/index.d.ts.map +1 -0
- package/dist/src/data-structures/skip-list/skip-list.d.ts +137 -0
- package/dist/src/data-structures/skip-list/skip-list.d.ts.map +1 -0
- package/dist/src/data-structures/skip-list/skip-list.interface.d.ts +223 -0
- package/dist/src/data-structures/skip-list/skip-list.interface.d.ts.map +1 -0
- package/dist/src/data-structures/sparse-matrix/index.d.ts +6 -0
- package/dist/src/data-structures/sparse-matrix/index.d.ts.map +1 -0
- package/dist/src/data-structures/sparse-matrix/sparse-matrix.d.ts +44 -0
- package/dist/src/data-structures/sparse-matrix/sparse-matrix.d.ts.map +1 -0
- package/dist/src/data-structures/sparse-matrix/sparse-matrix.interface.d.ts +105 -0
- package/dist/src/data-structures/sparse-matrix/sparse-matrix.interface.d.ts.map +1 -0
- package/dist/src/data-structures/suffix-array/index.d.ts +3 -0
- package/dist/src/data-structures/suffix-array/index.d.ts.map +1 -0
- package/dist/src/data-structures/suffix-array/suffix-array.d.ts +102 -0
- package/dist/src/data-structures/suffix-array/suffix-array.d.ts.map +1 -0
- package/dist/src/data-structures/suffix-array/suffix-array.interface.d.ts +117 -0
- package/dist/src/data-structures/suffix-array/suffix-array.interface.d.ts.map +1 -0
- package/dist/src/data-structures/trie/index.d.ts +8 -0
- package/dist/src/data-structures/trie/index.d.ts.map +1 -0
- package/dist/src/data-structures/trie/trie.d.ts +205 -0
- package/dist/src/data-structures/trie/trie.d.ts.map +1 -0
- package/dist/src/data-structures/trie/trie.interface.d.ts +117 -0
- package/dist/src/data-structures/trie/trie.interface.d.ts.map +1 -0
- package/dist/src/index.d.ts +54 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/patterns/coordinator.d.ts +90 -0
- package/dist/src/patterns/coordinator.d.ts.map +1 -0
- package/dist/src/patterns/event-emitter.d.ts +106 -0
- package/dist/src/patterns/event-emitter.d.ts.map +1 -0
- package/dist/src/patterns/factory.d.ts +120 -0
- package/dist/src/patterns/factory.d.ts.map +1 -0
- package/dist/src/patterns/index.d.ts +21 -0
- package/dist/src/patterns/index.d.ts.map +1 -0
- package/dist/src/patterns/mediator.d.ts +116 -0
- package/dist/src/patterns/mediator.d.ts.map +1 -0
- package/dist/src/patterns/object-pool.d.ts +178 -0
- package/dist/src/patterns/object-pool.d.ts.map +1 -0
- package/dist/src/patterns/observer.d.ts +89 -0
- package/dist/src/patterns/observer.d.ts.map +1 -0
- package/dist/src/patterns/operation-mode.d.ts +75 -0
- package/dist/src/patterns/operation-mode.d.ts.map +1 -0
- package/dist/src/patterns/state-machine.d.ts +122 -0
- package/dist/src/patterns/state-machine.d.ts.map +1 -0
- package/dist/src/reactive/batch-processor.d.ts +80 -0
- package/dist/src/reactive/batch-processor.d.ts.map +1 -0
- package/dist/src/reactive/core/batch-manager.d.ts +48 -0
- package/dist/src/reactive/core/batch-manager.d.ts.map +1 -0
- package/dist/src/reactive/core/batch-queue.d.ts +39 -0
- package/dist/src/reactive/core/batch-queue.d.ts.map +1 -0
- package/dist/src/reactive/core/event-handler-registry.d.ts +52 -0
- package/dist/src/reactive/core/event-handler-registry.d.ts.map +1 -0
- package/dist/src/reactive/core/event-mapper.d.ts +37 -0
- package/dist/src/reactive/core/event-mapper.d.ts.map +1 -0
- package/dist/src/reactive/core/pool-stats.d.ts +47 -0
- package/dist/src/reactive/core/pool-stats.d.ts.map +1 -0
- package/dist/src/reactive/core/subscription-manager.d.ts +46 -0
- package/dist/src/reactive/core/subscription-manager.d.ts.map +1 -0
- package/dist/src/reactive/event-delegator.d.ts +84 -0
- package/dist/src/reactive/event-delegator.d.ts.map +1 -0
- package/dist/src/reactive/index.d.ts +61 -0
- package/dist/src/reactive/index.d.ts.map +1 -0
- package/dist/src/reactive/interfaces.d.ts +207 -0
- package/dist/src/reactive/interfaces.d.ts.map +1 -0
- package/dist/src/reactive/object-pool.d.ts +97 -0
- package/dist/src/reactive/object-pool.d.ts.map +1 -0
- package/dist/src/reactive/reactive-state.d.ts +132 -0
- package/dist/src/reactive/reactive-state.d.ts.map +1 -0
- package/dist/src/types/common.d.ts +56 -0
- package/dist/src/types/common.d.ts.map +1 -0
- package/dist/src/types/index.d.ts +5 -0
- package/dist/src/types/index.d.ts.map +1 -0
- package/dist/src/utils/index.d.ts +7 -0
- package/dist/src/utils/index.d.ts.map +1 -0
- package/dist/src/utils/timing.d.ts +104 -0
- package/dist/src/utils/timing.d.ts.map +1 -0
- package/dist/src/utils/timing.interface.d.ts +96 -0
- package/dist/src/utils/timing.interface.d.ts.map +1 -0
- package/package.json +52 -52
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import type { Comparator } from '../../types/common';
|
|
2
|
+
import type { NullPosition } from './sorting.interface';
|
|
3
|
+
/**
|
|
4
|
+
* Options for string comparator
|
|
5
|
+
*/
|
|
6
|
+
export interface StringComparatorOptions {
|
|
7
|
+
/** Case-insensitive comparison */
|
|
8
|
+
caseInsensitive?: boolean;
|
|
9
|
+
/** Use locale-aware comparison */
|
|
10
|
+
localeCompare?: boolean;
|
|
11
|
+
/** Locale for comparison (e.g., 'en-US') */
|
|
12
|
+
locale?: string;
|
|
13
|
+
/** Where to place null/undefined values */
|
|
14
|
+
nullPosition?: NullPosition;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Create a numeric comparator
|
|
18
|
+
*
|
|
19
|
+
* @param nullPosition - Where to place null values in sort order
|
|
20
|
+
* @returns Comparator function
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* const numbers = [3, null, 1, undefined, 2];
|
|
25
|
+
* numbers.sort(numericComparator('last'));
|
|
26
|
+
* // [1, 2, 3, null, undefined]
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export declare function numericComparator(nullPosition?: NullPosition): Comparator<any>;
|
|
30
|
+
/**
|
|
31
|
+
* Create a string comparator
|
|
32
|
+
*
|
|
33
|
+
* @param options - Comparator options
|
|
34
|
+
* @returns Comparator function
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```typescript
|
|
38
|
+
* const names = ['Bob', 'alice', 'Charlie'];
|
|
39
|
+
* names.sort(stringComparator({ caseInsensitive: true }));
|
|
40
|
+
* // ['alice', 'Bob', 'Charlie']
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
export declare function stringComparator(options?: StringComparatorOptions): Comparator<any>;
|
|
44
|
+
/**
|
|
45
|
+
* Create a date comparator
|
|
46
|
+
*
|
|
47
|
+
* @param nullPosition - Where to place null values
|
|
48
|
+
* @returns Comparator function
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```typescript
|
|
52
|
+
* const dates = [new Date('2023-01-15'), null, new Date('2023-01-01')];
|
|
53
|
+
* dates.sort(dateComparator('last'));
|
|
54
|
+
* // [2023-01-01, 2023-01-15, null]
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export declare function dateComparator(nullPosition?: NullPosition): Comparator<any>;
|
|
58
|
+
/**
|
|
59
|
+
* Create a boolean comparator (false < true)
|
|
60
|
+
*
|
|
61
|
+
* @param nullPosition - Where to place null values
|
|
62
|
+
* @returns Comparator function
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```typescript
|
|
66
|
+
* const values = [true, null, false, true];
|
|
67
|
+
* values.sort(booleanComparator('last'));
|
|
68
|
+
* // [false, true, true, null]
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
export declare function booleanComparator(nullPosition?: NullPosition): Comparator<any>;
|
|
72
|
+
/**
|
|
73
|
+
* Auto-detect type and create appropriate comparator
|
|
74
|
+
*
|
|
75
|
+
* @param sampleValues - Sample values to detect type from
|
|
76
|
+
* @param options - Options for the comparator
|
|
77
|
+
* @returns Comparator function
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* ```typescript
|
|
81
|
+
* const data = [3, 1, 4, 1, 5];
|
|
82
|
+
* data.sort(autoComparator(data));
|
|
83
|
+
* // [1, 1, 3, 4, 5] - numeric comparison
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
export declare function autoComparator(sampleValues: any[], options?: {
|
|
87
|
+
nullPosition?: NullPosition;
|
|
88
|
+
}): Comparator<any>;
|
|
89
|
+
/**
|
|
90
|
+
* Reverse a comparator (ascending to descending)
|
|
91
|
+
*
|
|
92
|
+
* @param comparator - Comparator to reverse
|
|
93
|
+
* @returns Reversed comparator
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* ```typescript
|
|
97
|
+
* const desc = reverseComparator(numericComparator());
|
|
98
|
+
* [1, 2, 3].sort(desc);
|
|
99
|
+
* // [3, 2, 1]
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
export declare function reverseComparator<T>(comparator: Comparator<T>): Comparator<T>;
|
|
103
|
+
/**
|
|
104
|
+
* Chain multiple comparators (for multi-column sort)
|
|
105
|
+
*
|
|
106
|
+
* @param comparators - Comparators in priority order
|
|
107
|
+
* @returns Chained comparator
|
|
108
|
+
*
|
|
109
|
+
* @example
|
|
110
|
+
* ```typescript
|
|
111
|
+
* // Sort by age, then by name
|
|
112
|
+
* const data = [
|
|
113
|
+
* { age: 30, name: 'Bob' },
|
|
114
|
+
* { age: 25, name: 'Alice' },
|
|
115
|
+
* { age: 30, name: 'Charlie' }
|
|
116
|
+
* ];
|
|
117
|
+
*
|
|
118
|
+
* data.sort(chainComparators(
|
|
119
|
+
* (a, b) => a.age - b.age,
|
|
120
|
+
* (a, b) => a.name.localeCompare(b.name)
|
|
121
|
+
* ));
|
|
122
|
+
* // Alice (25), Bob (30), Charlie (30)
|
|
123
|
+
* ```
|
|
124
|
+
*/
|
|
125
|
+
export declare function chainComparators<T>(...comparators: Comparator<T>[]): Comparator<T>;
|
|
126
|
+
//# sourceMappingURL=comparators.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"comparators.d.ts","sourceRoot":"","sources":["../../../../src/algorithms/sorting/comparators.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAExD;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,kCAAkC;IAClC,eAAe,CAAC,EAAE,OAAO,CAAC;IAE1B,kCAAkC;IAClC,aAAa,CAAC,EAAE,OAAO,CAAC;IAExB,4CAA4C;IAC5C,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,2CAA2C;IAC3C,YAAY,CAAC,EAAE,YAAY,CAAC;CAC7B;AA2BD;;;;;;;;;;;;GAYG;AACH,wBAAgB,iBAAiB,CAAC,YAAY,GAAE,YAAqB,GAAG,UAAU,CAAC,GAAG,CAAC,CAatF;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,GAAE,uBAA4B,GAAG,UAAU,CAAC,GAAG,CAAC,CAyBvF;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,CAAC,YAAY,GAAE,YAAqB,GAAG,UAAU,CAAC,GAAG,CAAC,CAgBnF;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,iBAAiB,CAAC,YAAY,GAAE,YAAqB,GAAG,UAAU,CAAC,GAAG,CAAC,CAQtF;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,cAAc,CAC5B,YAAY,EAAE,GAAG,EAAE,EACnB,OAAO,GAAE;IAAE,YAAY,CAAC,EAAE,YAAY,CAAA;CAAO,GAC5C,UAAU,CAAC,GAAG,CAAC,CAyBjB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,CAE7E;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,GAAG,WAAW,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,GAAG,UAAU,CAAC,CAAC,CAAC,CAUlF"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sorting algorithms and comparators
|
|
3
|
+
* @packageDocumentation
|
|
4
|
+
*/
|
|
5
|
+
export type { NullPosition, TimsortOptions, SortMetadata } from './sorting.interface';
|
|
6
|
+
export { numericComparator, stringComparator, dateComparator, booleanComparator, autoComparator, reverseComparator, chainComparators, } from './comparators';
|
|
7
|
+
export type { StringComparatorOptions } from './comparators';
|
|
8
|
+
export { timsort, timsortIndices, isSorted } from './timsort';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/algorithms/sorting/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,YAAY,EAAE,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEtF,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,EACd,iBAAiB,EACjB,cAAc,EACd,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,eAAe,CAAC;AAEvB,YAAY,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAE7D,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Position for null/undefined values in sort order
|
|
3
|
+
*/
|
|
4
|
+
export type NullPosition = 'first' | 'last' | 'natural';
|
|
5
|
+
/**
|
|
6
|
+
* Options for Timsort algorithm
|
|
7
|
+
*/
|
|
8
|
+
export interface TimsortOptions {
|
|
9
|
+
/**
|
|
10
|
+
* Minimum run length for merge sort
|
|
11
|
+
* Smaller values = more merges, larger values = more insertions
|
|
12
|
+
* Default: 32 (optimal for most cases)
|
|
13
|
+
*/
|
|
14
|
+
minRun?: number;
|
|
15
|
+
/**
|
|
16
|
+
* Whether to use stable sorting
|
|
17
|
+
* Default: true
|
|
18
|
+
*/
|
|
19
|
+
stable?: boolean;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Result of a sort operation with metadata
|
|
23
|
+
*/
|
|
24
|
+
export interface SortMetadata {
|
|
25
|
+
/**
|
|
26
|
+
* Time taken in milliseconds
|
|
27
|
+
*/
|
|
28
|
+
duration: number;
|
|
29
|
+
/**
|
|
30
|
+
* Number of comparisons performed
|
|
31
|
+
*/
|
|
32
|
+
comparisons?: number;
|
|
33
|
+
/**
|
|
34
|
+
* Number of swaps/moves performed
|
|
35
|
+
*/
|
|
36
|
+
swaps?: number;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=sorting.interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sorting.interface.d.ts","sourceRoot":"","sources":["../../../../src/algorithms/sorting/sorting.interface.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,CAAC;AAExD;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Comparator } from '../../types/common';
|
|
2
|
+
/**
|
|
3
|
+
* Gallop right: Find position where key belongs in array[base:base+len]
|
|
4
|
+
* Returns offset k where array[base+k-1] < key <= array[base+k]
|
|
5
|
+
* Uses exponential search followed by binary search
|
|
6
|
+
*/
|
|
7
|
+
export declare function gallopRight<T>(key: T, array: T[], base: number, len: number, hint: number, comparator: Comparator<T>): number;
|
|
8
|
+
/**
|
|
9
|
+
* Gallop left: Like gallopRight, but finds position where key < array[base+k]
|
|
10
|
+
*/
|
|
11
|
+
export declare function gallopLeft<T>(key: T, array: T[], base: number, len: number, hint: number, comparator: Comparator<T>): number;
|
|
12
|
+
/**
|
|
13
|
+
* Gallop right in a generic array (for temporary buffer)
|
|
14
|
+
* Find position where key belongs in arr[base:base+len]
|
|
15
|
+
*/
|
|
16
|
+
export declare function gallopRightInArray<T>(key: T, arr: T[], base: number, len: number, hint: number, comparator: Comparator<T>): number;
|
|
17
|
+
/**
|
|
18
|
+
* Gallop left in a generic array (for temporary buffer)
|
|
19
|
+
*/
|
|
20
|
+
export declare function gallopLeftInArray<T>(key: T, arr: T[], base: number, len: number, hint: number, comparator: Comparator<T>): number;
|
|
21
|
+
//# sourceMappingURL=timsort-gallop.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timsort-gallop.d.ts","sourceRoot":"","sources":["../../../../src/algorithms/sorting/timsort-gallop.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErD;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAC3B,GAAG,EAAE,CAAC,EACN,KAAK,EAAE,CAAC,EAAE,EACV,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC,GACxB,MAAM,CA6CR;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAC1B,GAAG,EAAE,CAAC,EACN,KAAK,EAAE,CAAC,EAAE,EACV,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC,GACxB,MAAM,CAwCR;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAClC,GAAG,EAAE,CAAC,EACN,GAAG,EAAE,CAAC,EAAE,EACR,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC,GACxB,MAAM,CAwCR;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EACjC,GAAG,EAAE,CAAC,EACN,GAAG,EAAE,CAAC,EAAE,EACR,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC,GACxB,MAAM,CAwCR"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { TimsortState } from './timsort.interface';
|
|
2
|
+
/**
|
|
3
|
+
* Merge two adjacent runs with galloping optimization
|
|
4
|
+
*/
|
|
5
|
+
export declare function mergeRuns<T>(state: TimsortState<T>, base1: number, len1: number, base2: number, len2: number): void;
|
|
6
|
+
//# sourceMappingURL=timsort-merge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timsort-merge.d.ts","sourceRoot":"","sources":["../../../../src/algorithms/sorting/timsort-merge.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAIxD;;GAEG;AACH,wBAAgB,SAAS,CAAC,CAAC,EACzB,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,EACtB,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,GACX,IAAI,CAgCN"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { Comparator } from '../../types/common';
|
|
2
|
+
import type { Run, TimsortState } from './timsort.interface';
|
|
3
|
+
/**
|
|
4
|
+
* Count length of run starting at lo and reverse if descending
|
|
5
|
+
* Returns length of run (at least 2 if array has 2+ elements)
|
|
6
|
+
*/
|
|
7
|
+
export declare function countRunAndMakeAscending<T>(array: T[], lo: number, comparator: Comparator<T>): number;
|
|
8
|
+
/**
|
|
9
|
+
* Reverse array[lo:hi]
|
|
10
|
+
*/
|
|
11
|
+
export declare function reverseRange<T>(array: T[], lo: number, hi: number): void;
|
|
12
|
+
/**
|
|
13
|
+
* Binary insertion sort - more efficient than regular insertion sort
|
|
14
|
+
* Sorts array[lo:hi] where array[lo:start] is already sorted
|
|
15
|
+
*/
|
|
16
|
+
export declare function binaryInsertionSort<T>(array: T[], lo: number, hi: number, start: number, comparator: Comparator<T>): void;
|
|
17
|
+
/**
|
|
18
|
+
* Compute optimal minRun value
|
|
19
|
+
* Returns a value in range [32, 64] such that n/minRun is close to a power of 2
|
|
20
|
+
*/
|
|
21
|
+
export declare function computeMinRun(n: number): number;
|
|
22
|
+
/**
|
|
23
|
+
* Push a run onto the pending-run stack
|
|
24
|
+
*/
|
|
25
|
+
export declare function pushRun(runStack: Run[], runBase: number, runLen: number): void;
|
|
26
|
+
/**
|
|
27
|
+
* Merge runs to maintain stack invariants
|
|
28
|
+
*
|
|
29
|
+
* Invariants (from Python's timsort):
|
|
30
|
+
* 1. runLen[i - 2] > runLen[i - 1] + runLen[i]
|
|
31
|
+
* 2. runLen[i - 1] > runLen[i]
|
|
32
|
+
*/
|
|
33
|
+
export declare function mergeCollapse<T>(state: TimsortState<T>, mergeAtFn: (state: TimsortState<T>, i: number) => void): void;
|
|
34
|
+
/**
|
|
35
|
+
* Force merge all runs on the stack
|
|
36
|
+
*/
|
|
37
|
+
export declare function mergeForceCollapse<T>(state: TimsortState<T>, mergeAtFn: (state: TimsortState<T>, i: number) => void): void;
|
|
38
|
+
//# sourceMappingURL=timsort-run.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timsort-run.d.ts","sourceRoot":"","sources":["../../../../src/algorithms/sorting/timsort-run.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAG7D;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,CAAC,EACxC,KAAK,EAAE,CAAC,EAAE,EACV,EAAE,EAAE,MAAM,EACV,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC,GACxB,MAAM,CAyBR;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,IAAI,CAOxE;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EACnC,KAAK,EAAE,CAAC,EAAE,EACV,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,MAAM,EACb,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC,GACxB,IAAI,CA8BN;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAS/C;AAED;;GAEG;AACH,wBAAgB,OAAO,CAAC,QAAQ,EAAE,GAAG,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAE9E;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAC7B,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,EACtB,SAAS,EAAE,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,KAAK,IAAI,GACrD,IAAI,CAqBN;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAClC,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,EACtB,SAAS,EAAE,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,KAAK,IAAI,GACrD,IAAI,CAUN"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { Comparator } from '../../types/common';
|
|
2
|
+
import type { TimsortOptions } from './sorting.interface';
|
|
3
|
+
/**
|
|
4
|
+
* Timsort - Production-grade stable O(n log n) sorting algorithm
|
|
5
|
+
*
|
|
6
|
+
* This is a full implementation of Timsort with all optimizations:
|
|
7
|
+
* - Natural run detection (finds already-sorted sequences)
|
|
8
|
+
* - Galloping mode (binary search optimization during merges)
|
|
9
|
+
* - Stack-based merge strategy (maintains merge invariants)
|
|
10
|
+
* - Reusable temporary buffer (reduces allocations)
|
|
11
|
+
*
|
|
12
|
+
* Used by Python, Java, and V8's Array.sort().
|
|
13
|
+
*
|
|
14
|
+
* @param array - Array to sort (modified in-place)
|
|
15
|
+
* @param comparator - Comparison function
|
|
16
|
+
* @param options - Timsort options
|
|
17
|
+
* @returns The sorted array
|
|
18
|
+
*
|
|
19
|
+
* @complexity
|
|
20
|
+
* - Time: O(n log n) worst case, O(n) best case (already sorted)
|
|
21
|
+
* - Space: O(n) for temporary merge buffer
|
|
22
|
+
*/
|
|
23
|
+
export declare function timsort<T>(array: T[], comparator: Comparator<T>, options?: TimsortOptions): T[];
|
|
24
|
+
/**
|
|
25
|
+
* Sort indices based on values without modifying the values
|
|
26
|
+
*
|
|
27
|
+
* @param indices - Array of indices to sort
|
|
28
|
+
* @param getValue - Function to get value at an index
|
|
29
|
+
* @param comparator - Comparison function for values
|
|
30
|
+
* @param options - Timsort options
|
|
31
|
+
* @returns Sorted array of indices
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```typescript
|
|
35
|
+
* const values = ['Charlie', 'Alice', 'Bob'];
|
|
36
|
+
* const indices = [0, 1, 2];
|
|
37
|
+
*
|
|
38
|
+
* const sorted = timsortIndices(
|
|
39
|
+
* indices,
|
|
40
|
+
* (i) => values[i],
|
|
41
|
+
* (a, b) => a.localeCompare(b)
|
|
42
|
+
* );
|
|
43
|
+
* // sorted = [1, 2, 0] (Alice, Bob, Charlie)
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export declare function timsortIndices<T>(indices: number[], getValue: (index: number) => T, comparator: Comparator<T>, options?: TimsortOptions): number[];
|
|
47
|
+
/**
|
|
48
|
+
* Check if an array is sorted
|
|
49
|
+
*
|
|
50
|
+
* @param array - Array to check
|
|
51
|
+
* @param comparator - Comparison function
|
|
52
|
+
* @returns True if sorted
|
|
53
|
+
*/
|
|
54
|
+
export declare function isSorted<T>(array: readonly T[], comparator: Comparator<T>): boolean;
|
|
55
|
+
//# sourceMappingURL=timsort.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timsort.d.ts","sourceRoot":"","sources":["../../../../src/algorithms/sorting/timsort.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAY1D;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,OAAO,CAAC,CAAC,EACvB,KAAK,EAAE,CAAC,EAAE,EACV,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC,EACzB,OAAO,GAAE,cAAmB,GAC3B,CAAC,EAAE,CAUL;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAC9B,OAAO,EAAE,MAAM,EAAE,EACjB,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,CAAC,EAC9B,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC,EACzB,OAAO,GAAE,cAAmB,GAC3B,MAAM,EAAE,CAOV;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,OAAO,CAOnF"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Comparator } from '../../types/common';
|
|
2
|
+
/**
|
|
3
|
+
* Minimum gallop threshold
|
|
4
|
+
* How many times one run must "win" before we switch to galloping mode
|
|
5
|
+
*
|
|
6
|
+
* JavaScript Note: Set higher than Python's default (7) due to function call overhead.
|
|
7
|
+
* Galloping mode has more overhead in JS, so we require more consecutive wins
|
|
8
|
+
* to justify entering gallop mode.
|
|
9
|
+
*/
|
|
10
|
+
export declare const MIN_GALLOP = 32;
|
|
11
|
+
/**
|
|
12
|
+
* Minimum merge threshold for stack invariants
|
|
13
|
+
*/
|
|
14
|
+
export declare const MIN_MERGE = 32;
|
|
15
|
+
/**
|
|
16
|
+
* Run represents a sorted sequence in the array
|
|
17
|
+
*/
|
|
18
|
+
export interface Run {
|
|
19
|
+
start: number;
|
|
20
|
+
length: number;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Internal state shared across Timsort modules
|
|
24
|
+
*/
|
|
25
|
+
export interface TimsortState<T> {
|
|
26
|
+
array: T[];
|
|
27
|
+
comparator: Comparator<T>;
|
|
28
|
+
minGallop: number;
|
|
29
|
+
runStack: Run[];
|
|
30
|
+
tmp: T[];
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=timsort.interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timsort.interface.d.ts","sourceRoot":"","sources":["../../../../src/algorithms/sorting/timsort.interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErD;;;;;;;GAOG;AACH,eAAO,MAAM,UAAU,KAAK,CAAC;AAE7B;;GAEG;AACH,eAAO,MAAM,SAAS,KAAK,CAAC;AAE5B;;GAEG;AACH,MAAM,WAAW,GAAG;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY,CAAC,CAAC;IAC7B,KAAK,EAAE,CAAC,EAAE,CAAC;IACX,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,GAAG,EAAE,CAAC;IAChB,GAAG,EAAE,CAAC,EAAE,CAAC;CACV"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { ColumnStore as IColumnStore, ColumnStoreOptions, ColumnDefinition, AggregateOperation, AggregationResult } from './column-store.interface';
|
|
2
|
+
/**
|
|
3
|
+
* ColumnStore implementation using typed arrays
|
|
4
|
+
*
|
|
5
|
+
* Column-oriented storage for dense grid data.
|
|
6
|
+
* Uses typed arrays for numeric columns for better performance and memory efficiency.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* const store = new ColumnStore({
|
|
11
|
+
* rowCount: 1000,
|
|
12
|
+
* columns: [
|
|
13
|
+
* { name: 'id', type: 'int32' },
|
|
14
|
+
* { name: 'value', type: 'float64' },
|
|
15
|
+
* { name: 'label', type: 'string' }
|
|
16
|
+
* ]
|
|
17
|
+
* });
|
|
18
|
+
*
|
|
19
|
+
* store.setValue(0, 'id', 1);
|
|
20
|
+
* store.setValue(0, 'value', 99.5);
|
|
21
|
+
* store.setValue(0, 'label', 'Item 1');
|
|
22
|
+
*
|
|
23
|
+
* const sum = store.aggregate('value', 'sum');
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare class ColumnStore implements IColumnStore {
|
|
27
|
+
private data;
|
|
28
|
+
private columnTypes;
|
|
29
|
+
private rows;
|
|
30
|
+
private autoGrow;
|
|
31
|
+
constructor(options?: ColumnStoreOptions);
|
|
32
|
+
addColumn(definition: ColumnDefinition): void;
|
|
33
|
+
private createColumn;
|
|
34
|
+
private fillColumn;
|
|
35
|
+
removeColumn(columnName: string): boolean;
|
|
36
|
+
hasColumn(columnName: string): boolean;
|
|
37
|
+
getValue(row: number, columnName: string): any;
|
|
38
|
+
setValue(row: number, columnName: string, value: any): void;
|
|
39
|
+
private coerceValue;
|
|
40
|
+
getRow(row: number): Record<string, any>;
|
|
41
|
+
setRow(row: number, values: Record<string, any>): void;
|
|
42
|
+
getColumn(columnName: string): any[];
|
|
43
|
+
setColumn(columnName: string, values: any[]): void;
|
|
44
|
+
aggregate(columnName: string, operation: AggregateOperation): AggregationResult;
|
|
45
|
+
addRows(count: number): void;
|
|
46
|
+
clear(): void;
|
|
47
|
+
private ensureRowExists;
|
|
48
|
+
get rowCount(): number;
|
|
49
|
+
get columnCount(): number;
|
|
50
|
+
get columns(): ReadonlyArray<string>;
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=column-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"column-store.d.ts","sourceRoot":"","sources":["../../../../src/data-structures/column-store/column-store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,IAAI,YAAY,EAC3B,kBAAkB,EAClB,gBAAgB,EAEhB,kBAAkB,EAClB,iBAAiB,EAClB,MAAM,0BAA0B,CAAC;AAElC;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,qBAAa,WAAY,YAAW,YAAY;IAC9C,OAAO,CAAC,IAAI,CAAiD;IAC7D,OAAO,CAAC,WAAW,CAA0B;IAC7C,OAAO,CAAC,IAAI,CAAS;IACrB,OAAO,CAAC,QAAQ,CAAU;gBAEd,OAAO,GAAE,kBAAuB;IAc5C,SAAS,CAAC,UAAU,EAAE,gBAAgB,GAAG,IAAI;IAgB7C,OAAO,CAAC,YAAY;IAcpB,OAAO,CAAC,UAAU;IAUlB,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO;IAQzC,SAAS,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO;IAItC,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,GAAG;IAW9C,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI;IAY3D,OAAO,CAAC,WAAW;IA8BnB,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAUxC,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI;IAUtD,SAAS,CAAC,UAAU,EAAE,MAAM,GAAG,GAAG,EAAE;IASpC,SAAS,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,IAAI;IAiBlD,SAAS,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,kBAAkB,GAAG,iBAAiB;IA6F/E,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IA2B5B,KAAK,IAAI,IAAI;IAYb,OAAO,CAAC,eAAe;IAcvB,IAAI,QAAQ,IAAI,MAAM,CAErB;IAED,IAAI,WAAW,IAAI,MAAM,CAExB;IAED,IAAI,OAAO,IAAI,aAAa,CAAC,MAAM,CAAC,CAEnC;CACF"}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Column Store interfaces for ZenGrid
|
|
3
|
+
* Column-oriented storage using typed arrays for performance
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Supported column data types
|
|
7
|
+
*/
|
|
8
|
+
export type ColumnType = 'int32' | 'float64' | 'string' | 'boolean';
|
|
9
|
+
/**
|
|
10
|
+
* Aggregation operations
|
|
11
|
+
*/
|
|
12
|
+
export type AggregateOperation = 'sum' | 'avg' | 'min' | 'max' | 'count';
|
|
13
|
+
/**
|
|
14
|
+
* Column definition
|
|
15
|
+
*/
|
|
16
|
+
export interface ColumnDefinition {
|
|
17
|
+
/** Column name/identifier */
|
|
18
|
+
name: string;
|
|
19
|
+
/** Data type */
|
|
20
|
+
type: ColumnType;
|
|
21
|
+
/** Default value for new rows */
|
|
22
|
+
defaultValue?: any;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Aggregation result
|
|
26
|
+
*/
|
|
27
|
+
export interface AggregationResult {
|
|
28
|
+
operation: AggregateOperation;
|
|
29
|
+
column: string;
|
|
30
|
+
value: number;
|
|
31
|
+
count: number;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Column Store interface
|
|
35
|
+
*
|
|
36
|
+
* Column-oriented storage for dense grid data.
|
|
37
|
+
* Uses typed arrays (Float64Array, Int32Array) for numeric columns for better performance.
|
|
38
|
+
*/
|
|
39
|
+
export interface ColumnStore {
|
|
40
|
+
/**
|
|
41
|
+
* Add a new column
|
|
42
|
+
* @param definition - Column definition
|
|
43
|
+
* @complexity O(n) where n = rowCount
|
|
44
|
+
*/
|
|
45
|
+
addColumn(definition: ColumnDefinition): void;
|
|
46
|
+
/**
|
|
47
|
+
* Remove a column
|
|
48
|
+
* @param columnName - Column to remove
|
|
49
|
+
* @returns true if column existed and was removed
|
|
50
|
+
* @complexity O(1)
|
|
51
|
+
*/
|
|
52
|
+
removeColumn(columnName: string): boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Check if column exists
|
|
55
|
+
* @param columnName - Column name
|
|
56
|
+
* @complexity O(1)
|
|
57
|
+
*/
|
|
58
|
+
hasColumn(columnName: string): boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Get value at (row, column)
|
|
61
|
+
* @param row - Row index
|
|
62
|
+
* @param columnName - Column name
|
|
63
|
+
* @returns Value or undefined if out of bounds
|
|
64
|
+
* @complexity O(1)
|
|
65
|
+
*/
|
|
66
|
+
getValue(row: number, columnName: string): any;
|
|
67
|
+
/**
|
|
68
|
+
* Set value at (row, column)
|
|
69
|
+
* @param row - Row index
|
|
70
|
+
* @param columnName - Column name
|
|
71
|
+
* @param value - Value to set
|
|
72
|
+
* @complexity O(1)
|
|
73
|
+
*/
|
|
74
|
+
setValue(row: number, columnName: string, value: any): void;
|
|
75
|
+
/**
|
|
76
|
+
* Get entire row as object
|
|
77
|
+
* @param row - Row index
|
|
78
|
+
* @returns Object with column names as keys
|
|
79
|
+
* @complexity O(c) where c = number of columns
|
|
80
|
+
*/
|
|
81
|
+
getRow(row: number): Record<string, any>;
|
|
82
|
+
/**
|
|
83
|
+
* Set multiple values in a row
|
|
84
|
+
* @param row - Row index
|
|
85
|
+
* @param values - Object with column names and values
|
|
86
|
+
* @complexity O(k) where k = Object.keys(values).length
|
|
87
|
+
*/
|
|
88
|
+
setRow(row: number, values: Record<string, any>): void;
|
|
89
|
+
/**
|
|
90
|
+
* Get entire column as array
|
|
91
|
+
* @param columnName - Column name
|
|
92
|
+
* @returns Copy of column data
|
|
93
|
+
* @complexity O(n) where n = rowCount
|
|
94
|
+
*/
|
|
95
|
+
getColumn(columnName: string): any[];
|
|
96
|
+
/**
|
|
97
|
+
* Set entire column
|
|
98
|
+
* @param columnName - Column name
|
|
99
|
+
* @param values - Array of values (length must match rowCount)
|
|
100
|
+
* @complexity O(n)
|
|
101
|
+
*/
|
|
102
|
+
setColumn(columnName: string, values: any[]): void;
|
|
103
|
+
/**
|
|
104
|
+
* Perform aggregation on a column
|
|
105
|
+
* @param columnName - Column to aggregate
|
|
106
|
+
* @param operation - Aggregation operation
|
|
107
|
+
* @returns Aggregation result
|
|
108
|
+
* @complexity O(n)
|
|
109
|
+
*/
|
|
110
|
+
aggregate(columnName: string, operation: AggregateOperation): AggregationResult;
|
|
111
|
+
/**
|
|
112
|
+
* Add new rows (expand capacity)
|
|
113
|
+
* @param count - Number of rows to add
|
|
114
|
+
* @complexity O(n * c) where n = count, c = columns
|
|
115
|
+
*/
|
|
116
|
+
addRows(count: number): void;
|
|
117
|
+
/**
|
|
118
|
+
* Clear all data but keep column definitions
|
|
119
|
+
* @complexity O(c) where c = number of columns
|
|
120
|
+
*/
|
|
121
|
+
clear(): void;
|
|
122
|
+
/**
|
|
123
|
+
* Number of rows
|
|
124
|
+
*/
|
|
125
|
+
readonly rowCount: number;
|
|
126
|
+
/**
|
|
127
|
+
* Number of columns
|
|
128
|
+
*/
|
|
129
|
+
readonly columnCount: number;
|
|
130
|
+
/**
|
|
131
|
+
* Column names
|
|
132
|
+
*/
|
|
133
|
+
readonly columns: ReadonlyArray<string>;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Options for creating a ColumnStore
|
|
137
|
+
*/
|
|
138
|
+
export interface ColumnStoreOptions {
|
|
139
|
+
/**
|
|
140
|
+
* Initial row count
|
|
141
|
+
* @default 0
|
|
142
|
+
*/
|
|
143
|
+
rowCount?: number;
|
|
144
|
+
/**
|
|
145
|
+
* Column definitions
|
|
146
|
+
* @default []
|
|
147
|
+
*/
|
|
148
|
+
columns?: ColumnDefinition[];
|
|
149
|
+
/**
|
|
150
|
+
* Whether to grow automatically when accessing rows beyond rowCount
|
|
151
|
+
* @default false
|
|
152
|
+
*/
|
|
153
|
+
autoGrow?: boolean;
|
|
154
|
+
}
|
|
155
|
+
//# sourceMappingURL=column-store.interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"column-store.interface.d.ts","sourceRoot":"","sources":["../../../../src/data-structures/column-store/column-store.interface.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,SAAS,GAAG,QAAQ,GAAG,SAAS,CAAC;AAEpE;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,OAAO,CAAC;AAEzE;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,6BAA6B;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,gBAAgB;IAChB,IAAI,EAAE,UAAU,CAAC;IACjB,iCAAiC;IACjC,YAAY,CAAC,EAAE,GAAG,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,kBAAkB,CAAC;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;;GAKG;AACH,MAAM,WAAW,WAAW;IAC1B;;;;OAIG;IACH,SAAS,CAAC,UAAU,EAAE,gBAAgB,GAAG,IAAI,CAAC;IAE9C;;;;;OAKG;IACH,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC;IAE1C;;;;OAIG;IACH,SAAS,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC;IAEvC;;;;;;OAMG;IACH,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,GAAG,CAAC;IAE/C;;;;;;OAMG;IACH,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI,CAAC;IAE5D;;;;;OAKG;IACH,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAEzC;;;;;OAKG;IACH,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC;IAEvD;;;;;OAKG;IACH,SAAS,CAAC,UAAU,EAAE,MAAM,GAAG,GAAG,EAAE,CAAC;IAErC;;;;;OAKG;IACH,SAAS,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IAEnD;;;;;;OAMG;IACH,SAAS,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,kBAAkB,GAAG,iBAAiB,CAAC;IAEhF;;;;OAIG;IACH,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAE7B;;;OAGG;IACH,KAAK,IAAI,IAAI,CAAC;IAEd;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAE1B;;OAEG;IACH,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAE7B;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;CACzC;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;OAGG;IACH,OAAO,CAAC,EAAE,gBAAgB,EAAE,CAAC;IAE7B;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Column Store - Column-oriented storage with typed arrays
|
|
3
|
+
*/
|
|
4
|
+
export { ColumnStore } from './column-store';
|
|
5
|
+
export type { ColumnStore as IColumnStore, ColumnStoreOptions, ColumnDefinition, ColumnType, AggregateOperation, AggregationResult, } from './column-store.interface';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/data-structures/column-store/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,YAAY,EACV,WAAW,IAAI,YAAY,EAC3B,kBAAkB,EAClB,gBAAgB,EAChB,UAAU,EACV,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,0BAA0B,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { ICommand, ICommandStack, ICommandStackOptions } from './command-stack.interface';
|
|
2
|
+
/**
|
|
3
|
+
* Implementation of a command stack for undo/redo functionality.
|
|
4
|
+
*
|
|
5
|
+
* Time Complexity:
|
|
6
|
+
* - execute: O(1)
|
|
7
|
+
* - undo: O(1)
|
|
8
|
+
* - redo: O(1)
|
|
9
|
+
* - canUndo/canRedo: O(1)
|
|
10
|
+
* - clear: O(1)
|
|
11
|
+
*
|
|
12
|
+
* Space Complexity: O(n) where n is the number of commands (up to maxSize)
|
|
13
|
+
*/
|
|
14
|
+
export declare class CommandStack implements ICommandStack {
|
|
15
|
+
private undoStack;
|
|
16
|
+
private redoStack;
|
|
17
|
+
private readonly maxSize;
|
|
18
|
+
constructor(options?: ICommandStackOptions);
|
|
19
|
+
/**
|
|
20
|
+
* Executes a command and adds it to the undo stack.
|
|
21
|
+
* Clears the redo stack as new actions invalidate the redo history.
|
|
22
|
+
*/
|
|
23
|
+
execute(command: ICommand): void;
|
|
24
|
+
/**
|
|
25
|
+
* Undoes the last executed command.
|
|
26
|
+
*/
|
|
27
|
+
undo(): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Redoes the last undone command.
|
|
30
|
+
*/
|
|
31
|
+
redo(): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Checks if there are commands that can be undone.
|
|
34
|
+
*/
|
|
35
|
+
canUndo(): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Checks if there are commands that can be redone.
|
|
38
|
+
*/
|
|
39
|
+
canRedo(): boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Clears all commands from both stacks.
|
|
42
|
+
*/
|
|
43
|
+
clear(): void;
|
|
44
|
+
/**
|
|
45
|
+
* Gets the number of commands in the undo stack.
|
|
46
|
+
*/
|
|
47
|
+
getUndoCount(): number;
|
|
48
|
+
/**
|
|
49
|
+
* Gets the number of commands in the redo stack.
|
|
50
|
+
*/
|
|
51
|
+
getRedoCount(): number;
|
|
52
|
+
/**
|
|
53
|
+
* Gets the descriptions of all commands in the undo stack.
|
|
54
|
+
*/
|
|
55
|
+
getUndoHistory(): string[];
|
|
56
|
+
/**
|
|
57
|
+
* Gets the descriptions of all commands in the redo stack.
|
|
58
|
+
*/
|
|
59
|
+
getRedoHistory(): string[];
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=command-stack.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-stack.d.ts","sourceRoot":"","sources":["../../../../src/data-structures/command-stack/command-stack.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAE/F;;;;;;;;;;;GAWG;AACH,qBAAa,YAAa,YAAW,aAAa;IAChD,OAAO,CAAC,SAAS,CAAkB;IACnC,OAAO,CAAC,SAAS,CAAkB;IACnC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;gBAErB,OAAO,GAAE,oBAAyB;IAQ9C;;;OAGG;IACH,OAAO,CAAC,OAAO,EAAE,QAAQ,GAAG,IAAI;IAehC;;OAEG;IACH,IAAI,IAAI,OAAO;IAYf;;OAEG;IACH,IAAI,IAAI,OAAO;IAmBf;;OAEG;IACH,OAAO,IAAI,OAAO;IAIlB;;OAEG;IACH,OAAO,IAAI,OAAO;IAIlB;;OAEG;IACH,KAAK,IAAI,IAAI;IAKb;;OAEG;IACH,YAAY,IAAI,MAAM;IAItB;;OAEG;IACH,YAAY,IAAI,MAAM;IAItB;;OAEG;IACH,cAAc,IAAI,MAAM,EAAE;IAI1B;;OAEG;IACH,cAAc,IAAI,MAAM,EAAE;CAG3B"}
|