@noldova/context.collections 0.0.13 → 0.0.15

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 CHANGED
@@ -2,8 +2,11 @@
2
2
 
3
3
  Collections for CONTEXT libraries and apps, with queries over them:
4
4
  `List`, `Dictionary`, `HashSet`, `Queue` and `Stack`, each an `Enumerable` with
5
- the query operators; read-only views; equality and ordering comparers; and
6
- `BinarySearchService`, which finds positions in ascending numeric arrays.
5
+ the query operators; `ChunkedList`, a list held in chunks that sums its
6
+ elements' weights; read-only views; equality and ordering comparers; and
7
+ `BinarySearchService`, which finds an item's position and the lower and upper
8
+ bounds of a key in sorted arrays and lists, as `List.binarySearch` and
9
+ `ChunkedList.binarySearch` do for their own items.
7
10
 
8
11
  ## Install
9
12
 
@@ -47,6 +50,22 @@ byId.tryGet(9); // undefined
47
50
  Enumerable.from([3, 1, 2]).orderByDescending(t => t).take(2).toArray(); // [3, 2]
48
51
  ```
49
52
 
53
+ A `ChunkedList` suits a long list that is mostly one value, such as a count
54
+ of matches for each line of a large text. A chunk that holds only that value
55
+ takes no storage until an element in it is set, and each chunk keeps the sum
56
+ of its elements' weights:
57
+
58
+ ```ts
59
+ import { ChunkedList } from "@noldova/context.collections";
60
+
61
+ const matches = new ChunkedList<number>(1024, 0, 100_000, t => t);
62
+ matches.set(10, 2);
63
+ matches.set(500, 3);
64
+ matches.totalWeight; // 5
65
+ matches.weightBefore(500); // 2
66
+ matches.nextWeightedIndex(11); // 500
67
+ ```
68
+
50
69
  Arrays stay native: `Enumerable.from` gives any iterable the operators, and
51
70
  `new List(array)` copies one into a list. Operators that return a sequence are
52
71
  deferred and run again on each enumeration. A method that needs an element
package/api/index.d.ts CHANGED
@@ -7,7 +7,12 @@
7
7
  */
8
8
 
9
9
  /**
10
- * Provides binary-search operations for ascending numeric arrays.
10
+ * Binary searches over sorted items: arrays or read-only lists.
11
+ *
12
+ * @remarks
13
+ * The items must be sorted by the comparison the search uses; the order isn't checked. Each
14
+ * search reads O(log n) items, where n is the number of items searched, and doesn't copy or keep
15
+ * them. `index` and `count` search part of the items; omitted, the search covers them all.
11
16
  */
12
17
  export declare class BinarySearchService {
13
18
  /**
@@ -39,6 +44,126 @@ export declare class BinarySearchService {
39
44
  * ```
40
45
  */
41
46
  public static floorIndex(values: readonly number[], target: number): number;
47
+
48
+ /**
49
+ * Finds an item's position in sorted items.
50
+ *
51
+ * @param items The items, sorted by `comparison`.
52
+ * @param item The item to find.
53
+ * @param comparison The order. Omitted, it is {@link Comparer.compare}.
54
+ * @param index The first position searched; 0 when omitted.
55
+ * @param count How many items are searched; the rest from `index` when omitted.
56
+ * @returns The position of an item the comparison finds equal, any one of them when there are
57
+ * several, or the bitwise complement (`~`) of the position where the item would be inserted to
58
+ * keep the order, which is negative.
59
+ * @throws ArgumentOutOfRangeException When `index` or `count` isn't an integer from 0, or they
60
+ * reach past the items.
61
+ * @throws ArgumentException When an array has a hole at a position the search reads.
62
+ * @example
63
+ * ```ts
64
+ * import { BinarySearchService } from "@noldova/context.collections";
65
+ *
66
+ * BinarySearchService.search([1, 3, 5], 3); // 1
67
+ * ~BinarySearchService.search([1, 3, 5], 4); // 2: insert 4 at position 2.
68
+ * ```
69
+ */
70
+ public static search<T extends {} | null>(items: readonly T[] | IReadOnlyList<T>, item: T, comparison?: Comparison<T>, index?: number, count?: number): number;
71
+
72
+ /**
73
+ * Finds the first position whose item isn't before the key.
74
+ *
75
+ * @param items The items, sorted by `comparison`.
76
+ * @param key The key, compared with each item.
77
+ * @param comparison The order. Omitted, it is {@link Comparer.compare}.
78
+ * @param index The first position searched; 0 when omitted.
79
+ * @param count How many items are searched; the rest from `index` when omitted.
80
+ * @returns The position, from `index` to `index + count`; `index + count` when every item is
81
+ * before the key.
82
+ * @throws ArgumentOutOfRangeException When `index` or `count` isn't an integer from 0, or they
83
+ * reach past the items.
84
+ * @throws ArgumentException When an array has a hole at a position the search reads.
85
+ * @example
86
+ * ```ts
87
+ * import { BinarySearchService } from "@noldova/context.collections";
88
+ *
89
+ * BinarySearchService.lowerBound([1, 3, 3, 5], 3); // 1
90
+ * BinarySearchService.lowerBound([1, 3, 3, 5], 4); // 3
91
+ * ```
92
+ */
93
+ public static lowerBound<T extends {} | null>(items: readonly T[] | IReadOnlyList<T>, key: T, comparison?: Comparison<T>, index?: number, count?: number): number;
94
+
95
+ /**
96
+ * Finds the first position whose item is after the key.
97
+ *
98
+ * @param items The items, sorted by `comparison`.
99
+ * @param key The key, compared with each item.
100
+ * @param comparison The order. Omitted, it is {@link Comparer.compare}.
101
+ * @param index The first position searched; 0 when omitted.
102
+ * @param count How many items are searched; the rest from `index` when omitted.
103
+ * @returns The position, from `index` to `index + count`; `index + count` when no item is
104
+ * after the key.
105
+ * @throws ArgumentOutOfRangeException When `index` or `count` isn't an integer from 0, or they
106
+ * reach past the items.
107
+ * @throws ArgumentException When an array has a hole at a position the search reads.
108
+ * @example
109
+ * ```ts
110
+ * import { BinarySearchService } from "@noldova/context.collections";
111
+ *
112
+ * BinarySearchService.upperBound([1, 3, 3, 5], 3); // 3
113
+ * BinarySearchService.upperBound([1, 3, 3, 5], 0); // 0
114
+ * ```
115
+ */
116
+ public static upperBound<T extends {} | null>(items: readonly T[] | IReadOnlyList<T>, key: T, comparison?: Comparison<T>, index?: number, count?: number): number;
117
+
118
+ /**
119
+ * Finds the first position whose item's key isn't before the key.
120
+ *
121
+ * @param items The items, sorted by `select`'s key and `comparison`.
122
+ * @param key The key, compared with each item's.
123
+ * @param select Gives an item's key.
124
+ * @param comparison The order of keys. Omitted, it is {@link Comparer.compare}.
125
+ * @param index The first position searched; 0 when omitted.
126
+ * @param count How many items are searched; the rest from `index` when omitted.
127
+ * @returns The position, from `index` to `index + count`; `index + count` when every item's
128
+ * key is before the key.
129
+ * @throws ArgumentOutOfRangeException When `index` or `count` isn't an integer from 0, or they
130
+ * reach past the items.
131
+ * @throws ArgumentException When an array has a hole at a position the search reads.
132
+ * @example
133
+ * ```ts
134
+ * import { BinarySearchService } from "@noldova/context.collections";
135
+ *
136
+ * const words = ["a", "bb", "ccc", "dddd"];
137
+ * BinarySearchService.lowerBoundBy(words, 3, t => t.length); // 2: the first word of 3 letters or more.
138
+ * ```
139
+ */
140
+ public static lowerBoundBy<T extends {} | null, TKey>(items: readonly T[] | IReadOnlyList<T>, key: TKey, select: (item: T) => TKey, comparison?: Comparison<TKey>,
141
+ index?: number, count?: number): number;
142
+
143
+ /**
144
+ * Finds the first position whose item's key is after the key.
145
+ *
146
+ * @param items The items, sorted by `select`'s key and `comparison`.
147
+ * @param key The key, compared with each item's.
148
+ * @param select Gives an item's key.
149
+ * @param comparison The order of keys. Omitted, it is {@link Comparer.compare}.
150
+ * @param index The first position searched; 0 when omitted.
151
+ * @param count How many items are searched; the rest from `index` when omitted.
152
+ * @returns The position, from `index` to `index + count`; `index + count` when no item's key
153
+ * is after the key.
154
+ * @throws ArgumentOutOfRangeException When `index` or `count` isn't an integer from 0, or they
155
+ * reach past the items.
156
+ * @throws ArgumentException When an array has a hole at a position the search reads.
157
+ * @example
158
+ * ```ts
159
+ * import { BinarySearchService } from "@noldova/context.collections";
160
+ *
161
+ * const words = ["a", "bb", "ccc", "dddd"];
162
+ * BinarySearchService.upperBoundBy(words, 2, t => t.length); // 2: the first word longer than 2 letters.
163
+ * ```
164
+ */
165
+ public static upperBoundBy<T extends {} | null, TKey>(items: readonly T[] | IReadOnlyList<T>, key: TKey, select: (item: T) => TKey, comparison?: Comparison<TKey>,
166
+ index?: number, count?: number): number;
42
167
  }
43
168
 
44
169
  /**
@@ -294,7 +419,28 @@ export declare class EqualityComparers {
294
419
  * ages.firstOrDefault(t => t > 50); // undefined
295
420
  * ```
296
421
  */
297
- export declare abstract class Enumerable<T> implements Iterable<T> {
422
+ export declare class Enumerable<T> implements Iterable<T> {
423
+ /**
424
+ * Makes a sequence for a subclass. A subclass either passes the factory or
425
+ * overrides `[Symbol.iterator]`; outside a subclass, `Enumerable.from` makes one.
426
+ *
427
+ * @param factory Starts each enumeration of the elements. Without it, the
428
+ * sequence has no elements.
429
+ * @example
430
+ * ```ts
431
+ * import { Enumerable } from "@noldova/context.collections";
432
+ *
433
+ * class Countdown extends Enumerable<number> {
434
+ * public constructor(start: number) {
435
+ * super(() => Iterator.from([start, start - 1, start - 2]));
436
+ * }
437
+ * }
438
+ *
439
+ * new Countdown(3).toArray(); // [3, 2, 1]
440
+ * ```
441
+ */
442
+ protected constructor(factory?: () => Iterator<T>);
443
+
298
444
  /**
299
445
  * Wraps any iterable, such as an array, a `Map` or a generator, in the query operators.
300
446
  *
@@ -342,7 +488,7 @@ export declare abstract class Enumerable<T> implements Iterable<T> {
342
488
  /**
343
489
  * Starts an enumeration of the elements.
344
490
  */
345
- public abstract [Symbol.iterator](): Iterator<T>;
491
+ public [Symbol.iterator](): Iterator<T>;
346
492
 
347
493
  /**
348
494
  * Keeps the elements that match. A type guard narrows the result's element type.
@@ -1175,12 +1321,231 @@ export declare class List<T extends {} | null> extends Enumerable<T> implements
1175
1321
  */
1176
1322
  public sort(comparison?: Comparison<T>): void;
1177
1323
 
1324
+ /**
1325
+ * Finds an item's position in the list, which must be sorted by `comparison`, as
1326
+ * {@link BinarySearchService.search} does.
1327
+ *
1328
+ * @param item The item to find.
1329
+ * @param comparison The order. Omitted, it is {@link Comparer.compare}.
1330
+ * @returns The position of an item the comparison finds equal, or the bitwise complement (`~`)
1331
+ * of the position where the item would be inserted to keep the order.
1332
+ */
1333
+ public binarySearch(item: T, comparison?: Comparison<T>): number;
1334
+
1178
1335
  /**
1179
1336
  * Returns a view that reads this list, follows its changes and can't change it.
1180
1337
  */
1181
1338
  public asReadOnly(): ReadOnlyList<T>;
1182
1339
  }
1183
1340
 
1341
+ /**
1342
+ * A list held in chunks, for long lists that are mostly one value and for
1343
+ * sums of the elements' weights over a range.
1344
+ *
1345
+ * @template T The type of the elements; not `undefined`, which means no element.
1346
+ *
1347
+ * @remarks
1348
+ * The elements are kept in chunks of at most `chunkSize`. A chunk that holds
1349
+ * only the fill value it was created with takes no storage until an element
1350
+ * in it is set, so a list of a million fill values holds only its chunks'
1351
+ * lengths. Each chunk keeps the sum of its elements' weights, so the total
1352
+ * weight is O(1), and the weight before a position and the next or previous
1353
+ * weighted element take O(chunks) plus O(chunkSize), skipping chunks whose
1354
+ * weight is 0. Reading or setting a position is O(log chunks), plus
1355
+ * O(chunkSize) the first time a fill chunk is set. Inserting or removing
1356
+ * copies only the kept ends of the first and last chunks it touches, drops
1357
+ * the chunks it removes whole without reading them, and renumbers the chunks
1358
+ * in O(chunks). The rebuilt elements split into chunks of nearly equal size,
1359
+ * and a chunk left with fewer than half of `chunkSize` joins a neighbour, so
1360
+ * the chunk count stays near the length over `chunkSize`. A change that
1361
+ * weighs an element whose weight isn't a finite number that isn't negative
1362
+ * throws `ArgumentOutOfRangeException` and leaves the list as it was.
1363
+ * Changing the list while it is
1364
+ * being enumerated makes the enumeration throw `InvalidOperationException` at
1365
+ * its next step.
1366
+ *
1367
+ * @example
1368
+ * ```ts
1369
+ * import { ChunkedList } from "@noldova/context.collections";
1370
+ *
1371
+ * const matches = new ChunkedList<number>(1024, 0, 100_000, t => t);
1372
+ * matches.set(10, 2);
1373
+ * matches.set(500, 3);
1374
+ * matches.totalWeight; // 5
1375
+ * matches.weightBefore(500); // 2
1376
+ * matches.nextWeightedIndex(11); // 500
1377
+ * matches.previousWeightedIndex(500); // 10
1378
+ * matches.insertRange(0, [0, 0]);
1379
+ * matches.nextWeightedIndex(0); // 12
1380
+ * ```
1381
+ */
1382
+ export declare class ChunkedList<T extends {} | null> extends Enumerable<T> implements IReadOnlyList<T> {
1383
+ /**
1384
+ * Creates a list of `length` fill values.
1385
+ *
1386
+ * @param chunkSize The most elements a chunk holds.
1387
+ * @param fill The value of every element at the start; chunks that hold
1388
+ * only it take no storage.
1389
+ * @param length How many elements the list starts with. Omitted, it is 0.
1390
+ * @param weigh An element's weight, a finite number that isn't negative.
1391
+ * Omitted, every element weighs 0.
1392
+ * @throws {ArgumentOutOfRangeException} When `chunkSize` isn't a positive
1393
+ * integer, `length` isn't a non-negative integer, or `length` is positive
1394
+ * and the fill value's weight isn't a finite number that isn't negative.
1395
+ */
1396
+ public constructor(chunkSize: number, fill: T, length?: number, weigh?: (item: T) => number);
1397
+
1398
+ /**
1399
+ * The sum of every element's weight.
1400
+ */
1401
+ public get totalWeight(): number;
1402
+
1403
+ /**
1404
+ * Starts an enumeration of the elements in order.
1405
+ */
1406
+ public [Symbol.iterator](): Iterator<T>;
1407
+
1408
+ /**
1409
+ * The element at a zero-based position.
1410
+ *
1411
+ * @throws {ArgumentOutOfRangeException} When there is no element there,
1412
+ * including a negative or fractional position.
1413
+ */
1414
+ public get(index: number): T;
1415
+
1416
+ /**
1417
+ * The element at a zero-based position; `undefined` when there is none.
1418
+ */
1419
+ public tryGet(index: number): T | undefined;
1420
+
1421
+ /**
1422
+ * Replaces the element at a zero-based position, and its weight in the sums.
1423
+ *
1424
+ * @throws {ArgumentOutOfRangeException} When there is no element there, or
1425
+ * the element's weight isn't a finite number that isn't negative.
1426
+ */
1427
+ public set(index: number, item: T): void;
1428
+
1429
+ /**
1430
+ * Adds an element at the end.
1431
+ */
1432
+ public add(item: T): void;
1433
+
1434
+ /**
1435
+ * Adds elements at the end, in order.
1436
+ */
1437
+ public addRange(items: Iterable<T>): void;
1438
+
1439
+ /**
1440
+ * Inserts an element before a zero-based position; the list's length puts it at the end.
1441
+ *
1442
+ * @throws {ArgumentOutOfRangeException} When the position isn't an integer from
1443
+ * zero to the list's length.
1444
+ */
1445
+ public insert(index: number, item: T): void;
1446
+
1447
+ /**
1448
+ * Inserts elements, in order, before a zero-based position.
1449
+ *
1450
+ * @throws {ArgumentOutOfRangeException} When the position isn't an integer from
1451
+ * zero to the list's length.
1452
+ */
1453
+ public insertRange(index: number, items: Iterable<T>): void;
1454
+
1455
+ /**
1456
+ * Removes the first element equal to `item` by SameValueZero.
1457
+ *
1458
+ * @returns Whether an element was removed.
1459
+ */
1460
+ public remove(item: T): boolean;
1461
+
1462
+ /**
1463
+ * Removes the element at a zero-based position.
1464
+ *
1465
+ * @throws {ArgumentOutOfRangeException} When there is no element there.
1466
+ */
1467
+ public removeAt(index: number): void;
1468
+
1469
+ /**
1470
+ * Removes `count` elements from a zero-based position.
1471
+ *
1472
+ * @throws {ArgumentOutOfRangeException} When the position isn't an integer from
1473
+ * zero to the list's length, `count` isn't a non-negative integer, or the
1474
+ * range runs past the end.
1475
+ */
1476
+ public removeRange(index: number, count: number): void;
1477
+
1478
+ /**
1479
+ * Removes every element that matches. The elements left all hold storage.
1480
+ *
1481
+ * @returns How many were removed.
1482
+ */
1483
+ public removeAll(predicate: (item: T) => boolean): number;
1484
+
1485
+ /**
1486
+ * Removes every element.
1487
+ */
1488
+ public clear(): void;
1489
+
1490
+ /**
1491
+ * The position of the first element equal to `item` by SameValueZero, or `-1`.
1492
+ */
1493
+ public indexOf(item: T): number;
1494
+
1495
+ /**
1496
+ * The position of the last element equal to `item` by SameValueZero, or `-1`.
1497
+ */
1498
+ public lastIndexOf(item: T): number;
1499
+
1500
+ /**
1501
+ * Sorts the list in place, keeping the order of equal elements. The
1502
+ * elements then all hold storage.
1503
+ *
1504
+ * @param comparison The order. Omitted, it is {@link Comparer.compare}.
1505
+ */
1506
+ public sort(comparison?: Comparison<T>): void;
1507
+
1508
+ /**
1509
+ * Finds an item's position in the list, which must be sorted by `comparison`, as
1510
+ * {@link BinarySearchService.search} does.
1511
+ *
1512
+ * @param item The item to find.
1513
+ * @param comparison The order. Omitted, it is {@link Comparer.compare}.
1514
+ * @returns The position of an item the comparison finds equal, or the bitwise complement (`~`)
1515
+ * of the position where the item would be inserted to keep the order.
1516
+ */
1517
+ public binarySearch(item: T, comparison?: Comparison<T>): number;
1518
+
1519
+ /**
1520
+ * Returns a view that reads this list, follows its changes and can't change it.
1521
+ */
1522
+ public asReadOnly(): ReadOnlyList<T>;
1523
+
1524
+ /**
1525
+ * The sum of the weights of the elements before a zero-based position.
1526
+ *
1527
+ * @throws {ArgumentOutOfRangeException} When the position isn't an integer from
1528
+ * zero to the list's length.
1529
+ */
1530
+ public weightBefore(index: number): number;
1531
+
1532
+ /**
1533
+ * The first position from `index` on whose element weighs more than 0, or `-1`.
1534
+ *
1535
+ * @throws {ArgumentOutOfRangeException} When the position isn't an integer from
1536
+ * zero to the list's length.
1537
+ */
1538
+ public nextWeightedIndex(index: number): number;
1539
+
1540
+ /**
1541
+ * The last position before `index` whose element weighs more than 0, or `-1`.
1542
+ *
1543
+ * @throws {ArgumentOutOfRangeException} When the position isn't an integer from
1544
+ * zero to the list's length.
1545
+ */
1546
+ public previousWeightedIndex(index: number): number;
1547
+ }
1548
+
1184
1549
  /**
1185
1550
  * Values stored by key.
1186
1551
  *
package/api/index.js CHANGED
@@ -6,6 +6,7 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
8
  import "../extensions/enumerable.extensions.js";
9
+ export { ChunkedList } from "../models/chunked-list.js";
9
10
  export { DefaultEqualityComparer } from "../models/default-equality-comparer.js";
10
11
  export { Dictionary } from "../models/dictionary.js";
11
12
  export { Enumerable } from "../models/enumerable.js";
package/api/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/noldova.context.collections/src/api/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,wCAAwC,CAAC;AAMhD,OAAO,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAC;AACjF,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,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AkB,EAAE,MAAM,mCAAmC,CAAC;AACvE,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAC3E,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC"}
@@ -6,7 +6,7 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
8
  import { Dictionary } from "../models/dictionary.js";
9
- import { Enumerable, QueryEnumerable } from "../models/enumerable.js";
9
+ import { Enumerable } from "../models/enumerable.js";
10
10
  import { Grouping } from "../models/grouping.js";
11
11
  import { HashSet } from "../models/hash-set.js";
12
12
  import { HashTable } from "../models/hash-table.js";
@@ -21,8 +21,10 @@ Enumerable.prototype.orderByDescending = function (key, comparison = Comparer.co
21
21
  return new OrderedEnumerable(this, [OrderedEnumerable.by(key, Comparer.descending(comparison))]);
22
22
  };
23
23
  Enumerable.prototype.groupBy = function (key, comparer) {
24
- return new QueryEnumerable(() => Iterator.from(HashTable.groupOf(this, key, comparer))
25
- .map((group) => new Grouping(group.key, group.value)));
24
+ return Enumerable.from({
25
+ [Symbol.iterator]: () => Iterator.from(HashTable.groupOf(this, key, comparer))
26
+ .map((group) => new Grouping(group.key, group.value))
27
+ });
26
28
  };
27
29
  Enumerable.prototype.toList = function () {
28
30
  return new List(this);
@@ -1 +1 @@
1
- {"version":3,"file":"enumerable.extensions.js","sourceRoot":"","sources":["../../../../src/noldova.context.collections/src/extensions/enumerable.extensions.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAA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AEF,UAAU,CAAC,SAAS,CAAC,MAAM,GAAG;IAC5B,OAAO,IAAI,IAAI,CAAQ,IAAI,CAAC,CAAC;AAC/B,CAAC,CAAC;AAEF,UAAU,CAAC,SAAS,CAAC,SAAS,GAAG,UAAkC,QAA+B;IAChG,OAAO,IAAI,OAAO,CAAI,IAAI,EAAE,QAAQ,CAAC,CAAC;AACxC,CAAC,CAAC;AAEF,UAAU,CAAC,SAAS,CAAC,YAAY,GAAG,UAElC,GAAsB,EACtB,KAA0B,EAC1B,QAAkC;IAClC,OAAO,IAAI,UAAU,CAAe,IAAI,CAAC,MAAM,CAAC,CAAC,IAAO,EAA8B,EAAE,CAAC,IAAI,YAAY,CAAe,GAAG,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;AAC9J,CAAC,CAAC"}
1
+ {"version":3,"file":"enumerable.extensions.js","sourceRoot":"","sources":["../../../../src/noldova.context.collections/src/extensions/enumerable.extensions.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAcnD,UAAU,CAAC,SAAS,CAAC,OAAO,GAAG,UAAwC,GAAsB,EAAE,UAAU,GAAqB,QAAQ,CAAC,OAAO;IAC5I,OAA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C,IAAI,YAAY,CAAe,GAAG,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;AAC9J,CAAC,CAAC"}
@@ -0,0 +1,164 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) Noldova.
4
+ *
5
+ * This source code is licensed under the license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ import "@noldova/context.core";
9
+ import { ArgumentOutOfRangeException } from "@noldova/context.exceptions";
10
+ import { Resources } from "../resources.js";
11
+ import { BinarySearchService } from "../services/binary-search.service.js";
12
+ import { Comparer } from "../services/comparer.js";
13
+ import { EqualityComparers } from "../services/equality-comparers.js";
14
+ import { ChangeCounter } from "./change-counter.js";
15
+ import { Enumerable } from "./enumerable.js";
16
+ import { ListChunks } from "./list-chunks.js";
17
+ import { ReadOnlyList } from "./read-only-list.js";
18
+ export class ChunkedList extends Enumerable {
19
+ changes = new ChangeCounter();
20
+ chunks;
21
+ weigh;
22
+ constructor(chunkSize, fill, length = 0, weigh = ChunkedList.weighNothing) {
23
+ super();
24
+ ArgumentOutOfRangeException.throwIfNotPositiveInteger(chunkSize, Resources.chunkSizeParameterName);
25
+ ArgumentOutOfRangeException.throwIfNotInteger(length, Resources.lengthParameterName);
26
+ ArgumentOutOfRangeException.throwIfNegative(length, Resources.lengthParameterName);
27
+ this.chunks = new ListChunks(chunkSize, fill, length, weigh);
28
+ this.weigh = weigh;
29
+ }
30
+ get totalWeight() {
31
+ return this.chunks.totalWeight;
32
+ }
33
+ *[Symbol.iterator]() {
34
+ const version = this.changes.value;
35
+ for (const chunk of this.chunks)
36
+ for (const item of chunk) {
37
+ yield item;
38
+ this.changes.throwIfChangedSince(version);
39
+ }
40
+ }
41
+ count(predicate) {
42
+ return Object.isUndefined(predicate) ? this.chunks.length : super.count(predicate);
43
+ }
44
+ get(index) {
45
+ const item = this.tryGet(index);
46
+ if (Object.isUndefined(item))
47
+ throw new ArgumentOutOfRangeException(Resources.indexParameterName, index);
48
+ return item;
49
+ }
50
+ tryGet(index) {
51
+ const chunk = this.chunks.at(index);
52
+ return chunk?.get(index - chunk.start);
53
+ }
54
+ set(index, item) {
55
+ const chunk = this.chunks.at(index);
56
+ if (Object.isUndefined(chunk))
57
+ throw new ArgumentOutOfRangeException(Resources.indexParameterName, index);
58
+ this.chunks.set(chunk, index, item);
59
+ this.changes.increment();
60
+ }
61
+ add(item) {
62
+ this.replace(this.chunks.length, 0, [item]);
63
+ }
64
+ addRange(items) {
65
+ this.replace(this.chunks.length, 0, Array.from(items));
66
+ }
67
+ insert(index, item) {
68
+ this.insertRange(index, [item]);
69
+ }
70
+ insertRange(index, items) {
71
+ this.throwIfNotPosition(index);
72
+ this.replace(index, 0, Array.from(items));
73
+ }
74
+ remove(item) {
75
+ const index = this.indexOf(item);
76
+ if (index < 0)
77
+ return false;
78
+ this.removeAt(index);
79
+ return true;
80
+ }
81
+ removeAt(index) {
82
+ this.get(index);
83
+ this.replace(index, 1, []);
84
+ }
85
+ removeRange(index, count) {
86
+ this.throwIfNotPosition(index);
87
+ ArgumentOutOfRangeException.throwIfNotInteger(count, Resources.countParameterName);
88
+ ArgumentOutOfRangeException.throwIfNegative(count, Resources.countParameterName);
89
+ if (index + count > this.chunks.length)
90
+ throw new ArgumentOutOfRangeException(Resources.countParameterName, count);
91
+ this.replace(index, count, []);
92
+ }
93
+ removeAll(predicate) {
94
+ const kept = this.toArray().filter((item) => !predicate(item));
95
+ const removed = this.chunks.length - kept.length;
96
+ this.replace(0, this.chunks.length, kept);
97
+ return removed;
98
+ }
99
+ clear() {
100
+ this.replace(0, this.chunks.length, []);
101
+ }
102
+ indexOf(item) {
103
+ for (const chunk of this.chunks) {
104
+ const local = chunk.indexOf(item);
105
+ if (local >= 0)
106
+ return chunk.start + local;
107
+ }
108
+ return -1;
109
+ }
110
+ lastIndexOf(item) {
111
+ return this.toArray().findLastIndex((candidate) => EqualityComparers.default.equals(candidate, item));
112
+ }
113
+ sort(comparison = Comparer.compare) {
114
+ this.replace(0, this.chunks.length, this.toArray().sort(comparison));
115
+ }
116
+ binarySearch(item, comparison = Comparer.compare) {
117
+ return BinarySearchService.search(this, item, comparison);
118
+ }
119
+ asReadOnly() {
120
+ return new ReadOnlyList(this);
121
+ }
122
+ weightBefore(index) {
123
+ this.throwIfNotPosition(index);
124
+ let weight = 0;
125
+ for (const chunk of this.chunks) {
126
+ if (chunk.start + chunk.length > index)
127
+ return weight + chunk.weightBefore(index - chunk.start, this.weigh);
128
+ weight += chunk.sum;
129
+ }
130
+ return weight;
131
+ }
132
+ nextWeightedIndex(index) {
133
+ this.throwIfNotPosition(index);
134
+ for (const chunk of this.chunks.from(index)) {
135
+ const local = chunk.sum === 0 ? -1 : chunk.nextWeightedIndex(index - chunk.start, this.weigh);
136
+ if (local >= 0)
137
+ return chunk.start + local;
138
+ }
139
+ return -1;
140
+ }
141
+ previousWeightedIndex(index) {
142
+ this.throwIfNotPosition(index);
143
+ for (const chunk of this.chunks.backFrom(index - 1)) {
144
+ const local = chunk.sum === 0 ? -1 : chunk.previousWeightedIndex(index - chunk.start, this.weigh);
145
+ if (local >= 0)
146
+ return chunk.start + local;
147
+ }
148
+ return -1;
149
+ }
150
+ static weighNothing() {
151
+ return 0;
152
+ }
153
+ replace(index, removed, items) {
154
+ this.chunks.replace(index, removed, items);
155
+ this.changes.increment();
156
+ }
157
+ throwIfNotPosition(index) {
158
+ ArgumentOutOfRangeException.throwIfNotInteger(index, Resources.indexParameterName);
159
+ ArgumentOutOfRangeException.throwIfNegative(index, Resources.indexParameterName);
160
+ if (index > this.chunks.length)
161
+ throw new ArgumentOutOfRangeException(Resources.indexParameterName, index);
162
+ }
163
+ }
164
+ //# sourceMappingURL=chunked-list.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunked-list.js","sourceRoot":"","sources":["../../../../src/noldova.context.collections/src/models/chunked-list.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,uBAAuB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