@x-oasis/integer-buffer-set 0.1.27 → 0.1.29
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.d.ts +16 -5
- package/dist/integer-buffer-set.cjs.development.js +115 -39
- package/dist/integer-buffer-set.cjs.development.js.map +1 -1
- package/dist/integer-buffer-set.cjs.production.min.js +1 -1
- package/dist/integer-buffer-set.cjs.production.min.js.map +1 -1
- package/dist/integer-buffer-set.esm.js +115 -39
- package/dist/integer-buffer-set.esm.js.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +111 -65
package/dist/index.d.ts
CHANGED
|
@@ -19,7 +19,6 @@ declare class IntegerBufferSet<Meta = any> {
|
|
|
19
19
|
private _lastUpdatedMS;
|
|
20
20
|
constructor(props?: IntegerBufferSetProps<Meta>);
|
|
21
21
|
get bufferSize(): number;
|
|
22
|
-
isThresholdMeta(meta: any): boolean;
|
|
23
22
|
setIsOnTheFlyFull(val: any): void;
|
|
24
23
|
resetOnTheFlies(): void;
|
|
25
24
|
get isBufferFull(): boolean;
|
|
@@ -35,8 +34,14 @@ declare class IntegerBufferSet<Meta = any> {
|
|
|
35
34
|
replaceMetaToIndexMap(newMetaToIndexMap: MetaToIndexMap<Meta>): false | MetaToIndexMap<Meta>;
|
|
36
35
|
getIndexPosition(index: number): undefined | number;
|
|
37
36
|
getNewPositionForIndex(index: number): number;
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
_peek(heap: Heap): any;
|
|
38
|
+
_getMaxItem(): any;
|
|
39
|
+
_getMinItem(): any;
|
|
40
|
+
_getMinValue(): any;
|
|
41
|
+
_getMaxValue(): any;
|
|
42
|
+
getMaxValue(): any;
|
|
43
|
+
getMinValue(): any;
|
|
44
|
+
_push(heap: Heap, item: HeapItem): void;
|
|
40
45
|
getFliedPosition(newIndex: number, safeRange: SafeRange): number;
|
|
41
46
|
getPosition(newIndex: number, safeRange?: SafeRange): any;
|
|
42
47
|
replaceFurthestIndexPosition(newIndex: number, safeRange?: {
|
|
@@ -47,8 +52,14 @@ declare class IntegerBufferSet<Meta = any> {
|
|
|
47
52
|
startIndex: number;
|
|
48
53
|
endIndex: number;
|
|
49
54
|
}): any;
|
|
50
|
-
shuffle(
|
|
51
|
-
|
|
55
|
+
shuffle(options: {
|
|
56
|
+
retry: boolean;
|
|
57
|
+
fallback: boolean;
|
|
58
|
+
}): any;
|
|
59
|
+
getIndices(options?: {
|
|
60
|
+
retry: boolean;
|
|
61
|
+
fallback: boolean;
|
|
62
|
+
}): any;
|
|
52
63
|
_pushToHeaps(position: number, value: number): void;
|
|
53
64
|
_setMetaPosition(meta: Meta, position: number): void;
|
|
54
65
|
commitPosition(props: {
|
|
@@ -26,6 +26,20 @@ function _createClass(Constructor, protoProps, staticProps) {
|
|
|
26
26
|
});
|
|
27
27
|
return Constructor;
|
|
28
28
|
}
|
|
29
|
+
function _extends() {
|
|
30
|
+
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
31
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
32
|
+
var source = arguments[i];
|
|
33
|
+
for (var key in source) {
|
|
34
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
35
|
+
target[key] = source[key];
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return target;
|
|
40
|
+
};
|
|
41
|
+
return _extends.apply(this, arguments);
|
|
42
|
+
}
|
|
29
43
|
function _toPrimitive(input, hint) {
|
|
30
44
|
if (typeof input !== "object" || input === null) return input;
|
|
31
45
|
var prim = input[Symbol.toPrimitive];
|
|
@@ -46,6 +60,9 @@ var defaultMetaExtractor = function defaultMetaExtractor(value) {
|
|
|
46
60
|
};
|
|
47
61
|
var defaultBufferSize = 10;
|
|
48
62
|
var thresholdNumber = Number.MAX_SAFE_INTEGER - 100000;
|
|
63
|
+
var assertThresholdNumber = function assertThresholdNumber(val) {
|
|
64
|
+
return typeof val === 'number' && val > thresholdNumber;
|
|
65
|
+
};
|
|
49
66
|
var IntegerBufferSet = /*#__PURE__*/function () {
|
|
50
67
|
function IntegerBufferSet(props) {
|
|
51
68
|
if (props === void 0) {
|
|
@@ -78,10 +95,6 @@ var IntegerBufferSet = /*#__PURE__*/function () {
|
|
|
78
95
|
this._lastUpdatedMS = this._loopMS;
|
|
79
96
|
}
|
|
80
97
|
var _proto = IntegerBufferSet.prototype;
|
|
81
|
-
_proto.isThresholdMeta = function isThresholdMeta(meta) {
|
|
82
|
-
if (typeof meta === 'number' && meta > thresholdNumber) return true;
|
|
83
|
-
return false;
|
|
84
|
-
};
|
|
85
98
|
_proto.setIsOnTheFlyFull = function setIsOnTheFlyFull(val) {
|
|
86
99
|
if (val != null) {
|
|
87
100
|
var data = this._onTheFlyIndices.filter(function (v) {
|
|
@@ -113,14 +126,22 @@ var IntegerBufferSet = /*#__PURE__*/function () {
|
|
|
113
126
|
};
|
|
114
127
|
};
|
|
115
128
|
_proto.getIndexMeta = function getIndexMeta(index) {
|
|
116
|
-
|
|
117
|
-
|
|
129
|
+
try {
|
|
130
|
+
if (index == null || index < 0) return null;
|
|
131
|
+
return this._metaExtractor(index);
|
|
132
|
+
} catch (err) {
|
|
133
|
+
return null;
|
|
134
|
+
}
|
|
118
135
|
};
|
|
119
136
|
_proto.getMetaIndex = function getMetaIndex(meta) {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
137
|
+
try {
|
|
138
|
+
if (meta == null) return -1;
|
|
139
|
+
if (assertThresholdNumber(meta)) return -1;
|
|
140
|
+
if (this._indexExtractor) return this._indexExtractor(meta);
|
|
141
|
+
return this._metaToIndexMap.get(meta);
|
|
142
|
+
} catch (err) {
|
|
143
|
+
return -1;
|
|
144
|
+
}
|
|
124
145
|
};
|
|
125
146
|
_proto.setMetaIndex = function setMetaIndex(meta, index) {
|
|
126
147
|
if (!this._indexExtractor) {
|
|
@@ -149,13 +170,55 @@ var IntegerBufferSet = /*#__PURE__*/function () {
|
|
|
149
170
|
this._setMetaPosition(meta, newPosition);
|
|
150
171
|
return newPosition;
|
|
151
172
|
};
|
|
152
|
-
_proto.
|
|
153
|
-
|
|
154
|
-
|
|
173
|
+
_proto._peek = function _peek(heap) {
|
|
174
|
+
return heap.peek();
|
|
175
|
+
};
|
|
176
|
+
_proto._getMaxItem = function _getMaxItem() {
|
|
177
|
+
return this._peek(this._largeValues);
|
|
178
|
+
};
|
|
179
|
+
_proto._getMinItem = function _getMinItem() {
|
|
180
|
+
return this._peek(this._smallValues);
|
|
181
|
+
};
|
|
182
|
+
_proto._getMinValue = function _getMinValue() {
|
|
183
|
+
var _this$_peek;
|
|
184
|
+
return (_this$_peek = this._peek(this._smallValues)) == null ? void 0 : _this$_peek.value;
|
|
185
|
+
};
|
|
186
|
+
_proto._getMaxValue = function _getMaxValue() {
|
|
187
|
+
var _this$_peek2;
|
|
188
|
+
return (_this$_peek2 = this._peek(this._largeValues)) == null ? void 0 : _this$_peek2.value;
|
|
155
189
|
};
|
|
156
190
|
_proto.getMaxValue = function getMaxValue() {
|
|
157
|
-
var
|
|
158
|
-
|
|
191
|
+
var _item2;
|
|
192
|
+
var stack = [];
|
|
193
|
+
var item;
|
|
194
|
+
while ((item = this._getMaxItem()) && assertThresholdNumber((_item = item) == null ? void 0 : _item.value)) {
|
|
195
|
+
var _item;
|
|
196
|
+
stack.push(item);
|
|
197
|
+
this._largeValues.pop();
|
|
198
|
+
}
|
|
199
|
+
var stackItem;
|
|
200
|
+
while (stackItem = stack.pop()) {
|
|
201
|
+
this._largeValues.push(stackItem);
|
|
202
|
+
}
|
|
203
|
+
return (_item2 = item) == null ? void 0 : _item2.value;
|
|
204
|
+
};
|
|
205
|
+
_proto.getMinValue = function getMinValue() {
|
|
206
|
+
var _item4;
|
|
207
|
+
var stack = [];
|
|
208
|
+
var item;
|
|
209
|
+
while ((item = this._getMinItem()) && assertThresholdNumber((_item3 = item) == null ? void 0 : _item3.value)) {
|
|
210
|
+
var _item3;
|
|
211
|
+
stack.push(item);
|
|
212
|
+
this._smallValues.pop();
|
|
213
|
+
}
|
|
214
|
+
var stackItem;
|
|
215
|
+
while (stackItem = stack.pop()) {
|
|
216
|
+
this._smallValues.push(stackItem);
|
|
217
|
+
}
|
|
218
|
+
return (_item4 = item) == null ? void 0 : _item4.value;
|
|
219
|
+
};
|
|
220
|
+
_proto._push = function _push(heap, item) {
|
|
221
|
+
heap.push(item);
|
|
159
222
|
};
|
|
160
223
|
_proto.getFliedPosition = function getFliedPosition(newIndex, safeRange) {
|
|
161
224
|
if (this._isOnTheFlyFull) {
|
|
@@ -216,9 +279,9 @@ var IntegerBufferSet = /*#__PURE__*/function () {
|
|
|
216
279
|
return this._isOnTheFlyFullReturnHook(this.getNewPositionForIndex(newIndex));
|
|
217
280
|
}
|
|
218
281
|
var indexToReplace;
|
|
219
|
-
var minValue = this.
|
|
220
|
-
var maxValue = this.
|
|
221
|
-
if (maxValue
|
|
282
|
+
var minValue = this._getMinValue();
|
|
283
|
+
var maxValue = this._getMaxValue();
|
|
284
|
+
if (assertThresholdNumber(maxValue)) {
|
|
222
285
|
indexToReplace = maxValue;
|
|
223
286
|
this._largeValues.pop();
|
|
224
287
|
var _replacedMeta = this._indexToMetaMap.get(indexToReplace);
|
|
@@ -258,7 +321,7 @@ var IntegerBufferSet = /*#__PURE__*/function () {
|
|
|
258
321
|
var position = this._metaToPositionMap.get(replacedMeta);
|
|
259
322
|
return position;
|
|
260
323
|
};
|
|
261
|
-
_proto.shuffle = function shuffle() {
|
|
324
|
+
_proto.shuffle = function shuffle(options) {
|
|
262
325
|
var _this = this;
|
|
263
326
|
var indices = new Array(this.bufferSize);
|
|
264
327
|
for (var idx = 0; idx < indices.length; idx++) {
|
|
@@ -307,30 +370,41 @@ var IntegerBufferSet = /*#__PURE__*/function () {
|
|
|
307
370
|
}
|
|
308
371
|
}
|
|
309
372
|
this._positionToMetaList = positionToMetaList;
|
|
310
|
-
return this.getIndices(
|
|
373
|
+
return this.getIndices(_extends({}, options, {
|
|
374
|
+
retry: true
|
|
375
|
+
}));
|
|
311
376
|
};
|
|
312
|
-
_proto.getIndices = function getIndices() {
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
377
|
+
_proto.getIndices = function getIndices(options) {
|
|
378
|
+
if (options === void 0) {
|
|
379
|
+
options = {
|
|
380
|
+
retry: false,
|
|
381
|
+
fallback: false
|
|
382
|
+
};
|
|
383
|
+
}
|
|
316
384
|
try {
|
|
385
|
+
var _options = options,
|
|
386
|
+
retry = _options.retry,
|
|
387
|
+
fallback = _options.fallback;
|
|
388
|
+
var _this$initialize = this.initialize(),
|
|
389
|
+
smallValues = _this$initialize.smallValues,
|
|
390
|
+
largeValues = _this$initialize.largeValues;
|
|
317
391
|
var indices = new Array(this._positionToMetaList.length);
|
|
318
392
|
var metaToPositionMap = new Map();
|
|
319
393
|
var indexToMetaMap = new Map();
|
|
320
394
|
var metaToIndexMap = new Map();
|
|
321
395
|
for (var idx = 0; idx < indices.length; idx++) {
|
|
322
|
-
var meta = this._onTheFlyIndices[idx] || this._positionToMetaList[idx];
|
|
396
|
+
var meta = fallback ? this._onTheFlyIndices[idx] : this._onTheFlyIndices[idx] || this._positionToMetaList[idx];
|
|
323
397
|
var targetIndex = this.getMetaIndex(meta);
|
|
324
|
-
if (!
|
|
325
|
-
return this.shuffle();
|
|
398
|
+
if (!assertThresholdNumber(meta) && meta != this.getIndexMeta(targetIndex) && !retry) {
|
|
399
|
+
return this.shuffle(options);
|
|
326
400
|
}
|
|
327
|
-
if (meta != null && !
|
|
328
|
-
var
|
|
401
|
+
if (meta != null && !assertThresholdNumber(meta)) {
|
|
402
|
+
var item = {
|
|
329
403
|
position: idx,
|
|
330
404
|
value: targetIndex
|
|
331
405
|
};
|
|
332
|
-
|
|
333
|
-
|
|
406
|
+
this._push(smallValues, item);
|
|
407
|
+
this._push(largeValues, item);
|
|
334
408
|
metaToPositionMap.set(meta, idx);
|
|
335
409
|
indexToMetaMap.set(targetIndex, meta);
|
|
336
410
|
metaToIndexMap.set(meta, targetIndex);
|
|
@@ -353,18 +427,20 @@ var IntegerBufferSet = /*#__PURE__*/function () {
|
|
|
353
427
|
return indices;
|
|
354
428
|
} catch (err) {
|
|
355
429
|
console.log('err ', err);
|
|
356
|
-
return this.
|
|
430
|
+
return this.getIndices(_extends({}, options, {
|
|
431
|
+
fallback: true
|
|
432
|
+
}));
|
|
357
433
|
} finally {
|
|
358
434
|
this.readyToStartNextLoop();
|
|
359
435
|
}
|
|
360
436
|
};
|
|
361
437
|
_proto._pushToHeaps = function _pushToHeaps(position, value) {
|
|
362
|
-
var
|
|
438
|
+
var item = {
|
|
363
439
|
position: position,
|
|
364
440
|
value: value
|
|
365
441
|
};
|
|
366
|
-
this._smallValues
|
|
367
|
-
this._largeValues
|
|
442
|
+
this._push(this._smallValues, item);
|
|
443
|
+
this._push(this._largeValues, item);
|
|
368
444
|
};
|
|
369
445
|
_proto._setMetaPosition = function _setMetaPosition(meta, position) {
|
|
370
446
|
this._positionToMetaList[position] = meta;
|
|
@@ -425,15 +501,15 @@ var IntegerBufferSet = /*#__PURE__*/function () {
|
|
|
425
501
|
for (var position = 0; position < this._positionToMetaList.length; position++) {
|
|
426
502
|
var meta = this._positionToMetaList[position];
|
|
427
503
|
var value = this.getMetaIndex(meta);
|
|
428
|
-
if (
|
|
504
|
+
if (meta == null || value === -1 || value == null) {
|
|
429
505
|
value = Number.MAX_SAFE_INTEGER - position;
|
|
430
506
|
}
|
|
431
|
-
var
|
|
507
|
+
var item = {
|
|
432
508
|
position: position,
|
|
433
509
|
value: value
|
|
434
510
|
};
|
|
435
|
-
|
|
436
|
-
|
|
511
|
+
this._push(smallValues, item);
|
|
512
|
+
this._push(largeValues, item);
|
|
437
513
|
if (value > thresholdNumber) {
|
|
438
514
|
this._setMetaPosition(value, position);
|
|
439
515
|
this._setMetaIndex(value, value);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"integer-buffer-set.cjs.development.js","sources":["../src/index.ts"],"sourcesContent":["import Heap from '@x-oasis/heap';\nimport isClamped from '@x-oasis/is-clamped';\nimport invariant from '@x-oasis/invariant';\nimport returnHook, { ReturnHook } from '@x-oasis/return-hook';\nimport {\n HeapItem,\n SafeRange,\n MetaExtractor,\n IndexExtractor,\n IntegerBufferSetProps,\n MetaToIndexMap,\n MetaToPositionMap,\n IndexToMetaMap,\n} from './types';\n\nconst defaultMetaExtractor = (value) => value;\nexport const defaultBufferSize = 10;\nconst thresholdNumber = Number.MAX_SAFE_INTEGER - 100000;\n\n// !!!!! should do meta validation...meta should has an index...\n// value: original data `index` value\n// value(index) => meta => position\n// `index to getIndices, meta to find index`\n\n// Data structure that allows to store values and assign positions to them\n// in a way to minimize changing positions of stored values when new ones are\n// added or when some values are replaced. Stored elements are alwasy assigned\n// a consecutive set of positoins startin from 0 up to count of elements less 1\n// Following actions can be executed\n// * get position assigned to given value (null if value is not stored)\n// * create new entry for new value and get assigned position back\n// * replace value that is furthest from specified value range with new value\n// and get it's position back\n// All operations take amortized log(n) time where n is number of elements in\n// the set.\n// feature: add / delete / update item will also in consider..\nclass IntegerBufferSet<Meta = any> {\n private _name: string;\n private _bufferSize: number;\n\n private _indexToMetaMap: IndexToMetaMap<Meta>;\n private _metaToPositionMap: MetaToPositionMap<Meta>;\n private _positionToMetaList: Array<Meta>;\n private _metaToIndexMap: MetaToIndexMap<Meta>;\n\n private _smallValues: Heap<HeapItem>;\n private _largeValues: Heap<HeapItem>;\n private _metaExtractor: MetaExtractor<Meta>;\n private _indexExtractor: IndexExtractor<Meta>;\n\n private _onTheFlyIndices: Array<Meta>;\n\n private _isOnTheFlyFull: boolean;\n private _isOnTheFlyFullReturnHook: ReturnHook;\n\n private _loopMS: number;\n private _lastUpdatedMS: number;\n\n constructor(props: IntegerBufferSetProps<Meta> = {}) {\n const {\n name = 'default_buffer',\n indexExtractor,\n bufferSize = defaultBufferSize,\n metaExtractor = defaultMetaExtractor,\n } = props;\n this._metaExtractor = metaExtractor;\n this._indexExtractor = indexExtractor;\n\n this._name = name;\n\n /**\n * this._indexToMetaMap is used to find the prev meta when finding a position for index.\n */\n this._indexToMetaMap = new Map();\n this._metaToPositionMap = new Map();\n this._positionToMetaList = [];\n this._metaToIndexMap = new Map();\n this._onTheFlyIndices = [];\n\n this._bufferSize = bufferSize;\n\n this._smallValues = new Heap([], this._smallerComparator);\n this._largeValues = new Heap([], this._greaterComparator);\n\n this.getNewPositionForIndex = this.getNewPositionForIndex.bind(this);\n this.getIndexPosition = this.getIndexPosition.bind(this);\n this.replaceFurthestIndexPosition =\n this.replaceFurthestIndexPosition.bind(this);\n this._isOnTheFlyFullReturnHook = returnHook(\n this.setIsOnTheFlyFull.bind(this)\n );\n\n this._loopMS = Date.now();\n this._lastUpdatedMS = this._loopMS;\n }\n\n get bufferSize() {\n return this._bufferSize;\n }\n\n isThresholdMeta(meta) {\n if (typeof meta === 'number' && meta > thresholdNumber) return true;\n return false;\n }\n\n setIsOnTheFlyFull(val: any) {\n if (val != null) {\n const data = this._onTheFlyIndices.filter((v) => v != null);\n this._isOnTheFlyFull = data.length === this._bufferSize;\n // console.log('fly ', this._isOnTheFlyFull, data.length, this._bufferSize);\n }\n }\n\n resetOnTheFlies() {\n this._isOnTheFlyFull = false;\n this._onTheFlyIndices = [];\n }\n\n get isBufferFull() {\n return this._positionToMetaList.length >= this._bufferSize;\n }\n\n getOnTheFlyUncriticalPosition(safeRange: SafeRange) {\n const { startIndex, endIndex } = safeRange;\n for (let idx = 0; idx < this._onTheFlyIndices.length; idx++) {\n const meta = this._onTheFlyIndices[idx];\n const metaIndex = this.getMetaIndex(meta);\n if (!isClamped(startIndex, metaIndex, endIndex)) {\n return idx;\n }\n }\n return null;\n }\n\n initialize() {\n return {\n smallValues: new Heap([], this._smallerComparator),\n largeValues: new Heap([], this._greaterComparator),\n };\n }\n\n getIndexMeta(index: number) {\n if (index == null || index < 0) return null;\n return this._metaExtractor(index);\n }\n\n getMetaIndex(meta: Meta) {\n if (meta == null) return -1;\n if (this.isThresholdMeta(meta)) return -1;\n if (this._indexExtractor) return this._indexExtractor(meta);\n return this._metaToIndexMap.get(meta);\n }\n\n setMetaIndex(meta: Meta, index: number) {\n if (!this._indexExtractor) {\n return this._metaToIndexMap.set(meta, index);\n }\n return false;\n }\n\n deleteMetaIndex(meta: Meta) {\n return this._metaToIndexMap.delete(meta);\n }\n\n replaceMetaToIndexMap(newMetaToIndexMap: MetaToIndexMap<Meta>) {\n if (!this._indexExtractor) {\n return (this._metaToIndexMap = newMetaToIndexMap);\n }\n return false;\n }\n\n getIndexPosition(index: number): undefined | number {\n return this.getMetaIndex(this.getIndexMeta(index));\n }\n\n getNewPositionForIndex(index: number) {\n const meta = this.getIndexMeta(index);\n invariant(\n this._metaToPositionMap.get(meta) === undefined,\n \"Shouldn't try to find new position for value already stored in BufferSet\"\n );\n const newPosition = this._positionToMetaList.length;\n\n this._pushToHeaps(newPosition, index);\n this._setMetaIndex(meta, index);\n this._setMetaPosition(meta, newPosition);\n\n return newPosition;\n }\n\n getMinValue() {\n return this._smallValues.peek()?.value;\n }\n\n getMaxValue() {\n return this._largeValues.peek()?.value;\n }\n\n getFliedPosition(newIndex: number, safeRange: SafeRange) {\n if (this._isOnTheFlyFull) {\n // newIndex is not critical index, do nothing\n if (\n safeRange &&\n isClamped(safeRange.startIndex, newIndex, safeRange.endIndex)\n ) {\n return this.getOnTheFlyUncriticalPosition(safeRange);\n }\n // if `newIndex` is critical index, replace an un-committed\n // index value from _onTheFlyIndices.\n // const pos = this.getOnTheFlyUncriticalPosition(safeRange);\n // if (pos != null) return pos;\n }\n return null;\n }\n\n /**\n *\n * @param newIndex\n * @param safeRange\n * @returns\n *\n *\n * _positionToMetaList maybe undefined on next loop\n */\n getPosition(newIndex: number, safeRange?: SafeRange) {\n this.prepare();\n const meta = this.getIndexMeta(newIndex);\n const metaPosition = this._metaToPositionMap.get(meta);\n let position, indexMeta;\n\n // if (this._name === 'normal_goods')\n // console.log(\n // 'getPosition ',\n // newIndex,\n // !this.isBufferFull,\n // this._isOnTheFlyFull,\n // this._onTheFlyIndices.slice(),\n // this._indexToMetaMap.get(newIndex),\n // this._metaToPositionMap.get(this._indexToMetaMap.get(newIndex))\n // );\n\n if (metaPosition !== undefined) {\n position = this.commitPosition({\n newIndex,\n meta,\n safeRange,\n position: metaPosition,\n });\n } else if (!this.isBufferFull) {\n /** placed on new buffered position */\n position = this.getNewPositionForIndex(newIndex);\n } else if (this._isOnTheFlyFull) {\n position = this.getFliedPosition(newIndex, safeRange);\n } else if (\n (indexMeta = this._indexToMetaMap.get(newIndex)) &&\n this._metaToPositionMap.get(indexMeta) != null\n ) {\n /**\n Index has already been stored, but we cant use its old position directly...\n 1:index -> meta, meta may be reused later\n 2: temp use index -> meta -> position, this issue should exist for follows...\n */\n position = this.commitPosition({\n newIndex,\n meta,\n safeRange,\n position: this._metaToPositionMap.get(indexMeta),\n });\n } else {\n this._cleanHeaps();\n // console.log('commeit ---')\n position = this.commitPosition({\n newIndex,\n meta,\n safeRange,\n position: this._replaceFurthestIndexPosition(newIndex, safeRange),\n });\n }\n\n // console.log('position ', position)\n\n if (position != null) {\n this._onTheFlyIndices[position] = meta;\n this._setMetaIndex(meta, newIndex);\n this._metaToPositionMap.set(meta, position);\n\n // this._setMetaPosition(meta, position);\n // should not push to heap, pop only\n // this._pushToHeaps(position, newIndex)\n\n return this._isOnTheFlyFullReturnHook(position);\n }\n\n return null;\n }\n\n replaceFurthestIndexPosition(\n newIndex: number,\n safeRange?: {\n startIndex: number;\n endIndex: number;\n }\n ) {\n if (!this.isBufferFull) {\n return this._isOnTheFlyFullReturnHook(\n this.getNewPositionForIndex(newIndex)\n );\n }\n\n return this._replaceFurthestIndexPosition(newIndex, safeRange);\n }\n\n _replaceFurthestIndexPosition(\n newIndex: number,\n safeRange?: {\n startIndex: number;\n endIndex: number;\n }\n ) {\n if (this._largeValues.empty() || this._smallValues.empty()) {\n return this._isOnTheFlyFullReturnHook(\n this.getNewPositionForIndex(newIndex)\n );\n }\n\n let indexToReplace;\n\n const minValue = this._smallValues.peek()!.value;\n const maxValue = this._largeValues.peek()!.value;\n\n // console.log('mathc ', maxValue, maxValue > thresholdNumber)\n if (maxValue > thresholdNumber) {\n indexToReplace = maxValue;\n this._largeValues.pop();\n const replacedMeta = this._indexToMetaMap.get(indexToReplace);\n\n const position = this._metaToPositionMap.get(replacedMeta);\n return position;\n }\n\n if (!safeRange) {\n // far from min\n if (Math.abs(newIndex - minValue) > Math.abs(newIndex - maxValue)) {\n indexToReplace = minValue;\n this._smallValues.pop();\n } else {\n indexToReplace = maxValue;\n this._largeValues.pop();\n }\n const replacedMeta = this._indexToMetaMap.get(indexToReplace);\n const position = this._metaToPositionMap.get(replacedMeta);\n\n return position;\n }\n\n const { startIndex: lowValue, endIndex: highValue } = safeRange;\n\n // All values currently stored are necessary, we can't reuse any of them.\n if (\n isClamped(lowValue, minValue, highValue) &&\n isClamped(lowValue, maxValue, highValue)\n ) {\n return null;\n } else if (\n isClamped(lowValue, minValue, highValue) &&\n !isClamped(lowValue, maxValue, highValue)\n ) {\n indexToReplace = maxValue;\n this._largeValues.pop();\n } else if (\n !isClamped(lowValue, minValue, highValue) &&\n isClamped(lowValue, maxValue, highValue)\n ) {\n indexToReplace = minValue;\n this._smallValues.pop();\n } else if (lowValue - minValue > maxValue - highValue) {\n // minValue is further from provided range. We will reuse it's position.\n indexToReplace = minValue;\n this._smallValues.pop();\n } else {\n indexToReplace = maxValue;\n this._largeValues.pop();\n }\n\n const replacedMeta = this._indexToMetaMap.get(indexToReplace);\n const position = this._metaToPositionMap.get(replacedMeta);\n\n // console.log('index ', indexToReplace, replacedMeta, position)\n\n return position;\n }\n\n shuffle() {\n const indices = new Array(this.bufferSize);\n for (let idx = 0; idx < indices.length; idx++) {\n const meta = this._onTheFlyIndices[idx] || this._positionToMetaList[idx];\n // console.log('ix ', idx,this.getMetaIndex(meta) )\n const targetIndex = this.getMetaIndex(meta);\n indices[idx] = targetIndex;\n }\n\n // console.log(\n // 'indices ',\n // this._positionToMetaList,\n // this._onTheFlyIndices.slice(),\n // indices\n // );\n\n const _arr = new Array(indices.length);\n const _available = [];\n const indexToMetaMap = new Map();\n const metaToIndexMap = new Map();\n\n for (let idx = 0; idx < indices.length; idx++) {\n const currentIndex = indices[idx];\n const currentMeta = this._metaExtractor(currentIndex);\n // console.log(\"current \", currentIndex, currentMeta)\n if (currentMeta == null) continue;\n indexToMetaMap.set(currentIndex, currentMeta);\n metaToIndexMap.set(currentMeta, currentIndex);\n if (currentMeta === this._positionToMetaList[idx]) {\n _arr[idx] = currentMeta;\n continue;\n }\n const _i = this._positionToMetaList.findIndex((v) => v === currentMeta);\n if (_i !== -1) {\n _arr[_i] = currentMeta;\n continue;\n }\n\n _available.push(currentMeta);\n }\n\n const positionToMetaList = [];\n this._indexToMetaMap = indexToMetaMap;\n this.replaceMetaToIndexMap(metaToIndexMap);\n\n for (let position = 0; position < indices.length; position++) {\n if (_arr[position] != null) {\n positionToMetaList[position] = _arr[position];\n continue;\n }\n const meta = _available.shift();\n if (meta != null) {\n positionToMetaList[position] = meta;\n }\n }\n\n this._positionToMetaList = positionToMetaList;\n\n return this.getIndices();\n }\n\n // key point: `meta` should be preserved..\n getIndices() {\n const { smallValues, largeValues } = this.initialize();\n\n try {\n const indices = new Array(this._positionToMetaList.length);\n const metaToPositionMap = new Map();\n const indexToMetaMap = new Map();\n const metaToIndexMap = new Map();\n for (let idx = 0; idx < indices.length; idx++) {\n const meta =\n this._onTheFlyIndices[idx] || this._positionToMetaList[idx];\n const targetIndex = this.getMetaIndex(meta);\n // which means source data has changed. such as one element has been deleted\n if (\n !this.isThresholdMeta(meta) &&\n meta != this.getIndexMeta(targetIndex)\n ) {\n return this.shuffle();\n }\n if (meta != null && !this.isThresholdMeta(meta)) {\n const element = { position: idx, value: targetIndex };\n smallValues.push(element);\n largeValues.push(element);\n metaToPositionMap.set(meta, idx);\n indexToMetaMap.set(targetIndex, meta);\n metaToIndexMap.set(meta, targetIndex);\n indices[idx] = {\n meta,\n targetIndex,\n recyclerKey: `${this._name}_${idx}`,\n };\n }\n }\n this._smallValues = smallValues;\n this._largeValues = largeValues;\n this._metaToPositionMap = metaToPositionMap;\n this._positionToMetaList = indices.map((v) => v?.meta);\n this.resetOnTheFlies();\n this._indexToMetaMap = indexToMetaMap;\n this.replaceMetaToIndexMap(metaToIndexMap);\n\n return indices;\n } catch (err) {\n console.log('err ', err);\n return this._positionToMetaList;\n } finally {\n this.readyToStartNextLoop();\n // clear on the fly indices after return indices.\n }\n }\n\n _pushToHeaps(position: number, value: number) {\n const element = { position, value };\n // We can reuse the same object in both heaps, because we don't mutate them\n this._smallValues.push(element);\n this._largeValues.push(element);\n }\n\n _setMetaPosition(meta: Meta, position: number) {\n // do not delete meta2position; because getPosition will get by meta first...\n // const prevMetaOnPosition = this._positionToMetaList[position];\n // if (prevMetaOnPosition) this._metaToPositionMap.delete(prevMetaOnPosition);\n this._positionToMetaList[position] = meta;\n this._metaToPositionMap.set(meta, position);\n }\n\n commitPosition(props: {\n newIndex: number;\n position: number;\n meta: Meta;\n safeRange: SafeRange;\n }) {\n const { newIndex, safeRange, position, meta } = props;\n const onTheFlyPositionMeta = this._onTheFlyIndices[position];\n let positionToReplace = position;\n\n // console.log('position ', newIndex, position);\n\n if (onTheFlyPositionMeta) {\n // such as place item 11 twice...\n if (onTheFlyPositionMeta === meta) return position;\n if (this._isOnTheFlyFull)\n return this.getFliedPosition(newIndex, safeRange);\n positionToReplace = this._replaceFurthestIndexPosition(\n newIndex,\n safeRange\n );\n\n while (this._onTheFlyIndices[positionToReplace]) {\n positionToReplace = this._replaceFurthestIndexPosition(\n newIndex,\n safeRange\n );\n }\n }\n return positionToReplace;\n }\n\n /**\n *\n * @param meta\n * @param index\n * @returns true means index not changed\n */\n _setMetaIndex(meta: Meta, index: number) {\n const prevMetaIndex = this.getMetaIndex(meta);\n if (prevMetaIndex !== undefined) {\n // no need to set\n // if (prevMetaIndex === index) return true;\n this._indexToMetaMap.delete(prevMetaIndex);\n }\n this.setMetaIndex(meta, index);\n this._indexToMetaMap.set(index, meta);\n return false;\n }\n\n readyToStartNextLoop() {\n this._lastUpdatedMS = Date.now();\n }\n\n prepare() {\n if (this._loopMS === this._lastUpdatedMS) return;\n this._loopMS = this._lastUpdatedMS;\n\n this._onTheFlyIndices = [];\n this._isOnTheFlyFull = false;\n }\n\n _cleanHeaps() {\n // We not usually only remove object from one heap while moving value.\n // Here we make sure that there is no stale data on top of heaps.\n // this._cleanHeap(this._smallValues);\n // this._cleanHeap(this._largeValues);\n\n for (let idx = 0; idx < this._positionToMetaList.length; idx++) {\n if (this._positionToMetaList[idx] == null) {\n this._recreateHeaps();\n return;\n }\n }\n\n const minHeapSize = Math.min(\n this._smallValues.size(),\n this._largeValues.size()\n );\n const maxHeapSize = Math.max(\n this._smallValues.size(),\n this._largeValues.size()\n );\n if (maxHeapSize > 10 * minHeapSize) {\n // There are many old values in one of heaps. We need to get rid of them\n // to not use too avoid memory leaks\n this._recreateHeaps();\n }\n }\n _recreateHeaps() {\n const { smallValues, largeValues } = this.initialize();\n for (\n let position = 0;\n position < this._positionToMetaList.length;\n position++\n ) {\n const meta = this._positionToMetaList[position];\n let value = this.getMetaIndex(meta);\n\n if (!meta || value === -1 || value == null) {\n value = Number.MAX_SAFE_INTEGER - position;\n }\n\n const element = { position, value };\n smallValues.push(element);\n largeValues.push(element);\n if (value > thresholdNumber) {\n // @ts-ignore\n this._setMetaPosition(value, position);\n // @ts-ignore\n this._setMetaIndex(value, value);\n }\n }\n\n // this._largeValues.peek().value;\n\n this._smallValues = smallValues;\n this._largeValues = largeValues;\n }\n\n // _cleanHeap(heap: Heap<HeapItem>) {\n // while (\n // !heap.empty() &&\n // this._metaToPositionMap.get(\n // this._indexToMetaMap.get(heap.peek()!.value)\n // ) == null\n // ) {\n // console.log('pop ---', heap.peek()!.value);\n // heap.pop();\n // }\n // }\n\n _smallerComparator(lhs: HeapItem, rhs: HeapItem) {\n return lhs.value < rhs.value;\n }\n\n _greaterComparator(lhs: HeapItem, rhs: HeapItem) {\n return lhs.value > rhs.value;\n }\n}\n\nexport default IntegerBufferSet;\n"],"names":["defaultMetaExtractor","value","defaultBufferSize","thresholdNumber","Number","MAX_SAFE_INTEGER","IntegerBufferSet","props","_props","_props$name","name","indexExtractor","_props$bufferSize","bufferSize","_props$metaExtractor","metaExtractor","_metaExtractor","_indexExtractor","_name","_indexToMetaMap","Map","_metaToPositionMap","_positionToMetaList","_metaToIndexMap","_onTheFlyIndices","_bufferSize","_smallValues","Heap","_smallerComparator","_largeValues","_greaterComparator","getNewPositionForIndex","bind","getIndexPosition","replaceFurthestIndexPosition","_isOnTheFlyFullReturnHook","returnHook","setIsOnTheFlyFull","_loopMS","Date","now","_lastUpdatedMS","_proto","prototype","isThresholdMeta","meta","val","data","filter","v","_isOnTheFlyFull","length","resetOnTheFlies","getOnTheFlyUncriticalPosition","safeRange","startIndex","endIndex","idx","metaIndex","getMetaIndex","isClamped","initialize","smallValues","largeValues","getIndexMeta","index","get","setMetaIndex","set","deleteMetaIndex","replaceMetaToIndexMap","newMetaToIndexMap","undefined","invariant","newPosition","_pushToHeaps","_setMetaIndex","_setMetaPosition","getMinValue","_this$_smallValues$pe","peek","getMaxValue","_this$_largeValues$pe","getFliedPosition","newIndex","getPosition","prepare","metaPosition","position","indexMeta","commitPosition","isBufferFull","_cleanHeaps","_replaceFurthestIndexPosition","empty","indexToReplace","minValue","maxValue","pop","replacedMeta","Math","abs","lowValue","highValue","shuffle","indices","Array","targetIndex","_arr","_available","indexToMetaMap","metaToIndexMap","_loop","currentIndex","currentMeta","_this","_i","findIndex","push","_ret","positionToMetaList","shift","getIndices","_this$initialize","metaToPositionMap","element","recyclerKey","map","err","console","log","readyToStartNextLoop","onTheFlyPositionMeta","positionToReplace","prevMetaIndex","_recreateHeaps","minHeapSize","min","size","maxHeapSize","max","_this$initialize2","lhs","rhs","_createClass","key"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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0E,gBAAgB,CAAC5E,KAAK,EAAEuF,QAAQ,CAAC;QAEtC,IAAI,CAACZ,aAAa,CAAC3E,KAAK,EAAEA,KAAK,CAAC;;;IAMpC,IAAI,CAACyB,YAAY,GAAGoC,WAAW;IAC/B,IAAI,CAACjC,YAAY,GAAGkC,WAAW;GAChC;EAAArB,MAAA,CAcDd,kBAAkB,GAAlB,SAAAA,mBAAmBkH,GAAa,EAAEC,GAAa;IAC7C,OAAOD,GAAG,CAAC7I,KAAK,GAAG8I,GAAG,CAAC9I,KAAK;GAC7B;EAAAyC,MAAA,CAEDZ,kBAAkB,GAAlB,SAAAA,mBAAmBgH,GAAa,EAAEC,GAAa;IAC7C,OAAOD,GAAG,CAAC7I,KAAK,GAAG8I,GAAG,CAAC9I,KAAK;GAC7B;EAAA+I,YAAA,CAAA1I,gBAAA;IAAA2I,GAAA;IAAA/E,GAAA,EAljBD,SAAAA;MACE,OAAO,IAAI,CAACzC,WAAW;;;IACxBwH,GAAA;IAAA/E,GAAA,EAoBD,SAAAA;MACE,OAAO,IAAI,CAAC5C,mBAAmB,CAAC6B,MAAM,IAAI,IAAI,CAAC1B,WAAW;;;EAC3D,OAAAnB,gBAAA;AAAA;;;;;"}
|
|
1
|
+
{"version":3,"file":"integer-buffer-set.cjs.development.js","sources":["../src/index.ts"],"sourcesContent":["import Heap from '@x-oasis/heap';\nimport isClamped from '@x-oasis/is-clamped';\nimport invariant from '@x-oasis/invariant';\nimport returnHook, { ReturnHook } from '@x-oasis/return-hook';\nimport {\n HeapItem,\n SafeRange,\n MetaExtractor,\n IndexExtractor,\n IntegerBufferSetProps,\n MetaToIndexMap,\n MetaToPositionMap,\n IndexToMetaMap,\n} from './types';\n\nconst defaultMetaExtractor = (value) => value;\nexport const defaultBufferSize = 10;\nconst thresholdNumber = Number.MAX_SAFE_INTEGER - 100000;\nconst assertThresholdNumber = (val: any) =>\n typeof val === 'number' && val > thresholdNumber;\n\n// !!!!! should do meta validation...meta should has an index...\n// value: original data `index` value\n// value(index) => meta => position\n// `index to getIndices, meta to find index`\n\n// Data structure that allows to store values and assign positions to them\n// in a way to minimize changing positions of stored values when new ones are\n// added or when some values are replaced. Stored elements are alwasy assigned\n// a consecutive set of positoins startin from 0 up to count of elements less 1\n// Following actions can be executed\n// * get position assigned to given value (null if value is not stored)\n// * create new entry for new value and get assigned position back\n// * replace value that is furthest from specified value range with new value\n// and get it's position back\n// All operations take amortized log(n) time where n is number of elements in\n// the set.\n// feature: add / delete / update item will also in consider..\nclass IntegerBufferSet<Meta = any> {\n private _name: string;\n private _bufferSize: number;\n\n private _indexToMetaMap: IndexToMetaMap<Meta>;\n private _metaToPositionMap: MetaToPositionMap<Meta>;\n private _positionToMetaList: Array<Meta>;\n private _metaToIndexMap: MetaToIndexMap<Meta>;\n\n private _smallValues: Heap<HeapItem>;\n private _largeValues: Heap<HeapItem>;\n private _metaExtractor: MetaExtractor<Meta>;\n private _indexExtractor: IndexExtractor<Meta>;\n\n private _onTheFlyIndices: Array<Meta>;\n\n private _isOnTheFlyFull: boolean;\n private _isOnTheFlyFullReturnHook: ReturnHook;\n\n private _loopMS: number;\n private _lastUpdatedMS: number;\n\n constructor(props: IntegerBufferSetProps<Meta> = {}) {\n const {\n name = 'default_buffer',\n indexExtractor,\n bufferSize = defaultBufferSize,\n metaExtractor = defaultMetaExtractor,\n } = props;\n this._metaExtractor = metaExtractor;\n this._indexExtractor = indexExtractor;\n\n this._name = name;\n\n /**\n * this._indexToMetaMap is used to find the prev meta when finding a position for index.\n */\n this._indexToMetaMap = new Map();\n this._metaToPositionMap = new Map();\n this._positionToMetaList = [];\n this._metaToIndexMap = new Map();\n this._onTheFlyIndices = [];\n\n this._bufferSize = bufferSize;\n\n this._smallValues = new Heap([], this._smallerComparator);\n this._largeValues = new Heap([], this._greaterComparator);\n\n this.getNewPositionForIndex = this.getNewPositionForIndex.bind(this);\n this.getIndexPosition = this.getIndexPosition.bind(this);\n this.replaceFurthestIndexPosition =\n this.replaceFurthestIndexPosition.bind(this);\n this._isOnTheFlyFullReturnHook = returnHook(\n this.setIsOnTheFlyFull.bind(this)\n );\n\n this._loopMS = Date.now();\n this._lastUpdatedMS = this._loopMS;\n }\n\n get bufferSize() {\n return this._bufferSize;\n }\n\n setIsOnTheFlyFull(val: any) {\n if (val != null) {\n const data = this._onTheFlyIndices.filter((v) => v != null);\n this._isOnTheFlyFull = data.length === this._bufferSize;\n // console.log('fly ', this._isOnTheFlyFull, data.length, this._bufferSize);\n }\n }\n\n resetOnTheFlies() {\n this._isOnTheFlyFull = false;\n this._onTheFlyIndices = [];\n }\n\n get isBufferFull() {\n return this._positionToMetaList.length >= this._bufferSize;\n }\n\n getOnTheFlyUncriticalPosition(safeRange: SafeRange) {\n const { startIndex, endIndex } = safeRange;\n for (let idx = 0; idx < this._onTheFlyIndices.length; idx++) {\n const meta = this._onTheFlyIndices[idx];\n const metaIndex = this.getMetaIndex(meta);\n if (!isClamped(startIndex, metaIndex, endIndex)) {\n return idx;\n }\n }\n return null;\n }\n\n initialize() {\n return {\n smallValues: new Heap([], this._smallerComparator),\n largeValues: new Heap([], this._greaterComparator),\n };\n }\n\n getIndexMeta(index: number) {\n try {\n if (index == null || index < 0) return null;\n return this._metaExtractor(index);\n } catch (err) {\n return null;\n }\n }\n\n getMetaIndex(meta: Meta) {\n try {\n if (meta == null) return -1;\n if (assertThresholdNumber(meta)) return -1;\n if (this._indexExtractor) return this._indexExtractor(meta);\n return this._metaToIndexMap.get(meta);\n } catch (err) {\n return -1;\n }\n }\n\n setMetaIndex(meta: Meta, index: number) {\n if (!this._indexExtractor) {\n return this._metaToIndexMap.set(meta, index);\n }\n return false;\n }\n\n deleteMetaIndex(meta: Meta) {\n return this._metaToIndexMap.delete(meta);\n }\n\n replaceMetaToIndexMap(newMetaToIndexMap: MetaToIndexMap<Meta>) {\n if (!this._indexExtractor) {\n return (this._metaToIndexMap = newMetaToIndexMap);\n }\n return false;\n }\n\n getIndexPosition(index: number): undefined | number {\n return this.getMetaIndex(this.getIndexMeta(index));\n }\n\n getNewPositionForIndex(index: number) {\n const meta = this.getIndexMeta(index);\n invariant(\n this._metaToPositionMap.get(meta) === undefined,\n \"Shouldn't try to find new position for value already stored in BufferSet\"\n );\n const newPosition = this._positionToMetaList.length;\n\n this._pushToHeaps(newPosition, index);\n this._setMetaIndex(meta, index);\n this._setMetaPosition(meta, newPosition);\n\n return newPosition;\n }\n\n _peek(heap: Heap) {\n return heap.peek();\n }\n\n _getMaxItem() {\n return this._peek(this._largeValues);\n }\n\n _getMinItem() {\n return this._peek(this._smallValues);\n }\n\n _getMinValue() {\n return this._peek(this._smallValues)?.value;\n }\n\n _getMaxValue() {\n return this._peek(this._largeValues)?.value;\n }\n\n // should omit thresholdNumber\n getMaxValue() {\n const stack = [];\n let item;\n\n while ((item = this._getMaxItem()) && assertThresholdNumber(item?.value)) {\n stack.push(item);\n this._largeValues.pop();\n }\n\n let stackItem;\n while ((stackItem = stack.pop())) {\n this._largeValues.push(stackItem);\n }\n\n return item?.value;\n }\n\n getMinValue() {\n const stack = [];\n let item;\n\n while ((item = this._getMinItem()) && assertThresholdNumber(item?.value)) {\n stack.push(item);\n this._smallValues.pop();\n }\n\n let stackItem;\n while ((stackItem = stack.pop())) {\n this._smallValues.push(stackItem);\n }\n\n return item?.value;\n }\n\n _push(heap: Heap, item: HeapItem) {\n heap.push(item);\n }\n\n getFliedPosition(newIndex: number, safeRange: SafeRange) {\n if (this._isOnTheFlyFull) {\n // newIndex is not critical index, do nothing\n if (\n safeRange &&\n isClamped(safeRange.startIndex, newIndex, safeRange.endIndex)\n ) {\n return this.getOnTheFlyUncriticalPosition(safeRange);\n }\n // if `newIndex` is critical index, replace an un-committed\n // index value from _onTheFlyIndices.\n // const pos = this.getOnTheFlyUncriticalPosition(safeRange);\n // if (pos != null) return pos;\n }\n return null;\n }\n\n /**\n *\n * @param newIndex\n * @param safeRange\n * @returns\n *\n *\n * _positionToMetaList maybe undefined on next loop\n */\n getPosition(newIndex: number, safeRange?: SafeRange) {\n this.prepare();\n const meta = this.getIndexMeta(newIndex);\n const metaPosition = this._metaToPositionMap.get(meta);\n let position, indexMeta;\n\n // if (this._name === 'normal_goods')\n // console.log(\n // 'getPosition ',\n // newIndex,\n // !this.isBufferFull,\n // this._isOnTheFlyFull,\n // this._onTheFlyIndices.slice(),\n // this._indexToMetaMap.get(newIndex),\n // this._metaToPositionMap.get(this._indexToMetaMap.get(newIndex))\n // );\n\n if (metaPosition !== undefined) {\n position = this.commitPosition({\n newIndex,\n meta,\n safeRange,\n position: metaPosition,\n });\n } else if (!this.isBufferFull) {\n /** placed on new buffered position */\n position = this.getNewPositionForIndex(newIndex);\n } else if (this._isOnTheFlyFull) {\n position = this.getFliedPosition(newIndex, safeRange);\n } else if (\n (indexMeta = this._indexToMetaMap.get(newIndex)) &&\n this._metaToPositionMap.get(indexMeta) != null\n ) {\n /**\n Index has already been stored, but we cant use its old position directly...\n 1:index -> meta, meta may be reused later\n 2: temp use index -> meta -> position, this issue should exist for follows...\n */\n position = this.commitPosition({\n newIndex,\n meta,\n safeRange,\n position: this._metaToPositionMap.get(indexMeta),\n });\n } else {\n this._cleanHeaps();\n position = this.commitPosition({\n newIndex,\n meta,\n safeRange,\n position: this._replaceFurthestIndexPosition(newIndex, safeRange),\n });\n }\n\n // console.log('position ', position)\n\n if (position != null) {\n this._onTheFlyIndices[position] = meta;\n this._setMetaIndex(meta, newIndex);\n this._metaToPositionMap.set(meta, position);\n\n // this._setMetaPosition(meta, position);\n // should not push to heap, pop only\n // this._pushToHeaps(position, newIndex)\n\n return this._isOnTheFlyFullReturnHook(position);\n }\n\n return null;\n }\n\n replaceFurthestIndexPosition(\n newIndex: number,\n safeRange?: {\n startIndex: number;\n endIndex: number;\n }\n ) {\n if (!this.isBufferFull) {\n return this._isOnTheFlyFullReturnHook(\n this.getNewPositionForIndex(newIndex)\n );\n }\n\n return this._replaceFurthestIndexPosition(newIndex, safeRange);\n }\n\n _replaceFurthestIndexPosition(\n newIndex: number,\n safeRange?: {\n startIndex: number;\n endIndex: number;\n }\n ) {\n if (this._largeValues.empty() || this._smallValues.empty()) {\n return this._isOnTheFlyFullReturnHook(\n this.getNewPositionForIndex(newIndex)\n );\n }\n\n let indexToReplace;\n\n const minValue = this._getMinValue();\n const maxValue = this._getMaxValue();\n\n if (assertThresholdNumber(maxValue)) {\n indexToReplace = maxValue;\n this._largeValues.pop();\n const replacedMeta = this._indexToMetaMap.get(indexToReplace);\n\n const position = this._metaToPositionMap.get(replacedMeta);\n return position;\n }\n\n if (!safeRange) {\n // far from min\n if (Math.abs(newIndex - minValue) > Math.abs(newIndex - maxValue)) {\n indexToReplace = minValue;\n this._smallValues.pop();\n } else {\n indexToReplace = maxValue;\n this._largeValues.pop();\n }\n const replacedMeta = this._indexToMetaMap.get(indexToReplace);\n const position = this._metaToPositionMap.get(replacedMeta);\n\n return position;\n }\n\n const { startIndex: lowValue, endIndex: highValue } = safeRange;\n\n // All values currently stored are necessary, we can't reuse any of them.\n if (\n isClamped(lowValue, minValue, highValue) &&\n isClamped(lowValue, maxValue, highValue)\n ) {\n return null;\n } else if (\n isClamped(lowValue, minValue, highValue) &&\n !isClamped(lowValue, maxValue, highValue)\n ) {\n indexToReplace = maxValue;\n this._largeValues.pop();\n } else if (\n !isClamped(lowValue, minValue, highValue) &&\n isClamped(lowValue, maxValue, highValue)\n ) {\n indexToReplace = minValue;\n this._smallValues.pop();\n } else if (lowValue - minValue > maxValue - highValue) {\n // minValue is further from provided range. We will reuse it's position.\n indexToReplace = minValue;\n this._smallValues.pop();\n } else {\n indexToReplace = maxValue;\n this._largeValues.pop();\n }\n\n const replacedMeta = this._indexToMetaMap.get(indexToReplace);\n const position = this._metaToPositionMap.get(replacedMeta);\n\n // console.log('index ', indexToReplace, replacedMeta, position)\n\n return position;\n }\n\n shuffle(options: { retry: boolean; fallback: boolean }) {\n const indices = new Array(this.bufferSize);\n for (let idx = 0; idx < indices.length; idx++) {\n const meta = this._onTheFlyIndices[idx] || this._positionToMetaList[idx];\n // console.log('ix ', idx,this.getMetaIndex(meta) )\n const targetIndex = this.getMetaIndex(meta);\n indices[idx] = targetIndex;\n }\n\n // console.log(\n // 'indices ',\n // this._positionToMetaList,\n // this._onTheFlyIndices.slice(),\n // indices\n // );\n\n const _arr = new Array(indices.length);\n const _available = [];\n const indexToMetaMap = new Map();\n const metaToIndexMap = new Map();\n\n for (let idx = 0; idx < indices.length; idx++) {\n const currentIndex = indices[idx];\n const currentMeta = this._metaExtractor(currentIndex);\n // console.log(\"current \", currentIndex, currentMeta)\n if (currentMeta == null) continue;\n indexToMetaMap.set(currentIndex, currentMeta);\n metaToIndexMap.set(currentMeta, currentIndex);\n if (currentMeta === this._positionToMetaList[idx]) {\n _arr[idx] = currentMeta;\n continue;\n }\n const _i = this._positionToMetaList.findIndex((v) => v === currentMeta);\n if (_i !== -1) {\n _arr[_i] = currentMeta;\n continue;\n }\n\n _available.push(currentMeta);\n }\n\n const positionToMetaList = [];\n this._indexToMetaMap = indexToMetaMap;\n this.replaceMetaToIndexMap(metaToIndexMap);\n\n for (let position = 0; position < indices.length; position++) {\n if (_arr[position] != null) {\n positionToMetaList[position] = _arr[position];\n continue;\n }\n const meta = _available.shift();\n if (meta != null) {\n positionToMetaList[position] = meta;\n }\n }\n\n this._positionToMetaList = positionToMetaList;\n\n return this.getIndices({\n ...options,\n retry: true,\n });\n }\n\n // key point: `meta` should be preserved..\n getIndices(\n options = {\n retry: false,\n fallback: false,\n }\n ) {\n try {\n const { retry, fallback } = options;\n const { smallValues, largeValues } = this.initialize();\n const indices = new Array(this._positionToMetaList.length);\n const metaToPositionMap = new Map();\n const indexToMetaMap = new Map();\n const metaToIndexMap = new Map();\n for (let idx = 0; idx < indices.length; idx++) {\n const meta = fallback\n ? this._onTheFlyIndices[idx]\n : this._onTheFlyIndices[idx] || this._positionToMetaList[idx];\n const targetIndex = this.getMetaIndex(meta);\n // which means source data has changed. such as one item has been deleted\n if (\n !assertThresholdNumber(meta) &&\n meta != this.getIndexMeta(targetIndex) &&\n !retry\n ) {\n return this.shuffle(options);\n }\n if (meta != null && !assertThresholdNumber(meta)) {\n const item = { position: idx, value: targetIndex };\n this._push(smallValues, item);\n this._push(largeValues, item);\n metaToPositionMap.set(meta, idx);\n indexToMetaMap.set(targetIndex, meta);\n metaToIndexMap.set(meta, targetIndex);\n indices[idx] = {\n meta,\n targetIndex,\n recyclerKey: `${this._name}_${idx}`,\n };\n }\n }\n this._smallValues = smallValues;\n this._largeValues = largeValues;\n this._metaToPositionMap = metaToPositionMap;\n this._positionToMetaList = indices.map((v) => v?.meta);\n this.resetOnTheFlies();\n this._indexToMetaMap = indexToMetaMap;\n this.replaceMetaToIndexMap(metaToIndexMap);\n\n return indices;\n } catch (err) {\n console.log('err ', err);\n return this.getIndices({\n ...options,\n fallback: true,\n });\n } finally {\n this.readyToStartNextLoop();\n // clear on the fly indices after return indices.\n }\n }\n\n _pushToHeaps(position: number, value: number) {\n const item = { position, value };\n // We can reuse the same object in both heaps, because we don't mutate them\n this._push(this._smallValues, item);\n this._push(this._largeValues, item);\n }\n\n _setMetaPosition(meta: Meta, position: number) {\n // do not delete meta2position; because getPosition will get by meta first...\n // const prevMetaOnPosition = this._positionToMetaList[position];\n // if (prevMetaOnPosition) this._metaToPositionMap.delete(prevMetaOnPosition);\n this._positionToMetaList[position] = meta;\n this._metaToPositionMap.set(meta, position);\n }\n\n commitPosition(props: {\n newIndex: number;\n position: number;\n meta: Meta;\n safeRange: SafeRange;\n }) {\n const { newIndex, safeRange, position, meta } = props;\n const onTheFlyPositionMeta = this._onTheFlyIndices[position];\n let positionToReplace = position;\n\n if (onTheFlyPositionMeta) {\n // such as place item 11 twice...\n if (onTheFlyPositionMeta === meta) return position;\n if (this._isOnTheFlyFull)\n return this.getFliedPosition(newIndex, safeRange);\n positionToReplace = this._replaceFurthestIndexPosition(\n newIndex,\n safeRange\n );\n\n while (this._onTheFlyIndices[positionToReplace]) {\n positionToReplace = this._replaceFurthestIndexPosition(\n newIndex,\n safeRange\n );\n }\n }\n return positionToReplace;\n }\n\n /**\n *\n * @param meta\n * @param index\n * @returns true means index not changed\n */\n _setMetaIndex(meta: Meta, index: number) {\n const prevMetaIndex = this.getMetaIndex(meta);\n if (prevMetaIndex !== undefined) {\n // no need to set\n // if (prevMetaIndex === index) return true;\n this._indexToMetaMap.delete(prevMetaIndex);\n }\n this.setMetaIndex(meta, index);\n this._indexToMetaMap.set(index, meta);\n return false;\n }\n\n readyToStartNextLoop() {\n this._lastUpdatedMS = Date.now();\n }\n\n prepare() {\n if (this._loopMS === this._lastUpdatedMS) return;\n this._loopMS = this._lastUpdatedMS;\n\n this._onTheFlyIndices = [];\n this._isOnTheFlyFull = false;\n }\n\n _cleanHeaps() {\n for (let idx = 0; idx < this._positionToMetaList.length; idx++) {\n if (this._positionToMetaList[idx] == null) {\n this._recreateHeaps();\n return;\n }\n }\n\n const minHeapSize = Math.min(\n this._smallValues.size(),\n this._largeValues.size()\n );\n const maxHeapSize = Math.max(\n this._smallValues.size(),\n this._largeValues.size()\n );\n // We not usually only remove object from one heap while moving value.\n // Here we make sure that there is no stale data on top of heaps.\n if (maxHeapSize > 10 * minHeapSize) {\n // There are many old values in one of heaps. We need to get rid of them\n // to not use too avoid memory leaks\n this._recreateHeaps();\n }\n }\n _recreateHeaps() {\n const { smallValues, largeValues } = this.initialize();\n for (\n let position = 0;\n position < this._positionToMetaList.length;\n position++\n ) {\n const meta = this._positionToMetaList[position];\n let value = this.getMetaIndex(meta);\n if (meta == null || value === -1 || value == null) {\n value = Number.MAX_SAFE_INTEGER - position;\n }\n\n const item = { position, value };\n this._push(smallValues, item);\n this._push(largeValues, item);\n if (value > thresholdNumber) {\n // @ts-ignore\n this._setMetaPosition(value, position);\n // @ts-ignore\n this._setMetaIndex(value, value);\n }\n }\n this._smallValues = smallValues;\n this._largeValues = largeValues;\n }\n\n _smallerComparator(lhs: HeapItem, rhs: HeapItem) {\n return lhs.value < rhs.value;\n }\n\n _greaterComparator(lhs: HeapItem, rhs: HeapItem) {\n return lhs.value > rhs.value;\n }\n}\n\nexport default IntegerBufferSet;\n"],"names":["defaultMetaExtractor","value","defaultBufferSize","thresholdNumber","Number","MAX_SAFE_INTEGER","assertThresholdNumber","val","IntegerBufferSet","props","_props","_props$name","name","indexExtractor","_props$bufferSize","bufferSize","_props$metaExtractor","metaExtractor","_metaExtractor","_indexExtractor","_name","_indexToMetaMap","Map","_metaToPositionMap","_positionToMetaList","_metaToIndexMap","_onTheFlyIndices","_bufferSize","_smallValues","Heap","_smallerComparator","_largeValues","_greaterComparator","getNewPositionForIndex","bind","getIndexPosition","replaceFurthestIndexPosition","_isOnTheFlyFullReturnHook","returnHook","setIsOnTheFlyFull","_loopMS","Date","now","_lastUpdatedMS","_proto","prototype","data","filter","v","_isOnTheFlyFull","length","resetOnTheFlies","getOnTheFlyUncriticalPosition","safeRange","startIndex","endIndex","idx","meta","metaIndex","getMetaIndex","isClamped","initialize","smallValues","largeValues","getIndexMeta","index","err","get","setMetaIndex","set","deleteMetaIndex","replaceMetaToIndexMap","newMetaToIndexMap","undefined","invariant","newPosition","_pushToHeaps","_setMetaIndex","_setMetaPosition","_peek","heap","peek","_getMaxItem","_getMinItem","_getMinValue","_this$_peek","_getMaxValue","_this$_peek2","getMaxValue","stack","item","_item","push","pop","stackItem","_item2","getMinValue","_item3","_item4","_push","getFliedPosition","newIndex","getPosition","prepare","metaPosition","position","indexMeta","commitPosition","isBufferFull","_cleanHeaps","_replaceFurthestIndexPosition","empty","indexToReplace","minValue","maxValue","replacedMeta","Math","abs","lowValue","highValue","shuffle","options","indices","Array","targetIndex","_arr","_available","indexToMetaMap","metaToIndexMap","_loop","currentIndex","currentMeta","_this","_i","findIndex","_ret","positionToMetaList","shift","getIndices","_extends","retry","fallback","_options","_this$initialize","metaToPositionMap","recyclerKey","map","console","log","readyToStartNextLoop","onTheFlyPositionMeta","positionToReplace","prevMetaIndex","_recreateHeaps","minHeapSize","min","size","maxHeapSize","max","_this$initialize2","lhs","rhs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OD,GAAG,CAAC/J,KAAK,GAAGgK,GAAG,CAAChK,KAAK;GAC7B;EAAA2C,MAAA,CAEDZ,kBAAkB,GAAlB,SAAAA,mBAAmBgI,GAAa,EAAEC,GAAa;IAC7C,OAAOD,GAAG,CAAC/J,KAAK,GAAGgK,GAAG,CAAChK,KAAK;GAC7B;EAAAiK,YAAA,CAAA1J,gBAAA;IAAA2J,GAAA;IAAAhG,GAAA,EA9lBD,SAAAA;MACE,OAAO,IAAI,CAACxC,WAAW;;;IACxBwI,GAAA;IAAAhG,GAAA,EAeD,SAAAA;MACE,OAAO,IAAI,CAAC3C,mBAAmB,CAAC0B,MAAM,IAAI,IAAI,CAACvB,WAAW;;;EAC3D,OAAAnB,gBAAA;AAAA;;;;;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";function t(t){return t&&"object"==typeof t&&"default"in t?t.default:t}Object.defineProperty(exports,"__esModule",{value:!0});var e=t(require("@x-oasis/heap")),i=t(require("@x-oasis/is-clamped")),
|
|
1
|
+
"use strict";function t(t){return t&&"object"==typeof t&&"default"in t?t.default:t}Object.defineProperty(exports,"__esModule",{value:!0});var e=t(require("@x-oasis/heap")),i=t(require("@x-oasis/is-clamped")),n=t(require("@x-oasis/invariant")),s=t(require("@x-oasis/return-hook"));function a(){return(a=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var i=arguments[e];for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&(t[n]=i[n])}return t}).apply(this,arguments)}var o=function(t){return t},r=Number.MAX_SAFE_INTEGER-1e5,l=function(t){return"number"==typeof t&&t>r};exports.default=function(){function t(t){void 0===t&&(t={});var i=t.name,n=void 0===i?"default_buffer":i,a=t.indexExtractor,r=t.bufferSize,l=void 0===r?10:r,u=t.metaExtractor;this._metaExtractor=void 0===u?o:u,this._indexExtractor=a,this._name=n,this._indexToMetaMap=new Map,this._metaToPositionMap=new Map,this._positionToMetaList=[],this._metaToIndexMap=new Map,this._onTheFlyIndices=[],this._bufferSize=l,this._smallValues=new e([],this._smallerComparator),this._largeValues=new e([],this._greaterComparator),this.getNewPositionForIndex=this.getNewPositionForIndex.bind(this),this.getIndexPosition=this.getIndexPosition.bind(this),this.replaceFurthestIndexPosition=this.replaceFurthestIndexPosition.bind(this),this._isOnTheFlyFullReturnHook=s(this.setIsOnTheFlyFull.bind(this)),this._loopMS=Date.now(),this._lastUpdatedMS=this._loopMS}var u,h,p=t.prototype;return p.setIsOnTheFlyFull=function(t){if(null!=t){var e=this._onTheFlyIndices.filter((function(t){return null!=t}));this._isOnTheFlyFull=e.length===this._bufferSize}},p.resetOnTheFlies=function(){this._isOnTheFlyFull=!1,this._onTheFlyIndices=[]},p.getOnTheFlyUncriticalPosition=function(t){for(var e=t.startIndex,n=t.endIndex,s=0;s<this._onTheFlyIndices.length;s++){var a=this.getMetaIndex(this._onTheFlyIndices[s]);if(!i(e,a,n))return s}return null},p.initialize=function(){return{smallValues:new e([],this._smallerComparator),largeValues:new e([],this._greaterComparator)}},p.getIndexMeta=function(t){try{return null==t||t<0?null:this._metaExtractor(t)}catch(t){return null}},p.getMetaIndex=function(t){try{return null==t||l(t)?-1:this._indexExtractor?this._indexExtractor(t):this._metaToIndexMap.get(t)}catch(t){return-1}},p.setMetaIndex=function(t,e){return!this._indexExtractor&&this._metaToIndexMap.set(t,e)},p.deleteMetaIndex=function(t){return this._metaToIndexMap.delete(t)},p.replaceMetaToIndexMap=function(t){return!this._indexExtractor&&(this._metaToIndexMap=t)},p.getIndexPosition=function(t){return this.getMetaIndex(this.getIndexMeta(t))},p.getNewPositionForIndex=function(t){var e=this.getIndexMeta(t);void 0!==this._metaToPositionMap.get(e)&&n(!1);var i=this._positionToMetaList.length;return this._pushToHeaps(i,t),this._setMetaIndex(e,t),this._setMetaPosition(e,i),i},p._peek=function(t){return t.peek()},p._getMaxItem=function(){return this._peek(this._largeValues)},p._getMinItem=function(){return this._peek(this._smallValues)},p._getMinValue=function(){var t;return null==(t=this._peek(this._smallValues))?void 0:t.value},p._getMaxValue=function(){var t;return null==(t=this._peek(this._largeValues))?void 0:t.value},p.getMaxValue=function(){for(var t,e,i,n=[];(e=this._getMaxItem())&&l(null==(s=e)?void 0:s.value);){var s;n.push(e),this._largeValues.pop()}for(;i=n.pop();)this._largeValues.push(i);return null==(t=e)?void 0:t.value},p.getMinValue=function(){for(var t,e,i,n=[];(e=this._getMinItem())&&l(null==(s=e)?void 0:s.value);){var s;n.push(e),this._smallValues.pop()}for(;i=n.pop();)this._smallValues.push(i);return null==(t=e)?void 0:t.value},p._push=function(t,e){t.push(e)},p.getFliedPosition=function(t,e){return this._isOnTheFlyFull&&e&&i(e.startIndex,t,e.endIndex)?this.getOnTheFlyUncriticalPosition(e):null},p.getPosition=function(t,e){this.prepare();var i,n,s=this.getIndexMeta(t),a=this._metaToPositionMap.get(s);return void 0!==a?i=this.commitPosition({newIndex:t,meta:s,safeRange:e,position:a}):this.isBufferFull?this._isOnTheFlyFull?i=this.getFliedPosition(t,e):(n=this._indexToMetaMap.get(t))&&null!=this._metaToPositionMap.get(n)?i=this.commitPosition({newIndex:t,meta:s,safeRange:e,position:this._metaToPositionMap.get(n)}):(this._cleanHeaps(),i=this.commitPosition({newIndex:t,meta:s,safeRange:e,position:this._replaceFurthestIndexPosition(t,e)})):i=this.getNewPositionForIndex(t),null!=i?(this._onTheFlyIndices[i]=s,this._setMetaIndex(s,t),this._metaToPositionMap.set(s,i),this._isOnTheFlyFullReturnHook(i)):null},p.replaceFurthestIndexPosition=function(t,e){return this.isBufferFull?this._replaceFurthestIndexPosition(t,e):this._isOnTheFlyFullReturnHook(this.getNewPositionForIndex(t))},p._replaceFurthestIndexPosition=function(t,e){if(this._largeValues.empty()||this._smallValues.empty())return this._isOnTheFlyFullReturnHook(this.getNewPositionForIndex(t));var n,s=this._getMinValue(),a=this._getMaxValue();if(l(a)){n=a,this._largeValues.pop();var o=this._indexToMetaMap.get(n);return this._metaToPositionMap.get(o)}if(!e){Math.abs(t-s)>Math.abs(t-a)?(n=s,this._smallValues.pop()):(n=a,this._largeValues.pop());var r=this._indexToMetaMap.get(n);return this._metaToPositionMap.get(r)}var u=e.startIndex,h=e.endIndex;if(i(u,s,h)&&i(u,a,h))return null;i(u,s,h)&&!i(u,a,h)?(n=a,this._largeValues.pop()):!i(u,s,h)&&i(u,a,h)||u-s>a-h?(n=s,this._smallValues.pop()):(n=a,this._largeValues.pop());var p=this._indexToMetaMap.get(n);return this._metaToPositionMap.get(p)},p.shuffle=function(t){for(var e=this,i=new Array(this.bufferSize),n=0;n<i.length;n++){var s=this.getMetaIndex(this._onTheFlyIndices[n]||this._positionToMetaList[n]);i[n]=s}for(var o=new Array(i.length),r=[],l=new Map,u=new Map,h=function(){var t=i[p],n=e._metaExtractor(t);if(null==n)return"continue";if(l.set(t,n),u.set(n,t),n===e._positionToMetaList[p])return o[p]=n,"continue";var s=e._positionToMetaList.findIndex((function(t){return t===n}));if(-1!==s)return o[s]=n,"continue";r.push(n)},p=0;p<i.length;p++)h();var _=[];this._indexToMetaMap=l,this.replaceMetaToIndexMap(u);for(var d=0;d<i.length;d++)if(null==o[d]){var f=r.shift();null!=f&&(_[d]=f)}else _[d]=o[d];return this._positionToMetaList=_,this.getIndices(a({},t,{retry:!0}))},p.getIndices=function(t){void 0===t&&(t={retry:!1,fallback:!1});try{for(var e=t.retry,i=t.fallback,n=this.initialize(),s=n.smallValues,o=n.largeValues,r=new Array(this._positionToMetaList.length),u=new Map,h=new Map,p=new Map,_=0;_<r.length;_++){var d=i?this._onTheFlyIndices[_]:this._onTheFlyIndices[_]||this._positionToMetaList[_],f=this.getMetaIndex(d);if(!l(d)&&d!=this.getIndexMeta(f)&&!e)return this.shuffle(t);if(null!=d&&!l(d)){var c={position:_,value:f};this._push(s,c),this._push(o,c),u.set(d,_),h.set(f,d),p.set(d,f),r[_]={meta:d,targetIndex:f,recyclerKey:this._name+"_"+_}}}return this._smallValues=s,this._largeValues=o,this._metaToPositionMap=u,this._positionToMetaList=r.map((function(t){return null==t?void 0:t.meta})),this.resetOnTheFlies(),this._indexToMetaMap=h,this.replaceMetaToIndexMap(p),r}catch(e){return console.log("err ",e),this.getIndices(a({},t,{fallback:!0}))}finally{this.readyToStartNextLoop()}},p._pushToHeaps=function(t,e){var i={position:t,value:e};this._push(this._smallValues,i),this._push(this._largeValues,i)},p._setMetaPosition=function(t,e){this._positionToMetaList[e]=t,this._metaToPositionMap.set(t,e)},p.commitPosition=function(t){var e=t.newIndex,i=t.safeRange,n=t.position,s=this._onTheFlyIndices[n],a=n;if(s){if(s===t.meta)return n;if(this._isOnTheFlyFull)return this.getFliedPosition(e,i);for(a=this._replaceFurthestIndexPosition(e,i);this._onTheFlyIndices[a];)a=this._replaceFurthestIndexPosition(e,i)}return a},p._setMetaIndex=function(t,e){var i=this.getMetaIndex(t);return void 0!==i&&this._indexToMetaMap.delete(i),this.setMetaIndex(t,e),this._indexToMetaMap.set(e,t),!1},p.readyToStartNextLoop=function(){this._lastUpdatedMS=Date.now()},p.prepare=function(){this._loopMS!==this._lastUpdatedMS&&(this._loopMS=this._lastUpdatedMS,this._onTheFlyIndices=[],this._isOnTheFlyFull=!1)},p._cleanHeaps=function(){for(var t=0;t<this._positionToMetaList.length;t++)if(null==this._positionToMetaList[t])return void this._recreateHeaps();var e=Math.min(this._smallValues.size(),this._largeValues.size());Math.max(this._smallValues.size(),this._largeValues.size())>10*e&&this._recreateHeaps()},p._recreateHeaps=function(){for(var t=this.initialize(),e=t.smallValues,i=t.largeValues,n=0;n<this._positionToMetaList.length;n++){var s=this._positionToMetaList[n],a=this.getMetaIndex(s);null!=s&&-1!==a&&null!=a||(a=Number.MAX_SAFE_INTEGER-n);var o={position:n,value:a};this._push(e,o),this._push(i,o),a>r&&(this._setMetaPosition(a,n),this._setMetaIndex(a,a))}this._smallValues=e,this._largeValues=i},p._smallerComparator=function(t,e){return t.value<e.value},p._greaterComparator=function(t,e){return t.value>e.value},u=t,(h=[{key:"bufferSize",get:function(){return this._bufferSize}},{key:"isBufferFull",get:function(){return this._positionToMetaList.length>=this._bufferSize}}])&&function(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,"symbol"==typeof(s=function(t,e){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var n=i.call(t,"string");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(n.key))?s:String(s),n)}var s}(u.prototype,h),Object.defineProperty(u,"prototype",{writable:!1}),t}(),exports.defaultBufferSize=10;
|
|
2
2
|
//# sourceMappingURL=integer-buffer-set.cjs.production.min.js.map
|