@itwin/core-bentley 5.0.0-dev.8 → 5.0.0-dev.83
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/CHANGELOG.md +46 -1
- package/lib/cjs/BeEvent.js +3 -7
- package/lib/cjs/BeEvent.js.map +1 -1
- package/lib/cjs/BentleyError.d.ts +3 -0
- package/lib/cjs/BentleyError.d.ts.map +1 -1
- package/lib/cjs/BentleyError.js +6 -1
- package/lib/cjs/BentleyError.js.map +1 -1
- package/lib/cjs/ByteStream.d.ts +3 -22
- package/lib/cjs/ByteStream.d.ts.map +1 -1
- package/lib/cjs/ByteStream.js +7 -21
- package/lib/cjs/ByteStream.js.map +1 -1
- package/lib/cjs/Compare.d.ts +15 -0
- package/lib/cjs/Compare.d.ts.map +1 -1
- package/lib/cjs/Compare.js +48 -0
- package/lib/cjs/Compare.js.map +1 -1
- package/lib/cjs/CompressedId64Set.js +6 -3
- package/lib/cjs/CompressedId64Set.js.map +1 -1
- package/lib/cjs/Dictionary.js +8 -3
- package/lib/cjs/Dictionary.js.map +1 -1
- package/lib/cjs/Disposable.d.ts +18 -0
- package/lib/cjs/Disposable.d.ts.map +1 -1
- package/lib/cjs/Disposable.js +25 -25
- package/lib/cjs/Disposable.js.map +1 -1
- package/lib/cjs/Id.d.ts +0 -4
- package/lib/cjs/Id.d.ts.map +1 -1
- package/lib/cjs/Id.js +9 -11
- package/lib/cjs/Id.js.map +1 -1
- package/lib/cjs/IndexMap.js +6 -1
- package/lib/cjs/IndexMap.js.map +1 -1
- package/lib/cjs/LRUMap.js +16 -0
- package/lib/cjs/LRUMap.js.map +1 -1
- package/lib/cjs/Logger.d.ts +24 -2
- package/lib/cjs/Logger.d.ts.map +1 -1
- package/lib/cjs/Logger.js +26 -7
- package/lib/cjs/Logger.js.map +1 -1
- package/lib/cjs/ObservableSet.js +6 -6
- package/lib/cjs/ObservableSet.js.map +1 -1
- package/lib/cjs/OneAtATimeAction.js +9 -0
- package/lib/cjs/OneAtATimeAction.js.map +1 -1
- package/lib/cjs/OrderedSet.js +1 -0
- package/lib/cjs/OrderedSet.js.map +1 -1
- package/lib/cjs/PriorityQueue.js +3 -1
- package/lib/cjs/PriorityQueue.js.map +1 -1
- package/lib/cjs/SortedArray.js +4 -1
- package/lib/cjs/SortedArray.js.map +1 -1
- package/lib/cjs/StatusCategory.js +42 -105
- package/lib/cjs/StatusCategory.js.map +1 -1
- package/lib/cjs/Time.js +5 -0
- package/lib/cjs/Time.js.map +1 -1
- package/lib/cjs/Tracing.js +2 -0
- package/lib/cjs/Tracing.js.map +1 -1
- package/lib/cjs/TupleKeyedMap.js +2 -2
- package/lib/cjs/TupleKeyedMap.js.map +1 -1
- package/lib/cjs/TypedArrayBuilder.js +8 -0
- package/lib/cjs/TypedArrayBuilder.js.map +1 -1
- package/lib/cjs/UnexpectedErrors.js +10 -12
- package/lib/cjs/UnexpectedErrors.js.map +1 -1
- package/lib/cjs/YieldManager.js +3 -1
- package/lib/cjs/YieldManager.js.map +1 -1
- package/lib/cjs/internal/cross-package.d.ts +0 -1
- package/lib/cjs/internal/cross-package.d.ts.map +1 -1
- package/lib/cjs/internal/cross-package.js +1 -3
- package/lib/cjs/internal/cross-package.js.map +1 -1
- package/lib/esm/BeEvent.js +3 -7
- package/lib/esm/BeEvent.js.map +1 -1
- package/lib/esm/BentleyError.d.ts +3 -0
- package/lib/esm/BentleyError.d.ts.map +1 -1
- package/lib/esm/BentleyError.js +6 -1
- package/lib/esm/BentleyError.js.map +1 -1
- package/lib/esm/ByteStream.d.ts +3 -22
- package/lib/esm/ByteStream.d.ts.map +1 -1
- package/lib/esm/ByteStream.js +7 -21
- package/lib/esm/ByteStream.js.map +1 -1
- package/lib/esm/Compare.d.ts +15 -0
- package/lib/esm/Compare.d.ts.map +1 -1
- package/lib/esm/Compare.js +46 -0
- package/lib/esm/Compare.js.map +1 -1
- package/lib/esm/CompressedId64Set.js +6 -3
- package/lib/esm/CompressedId64Set.js.map +1 -1
- package/lib/esm/Dictionary.js +8 -3
- package/lib/esm/Dictionary.js.map +1 -1
- package/lib/esm/Disposable.d.ts +18 -0
- package/lib/esm/Disposable.d.ts.map +1 -1
- package/lib/esm/Disposable.js +24 -25
- package/lib/esm/Disposable.js.map +1 -1
- package/lib/esm/Id.d.ts +0 -4
- package/lib/esm/Id.d.ts.map +1 -1
- package/lib/esm/Id.js +9 -11
- package/lib/esm/Id.js.map +1 -1
- package/lib/esm/IndexMap.js +6 -1
- package/lib/esm/IndexMap.js.map +1 -1
- package/lib/esm/LRUMap.js +16 -0
- package/lib/esm/LRUMap.js.map +1 -1
- package/lib/esm/Logger.d.ts +24 -2
- package/lib/esm/Logger.d.ts.map +1 -1
- package/lib/esm/Logger.js +26 -7
- package/lib/esm/Logger.js.map +1 -1
- package/lib/esm/ObservableSet.js +6 -6
- package/lib/esm/ObservableSet.js.map +1 -1
- package/lib/esm/OneAtATimeAction.js +9 -0
- package/lib/esm/OneAtATimeAction.js.map +1 -1
- package/lib/esm/OrderedSet.js +1 -0
- package/lib/esm/OrderedSet.js.map +1 -1
- package/lib/esm/PriorityQueue.js +3 -1
- package/lib/esm/PriorityQueue.js.map +1 -1
- package/lib/esm/SortedArray.js +4 -1
- package/lib/esm/SortedArray.js.map +1 -1
- package/lib/esm/StatusCategory.js +42 -105
- package/lib/esm/StatusCategory.js.map +1 -1
- package/lib/esm/Time.js +5 -0
- package/lib/esm/Time.js.map +1 -1
- package/lib/esm/Tracing.js +2 -0
- package/lib/esm/Tracing.js.map +1 -1
- package/lib/esm/TupleKeyedMap.js +2 -2
- package/lib/esm/TupleKeyedMap.js.map +1 -1
- package/lib/esm/TypedArrayBuilder.js +8 -0
- package/lib/esm/TypedArrayBuilder.js.map +1 -1
- package/lib/esm/UnexpectedErrors.js +10 -12
- package/lib/esm/UnexpectedErrors.js.map +1 -1
- package/lib/esm/YieldManager.js +3 -1
- package/lib/esm/YieldManager.js.map +1 -1
- package/lib/esm/internal/cross-package.d.ts +0 -1
- package/lib/esm/internal/cross-package.d.ts.map +1 -1
- package/lib/esm/internal/cross-package.js +0 -1
- package/lib/esm/internal/cross-package.js.map +1 -1
- package/package.json +8 -8
- package/lib/cjs/internal/staticLoggerMetadata.d.ts +0 -11
- package/lib/cjs/internal/staticLoggerMetadata.d.ts.map +0 -1
- package/lib/cjs/internal/staticLoggerMetadata.js +0 -17
- package/lib/cjs/internal/staticLoggerMetadata.js.map +0 -1
- package/lib/esm/internal/staticLoggerMetadata.d.ts +0 -11
- package/lib/esm/internal/staticLoggerMetadata.d.ts.map +0 -1
- package/lib/esm/internal/staticLoggerMetadata.js +0 -14
- package/lib/esm/internal/staticLoggerMetadata.js.map +0 -1
|
@@ -118,6 +118,9 @@ export var CompressedId64Set;
|
|
|
118
118
|
CompressedId64Set.compressIds = compressIds;
|
|
119
119
|
/** This exists strictly for the purposes of compressed sets of 64-bit Ids, to avoid the overhead of BigInt for handling 64-bit integers. */
|
|
120
120
|
class Uint64 {
|
|
121
|
+
lower;
|
|
122
|
+
upper;
|
|
123
|
+
static _base = 0x100000000;
|
|
121
124
|
static assertUint32(num) {
|
|
122
125
|
assert(num >= 0);
|
|
123
126
|
assert(num < Uint64._base);
|
|
@@ -179,7 +182,6 @@ export var CompressedId64Set;
|
|
|
179
182
|
return Id64.fromUint32Pair(this.lower, this.upper);
|
|
180
183
|
}
|
|
181
184
|
}
|
|
182
|
-
Uint64._base = 0x100000000;
|
|
183
185
|
/** Supplies an iterator over the [[Id64String]]s in a [[CompressedId64Set]].
|
|
184
186
|
* The Ids are iterated in ascending order based on their unsigned 64-bit integer values.
|
|
185
187
|
*/
|
|
@@ -323,10 +325,11 @@ export class OrderedId64Array extends SortedArray {
|
|
|
323
325
|
* @public
|
|
324
326
|
*/
|
|
325
327
|
export class MutableCompressedId64Set {
|
|
328
|
+
_ids;
|
|
329
|
+
_inserted = new OrderedId64Array();
|
|
330
|
+
_deleted = new OrderedId64Array();
|
|
326
331
|
/** Construct a new set, optionally initialized to contain the Ids represented by `ids`. */
|
|
327
332
|
constructor(ids) {
|
|
328
|
-
this._inserted = new OrderedId64Array();
|
|
329
|
-
this._deleted = new OrderedId64Array();
|
|
330
333
|
this._ids = ids ?? "";
|
|
331
334
|
}
|
|
332
335
|
/** Obtain the compact string representation of the contents of this set. If any insertions or removals are pending, they will be applied and the string recomputed. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CompressedId64Set.js","sourceRoot":"","sources":["../../src/CompressedId64Set.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,IAAI,EAAkC,MAAM,MAAM,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAK5C;;;;;;;;GAQG;AACH,MAAM,KAAW,iBAAiB,CAoUjC;AApUD,WAAiB,iBAAiB;IAChC,SAAS,UAAU,CAAC,EAAU;QAC5B,gBAAgB;QAChB,WAAW;QACX,WAAW;QACX,WAAW;QACX,WAAW;QAEX,OAAO,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IAC1D,CAAC;IAED,SAAS,YAAY,CAAC,SAAiB,EAAE,MAAc;QACrD,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QACnB,MAAM,GAAG,GAAG,IAAI,SAAS,CAAC,QAAQ,EAAE,EAAE,CAAC;QACvC,IAAI,MAAM,IAAI,CAAC;YACb,OAAO,GAAG,CAAC;QAEb,MAAM,GAAG,GAAG,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;QAC9C,OAAO,GAAG,GAAG,IAAI,GAAG,EAAE,CAAC;IACzB,CAAC;IAED;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Q;QAClB,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC;IAC3D,CAAC;IAEO,SAAS;QACf,IAAI,CAAC,IAAI,CAAC,QAAQ;YAChB,OAAO;QAET,MAAM,UAAU,GAAG,mBAAmB,CAAC,UAAU,CAAC,iBAAiB,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QAC5G,MAAM,KAAK,GAAG,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,GAAG,EAAE,CAAC,mBAAmB,CAAC,aAAa,CAAC,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC;QAC7G,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QAEjD,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;QACvB,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;IACxB,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Ids\n */\n\nimport { assert } from \"./Assert\";\nimport { Id64, Id64Array, Id64Set, Id64String } from \"./Id\";\nimport { OrderedId64Iterable } from \"./OrderedId64Iterable\";\nimport { SortedArray } from \"./SortedArray\";\n\n/** @public */\nexport type CompressedId64Set = string;\n\n/** A compact string representation of an [[Id64Set]]. Such a representation is useful when serializing potentially very large\n * sets of Ids.\n * @see [[CompressedId64Set.iterable]] to efficiently iterate the Ids represented by a compact string.\n * @see [[CompressedId64Set.compressSet]] and [[CompressedId64Set.compressArray]] to produce a compact string from a collection of Ids.\n * @see [[CompressedId64Set.decompressSet]] and [[CompressedId64Set.decompressArray]] to produce a collection of Ids from a compact string.\n * @see [[OrderedId64Iterable]] for a generic representation of an ordered set of Ids (compressed or otherwise).\n * @see [[MutableCompressedId64Set]] for a mutable version.\n * @public\n */\nexport namespace CompressedId64Set { // eslint-disable-line @typescript-eslint/no-redeclare\n function isHexDigit(ch: number): boolean {\n // ascii values:\n // '0' = 48\n // '9' = 57\n // 'a' = 65\n // 'f' = 70\n\n return (ch >= 48 && ch <= 57) || (ch >= 65 && ch <= 70);\n }\n\n function compactRange(increment: Uint64, length: number): string {\n assert(length > 0);\n const inc = `+${increment.toString()}`;\n if (length <= 1)\n return inc;\n\n const len = length.toString(16).toUpperCase();\n return `${inc}*${len}`;\n }\n\n /** Given a set of [[Id64String]]s, produce a compact string representation. Useful when serializing potentially large sets of Ids.\n * @note Invalid Ids are ignored.\n * @see [[CompressedId64Set.sortAndCompress]] to compress any unordered collection of Ids.\n * @see [[CompressedId64Set.compressArray]] to perform the same operation on an [[Id64Array]].\n * @see [[CompressedId64Set.decompressSet]] to perform the inverse operation.\n */\n export function compressSet(ids: Id64Set): CompressedId64Set {\n return sortAndCompress(ids);\n }\n\n /** Create a sorted array from `ids`, then return a compact string representation of those Ids.\n * @see [[CompressedId64Set.compressIds]] if `ids` is known to already be sorted.\n */\n export function sortAndCompress(ids: Iterable<Id64String>): CompressedId64Set {\n // `string` is an Iterable<string>. In that case assume caller passed a single Id64String.\n const arr = typeof ids === \"string\" ? [ids] : Array.from(ids);\n OrderedId64Iterable.sortArray(arr);\n return compressArray(arr);\n }\n\n /** Give a **numerically-ordered** array of [[Id64String]]s, produce a compact string representation. Useful when serializing potentially large sets of Ids.\n * Duplicate Ids are included only once in the string representation.\n * @throws Error if two consecutive Ids `x` and `y` exist such that the numerical value of `x` is greater than that of `y` - i.e., the array is not properly sorted.\n * @note The array must be sorted according to the 64-bit numerical value of each Id.\n * @note Invalid Ids are ignored.\n * @see [[CompressedId64Set.decompressArray]] to perform the inverse operation.\n * @see [[OrderedId64Iterable.sortArray]] to ensure the Ids are properly sorted.\n * @see [[CompressedId64Set.sortAndCompress]] to compress any unordered collection of Ids.\n */\n export function compressArray(ids: Id64Array): CompressedId64Set {\n return compressIds(ids);\n }\n\n /** Give a **numerically-ordered** collection of [[Id64String]]s, produce a compact string representation. Useful when serializing potentially large sets of Ids.\n * Duplicate Ids are included only once in the string representation.\n * @throws Error if two consecutive Ids `x` and `y` exist such that the numerical value of `x` is greater than that of `y` - i.e., the collection is not properly sorted.\n * @note The collection must be sorted according to the 64-bit numerical value of each Id.\n * @note Invalid Ids are ignored.\n * @see [[CompressedId64Set.iterable]] to perform the inverse operation.\n * @see [[OrderedId64Iterable.sortArray]] or [[OrderedId64Iterable.compare]] to ensure the Ids are properly sorted.\n * @see [[CompressedId64Set.sortAndCompress]] to compress any unordered collection of Ids.\n */\n export function compressIds(ids: OrderedId64Iterable): CompressedId64Set {\n if (\"string\" === typeof ids)\n return ids;\n\n let str = \"\";\n\n const prevId = new Uint64();\n const rangeIncrement = new Uint64();\n let rangeLen = 0;\n\n const curId = new Uint64();\n const curIncrement = new Uint64();\n for (const id of ids) {\n if (!Id64.isValidId64(id))\n continue; // ignore garbage and invalid Ids (\"0\")\n\n curId.setFromId(id);\n curIncrement.setFromDifference(curId, prevId);\n\n const cmp = prevId.compare(curId);\n if (0 === cmp)\n continue; // ignore duplicates\n else if (cmp > 0)\n throw new Error(\"CompressedId64Set.compressArray requires a sorted array as input\");\n\n prevId.copyFrom(curId);\n\n if (0 === rangeLen) {\n rangeIncrement.copyFrom(curIncrement);\n rangeLen = 1;\n } else if (curIncrement.equals(rangeIncrement)) {\n ++rangeLen;\n } else {\n str += compactRange(rangeIncrement, rangeLen);\n rangeIncrement.copyFrom(curIncrement);\n rangeLen = 1;\n }\n }\n\n if (0 < rangeLen)\n str += compactRange(rangeIncrement, rangeLen);\n\n return str;\n }\n\n /** This exists strictly for the purposes of compressed sets of 64-bit Ids, to avoid the overhead of BigInt for handling 64-bit integers. */\n class Uint64 implements Id64.Uint32Pair {\n private static readonly _base = 0x100000000;\n\n private static assertUint32(num: number): void {\n assert(num >= 0);\n assert(num < Uint64._base);\n assert(Math.floor(num) === num);\n }\n\n private assertConstraints(): void {\n Uint64.assertUint32(this.lower);\n Uint64.assertUint32(this.upper);\n }\n\n constructor(public lower = 0, public upper = 0) {\n this.assertConstraints();\n }\n\n public compare(rhs: Uint64): number {\n const diff = this.upper - rhs.upper;\n return 0 === diff ? this.lower - rhs.lower : diff;\n }\n\n public equals(rhs: Uint64): boolean { return 0 === this.compare(rhs); }\n public isLessThan(rhs: Uint64): boolean { return this.compare(rhs) < 0; }\n public isGreaterThan(rhs: Uint64): boolean { return this.compare(rhs) > 0; }\n\n public get isZero(): boolean { return 0 === this.lower && 0 === this.upper; }\n\n public setFromDifference(lhs: Uint64, rhs: Uint64): void {\n assert(!rhs.isGreaterThan(lhs));\n\n this.lower = lhs.lower - rhs.lower;\n this.upper = lhs.upper - rhs.upper;\n if (this.lower < 0) {\n this.lower += Uint64._base;\n this.upper -= 1;\n }\n }\n\n public add(rhs: Uint64): void {\n let lower = rhs.lower;\n let upper = rhs.upper;\n if (lower + this.lower >= Uint64._base) {\n lower -= Uint64._base;\n upper += 1;\n }\n\n this.lower += lower;\n this.upper += upper;\n this.assertConstraints();\n }\n\n public setFromId(id: Id64String): void {\n Id64.getUint32Pair(id, this);\n }\n\n public copyFrom(other: Uint64): void {\n this.lower = other.lower;\n this.upper = other.upper;\n }\n\n public toString(): string {\n if (0 === this.upper)\n return this.lower.toString(16).toUpperCase();\n\n const upper = this.upper.toString(16);\n const lower = this.lower.toString(16).padStart(8, \"0\");\n assert(lower.length === 8);\n return `${upper}${lower}`.toUpperCase();\n }\n\n public toId64String(): string {\n return Id64.fromUint32Pair(this.lower, this.upper);\n }\n }\n\n /** Supplies an iterator over the [[Id64String]]s in a [[CompressedId64Set]].\n * The Ids are iterated in ascending order based on their unsigned 64-bit integer values.\n */\n export function* iterator(ids: CompressedId64Set): Iterator<Id64String> {\n if (0 === ids.length)\n return; // empty set.\n\n if (\"+\" !== ids[0])\n throw new Error(\"Invalid CompressedId64Set\");\n\n let curIndex = 1; // skip the leading '+'\n const curId = new Uint64();\n\n function parseUint32(): number {\n let value = 0;\n let nChars = 0;\n while (curIndex < ids.length && nChars < 8) {\n ++nChars;\n const ch = ids.charCodeAt(curIndex);\n if (!isHexDigit(ch))\n break; // not a hex digit in [0..9] or [A..F]\n\n value <<= 4;\n value |= (ch >= 65 ? ch - 65 + 10 : ch - 48); // ch - 'A' + 10 or ch - '0'\n value = value >>> 0; // restore unsignedness because silly javascript.\n ++curIndex;\n }\n\n return value;\n }\n\n function parseUint64(uint64: Uint64): void {\n let lower = 0;\n let upper = 0;\n\n // Read up to the first 8 digits.\n const startIndex = curIndex;\n const first = parseUint32();\n\n const nFirstDigits = curIndex - startIndex;\n assert(nFirstDigits <= 8);\n\n if (8 === nFirstDigits && curIndex + 1 < ids.length && isHexDigit(ids.charCodeAt(curIndex + 1))) {\n // We've got up to 8 more digits remaining\n const secondIndex = curIndex;\n const second = parseUint32();\n\n // Transfer excess digits from upper to lower.\n const nSecondDigits = curIndex - secondIndex;\n assert(nSecondDigits > 0 && nSecondDigits <= 8);\n\n const nDigitsToTransfer = 8 - nSecondDigits;\n upper = first >>> (4 * nDigitsToTransfer);\n const transfer = first - ((upper << (4 * nDigitsToTransfer)) >>> 0);\n lower = (second | ((transfer << (4 * nSecondDigits)) >>> 0)) >>> 0;\n } else {\n lower = first;\n }\n\n uint64.lower = lower;\n uint64.upper = upper;\n }\n\n const increment = new Uint64();\n while (curIndex < ids.length) {\n let multiplier = 1;\n parseUint64(increment);\n if (increment.isZero)\n throw new Error(\"Invalid CompressedId64Set\");\n\n if (curIndex < ids.length) {\n switch (ids[curIndex++]) {\n case \"*\":\n multiplier = parseUint32();\n if (0 === multiplier)\n throw new Error(\"Invalid CompressedId64Set\");\n\n if (curIndex !== ids.length && ids[curIndex++] !== \"+\")\n return;\n\n break;\n case \"+\":\n break;\n default:\n throw new Error(\"Invalid CompressedId64Set\");\n }\n }\n\n for (let i = 0; i < multiplier; i++) {\n curId.add(increment);\n yield curId.toId64String();\n }\n }\n }\n\n /** Supplies an iterable over the [[Id64String]]s in a [[CompressedId64Set]].\n * The Ids are iterated in ascending order based on their unsigned 64-bit integer values.\n */\n export function iterable(ids: CompressedId64Set): OrderedId64Iterable {\n return {\n [Symbol.iterator]: () => iterator(ids),\n };\n }\n\n /** Decompress the compact string representation of an [[Id64Set]] into an [[Id64Set]].\n * @param compressedIds The compact string representation.\n * @param out If supplied, the Ids will be inserted into this set rather than allocating and returning a new set.\n * @returns The set containing the decompressed Ids.\n * @throws Error if `compressedIds` is not a well-formed [[CompressedId64Set]].\n * @see [[CompressedId64Set.compressSet]] to perform the inverse operation.\n * @see [[CompressedId64Set.decompressArray]] to decompress as an [[Id64Array]] instead.\n * @see [[CompressedId64Set.iterable]] to efficiently iterate the Ids.\n */\n export function decompressSet(compressedIds: CompressedId64Set, out?: Id64Set): Id64Set {\n const set = out ?? new Set<string>();\n for (const id of iterable(compressedIds))\n set.add(id);\n\n return set;\n }\n\n /** Decompress the compact string representation of an [[Id64Set]] into an [[Id64Array]].\n * @param compressedIds The compact string representation.\n * @param out If supplied, the Ids will be appended to this array rather than allocating and returning a new array.\n * @returns The array containing the decompressed Ids.\n * @throws Error if `compressedIds` is not a well-formed [[CompressedId64Set]].\n * @note The Ids are decompressed and appended to the array in ascending order based on their 64-bit numerical values.\n * @see [[CompressedId64Set.compressArray]] to perform the inverse operation.\n * @see [[CompressedId64Set.decompressSet]] to decompress as an [[Id64Set]] instead.\n * @see [[CompressedId64Set.iterable]] to efficiently iterate the Ids.\n */\n export function decompressArray(compressedIds: CompressedId64Set, out?: Id64Array): Id64Array {\n const arr = out ?? [];\n for (const id of iterable(compressedIds))\n arr.push(id);\n\n return arr;\n }\n}\n\n/** A [[SortedArray]] of unique [[Id64String]]s sorted in ascending order by the 64-bit unsigned integer values of the Ids.\n * @see [[CompressedId64Set]] for an immutable compact string representation.\n * @public\n */\nexport class OrderedId64Array extends SortedArray<Id64String> {\n /** Construct a new, empty array. */\n public constructor() {\n super((lhs, rhs) => OrderedId64Iterable.compare(lhs, rhs));\n }\n\n /** An iterable that iterates over the Ids in sorted order. */\n public get ids(): OrderedId64Iterable { return this._array; }\n\n /** The underlying array of Ids. */\n public get array(): ReadonlyArray<Id64String> { return this._array; }\n}\n\n/** A mutable set of valid [[Id64String]]s sorted in ascending order by the 64-bit unsigned integer value of the Ids.\n * Internally the set of Ids is maintained as a [[CompressedId64Set]] string representation.\n * Insertions and removals are buffered until the string representation needs to be recomputed. The string representation is recomputed by every public method except [[add]] and [[delete]] -\n * therefore, if multiple removals and/or insertions are required, it is most efficient to perform them all before invoking other methods.\n * @public\n */\nexport class MutableCompressedId64Set implements OrderedId64Iterable {\n private _ids: CompressedId64Set;\n private readonly _inserted = new OrderedId64Array();\n private readonly _deleted = new OrderedId64Array();\n\n /** Construct a new set, optionally initialized to contain the Ids represented by `ids`. */\n public constructor(ids?: CompressedId64Set) {\n this._ids = ids ?? \"\";\n }\n\n /** Obtain the compact string representation of the contents of this set. If any insertions or removals are pending, they will be applied and the string recomputed. */\n public get ids(): CompressedId64Set {\n this.updateIds();\n return this._ids;\n }\n\n /** Add the specified Id to the set.\n * @throws Error if `id` is not a valid [[Id64String]].\n */\n public add(id: Id64String): void {\n if (!Id64.isValidId64(id))\n throw new Error(\"MutableCompressedId64Set.add: invalid Id\");\n\n this._deleted.remove(id);\n this._inserted.insert(id);\n }\n\n /** Remove the specified Id from the set.\n * @throws Error if `id` is not a valid [[Id64String]].\n */\n public delete(id: Id64String): void {\n if (!Id64.isValidId64(id))\n throw new Error(\"MutableCompressedId64Set.delete: invalid Id\");\n\n this._inserted.remove(id);\n this._deleted.insert(id);\n }\n\n /** Remove all Ids from the set. */\n public clear(): void {\n this._ids = \"\";\n this._inserted.clear();\n this._deleted.clear();\n }\n\n /** Remove all Ids from the set, then add the specified Ids. */\n public reset(ids?: CompressedId64Set): void {\n this.clear();\n this._ids = ids ?? \"\";\n }\n\n /** Obtain an iterator over the Ids in this set. The Ids are returned in ascending order based on their unsigned 64-bit integer values. */\n public [Symbol.iterator]() {\n return CompressedId64Set.iterator(this.ids);\n }\n\n /** Compute a compact string representation of the union of this and another set of Ids - i.e., those Ids present in either this and/or the other set. */\n public computeUnion(ids: OrderedId64Iterable | CompressedId64Set | MutableCompressedId64Set): CompressedId64Set {\n if (this.isEmpty)\n return CompressedId64Set.compressIds(ids);\n else if (OrderedId64Iterable.isEmptySet(ids) || this.equals(ids))\n return this.ids;\n\n return CompressedId64Set.compressIds(OrderedId64Iterable.union(this, ids));\n }\n\n /** Compute a compact string representation of the intersection of this and another set of Ids - i.e., those Ids present in both this and the other set. */\n public computeIntersection(ids: OrderedId64Iterable | CompressedId64Set | MutableCompressedId64Set): CompressedId64Set {\n if (this.equals(ids))\n return this.ids;\n else if (this.isEmpty || OrderedId64Iterable.isEmptySet(ids))\n return \"\";\n\n return CompressedId64Set.compressIds(OrderedId64Iterable.intersection(this, ids));\n }\n\n /** Compute a compact string representation of the difference between this and another set - i.e., those Ids present in this but not in the other set. */\n public computeDifference(ids: OrderedId64Iterable | CompressedId64Set | MutableCompressedId64Set): CompressedId64Set {\n if (this.isEmpty || this.equals(ids))\n return \"\";\n\n return CompressedId64Set.compressIds(OrderedId64Iterable.difference(this, ids));\n }\n\n /** Return true if this set contains no Ids. */\n public get isEmpty(): boolean {\n return OrderedId64Iterable.isEmptySet(this.ids);\n }\n\n /** Return true if the set of Ids represented by `other` is identical to those in this set.\n * @note This considers only the **distinct** Ids in `other` - duplicates are ignored.\n */\n public equals(other: CompressedId64Set | MutableCompressedId64Set | OrderedId64Iterable): boolean {\n if (other instanceof MutableCompressedId64Set) {\n if (other === this)\n return true;\n\n if (typeof other !== \"string\")\n other = other.ids;\n }\n\n if (typeof other === \"string\")\n return other === this.ids;\n\n this.updateIds();\n return OrderedId64Iterable.areEqualSets(this, other);\n }\n\n private get _isDirty(): boolean {\n return !this._inserted.isEmpty || !this._deleted.isEmpty;\n }\n\n private updateIds(): void {\n if (!this._isDirty)\n return;\n\n const difference = OrderedId64Iterable.difference(CompressedId64Set.iterable(this._ids), this._deleted.ids);\n const union = { [Symbol.iterator]: () => OrderedId64Iterable.unionIterator(difference, this._inserted.ids) };\n this._ids = CompressedId64Set.compressIds(union);\n\n this._inserted.clear();\n this._deleted.clear();\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"CompressedId64Set.js","sourceRoot":"","sources":["../../src/CompressedId64Set.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,IAAI,EAAkC,MAAM,MAAM,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAK5C;;;;;;;;GAQG;AACH,MAAM,KAAW,iBAAiB,CAoUjC;AApUD,WAAiB,iBAAiB;IAChC,SAAS,UAAU,CAAC,EAAU;QAC5B,gBAAgB;QAChB,WAAW;QACX,WAAW;QACX,WAAW;QACX,WAAW;QAEX,OAAO,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IAC1D,CAAC;IAED,SAAS,YAAY,CAAC,SAAiB,EAAE,MAAc;QACrD,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QACnB,MAAM,GAAG,GAAG,IAAI,SAAS,CAAC,QAAQ,EAAE,EAAE,CAAC;QACvC,IAAI,MAAM,IAAI,CAAC;YACb,OAAO,GAAG,CAAC;QAEb,MAAM,GAAG,GAAG,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;QAC9C,OAAO,GAAG,GAAG,IAAI,GAAG,EAAE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,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACvD,CAAC;IAED,IAAY,QAAQ;QAClB,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC;IAC3D,CAAC;IAEO,SAAS;QACf,IAAI,CAAC,IAAI,CAAC,QAAQ;YAChB,OAAO;QAET,MAAM,UAAU,GAAG,mBAAmB,CAAC,UAAU,CAAC,iBAAiB,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QAC5G,MAAM,KAAK,GAAG,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,GAAG,EAAE,CAAC,mBAAmB,CAAC,aAAa,CAAC,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC;QAC7G,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QAEjD,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;QACvB,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;IACxB,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Ids\n */\n\nimport { assert } from \"./Assert\";\nimport { Id64, Id64Array, Id64Set, Id64String } from \"./Id\";\nimport { OrderedId64Iterable } from \"./OrderedId64Iterable\";\nimport { SortedArray } from \"./SortedArray\";\n\n/** @public */\nexport type CompressedId64Set = string;\n\n/** A compact string representation of an [[Id64Set]]. Such a representation is useful when serializing potentially very large\n * sets of Ids.\n * @see [[CompressedId64Set.iterable]] to efficiently iterate the Ids represented by a compact string.\n * @see [[CompressedId64Set.compressSet]] and [[CompressedId64Set.compressArray]] to produce a compact string from a collection of Ids.\n * @see [[CompressedId64Set.decompressSet]] and [[CompressedId64Set.decompressArray]] to produce a collection of Ids from a compact string.\n * @see [[OrderedId64Iterable]] for a generic representation of an ordered set of Ids (compressed or otherwise).\n * @see [[MutableCompressedId64Set]] for a mutable version.\n * @public\n */\nexport namespace CompressedId64Set { // eslint-disable-line @typescript-eslint/no-redeclare\n function isHexDigit(ch: number): boolean {\n // ascii values:\n // '0' = 48\n // '9' = 57\n // 'a' = 65\n // 'f' = 70\n\n return (ch >= 48 && ch <= 57) || (ch >= 65 && ch <= 70);\n }\n\n function compactRange(increment: Uint64, length: number): string {\n assert(length > 0);\n const inc = `+${increment.toString()}`;\n if (length <= 1)\n return inc;\n\n const len = length.toString(16).toUpperCase();\n return `${inc}*${len}`;\n }\n\n /** Given a set of [[Id64String]]s, produce a compact string representation. Useful when serializing potentially large sets of Ids.\n * @note Invalid Ids are ignored.\n * @see [[CompressedId64Set.sortAndCompress]] to compress any unordered collection of Ids.\n * @see [[CompressedId64Set.compressArray]] to perform the same operation on an [[Id64Array]].\n * @see [[CompressedId64Set.decompressSet]] to perform the inverse operation.\n */\n export function compressSet(ids: Id64Set): CompressedId64Set {\n return sortAndCompress(ids);\n }\n\n /** Create a sorted array from `ids`, then return a compact string representation of those Ids.\n * @see [[CompressedId64Set.compressIds]] if `ids` is known to already be sorted.\n */\n export function sortAndCompress(ids: Iterable<Id64String>): CompressedId64Set {\n // `string` is an Iterable<string>. In that case assume caller passed a single Id64String.\n const arr = typeof ids === \"string\" ? [ids] : Array.from(ids);\n OrderedId64Iterable.sortArray(arr);\n return compressArray(arr);\n }\n\n /** Give a **numerically-ordered** array of [[Id64String]]s, produce a compact string representation. Useful when serializing potentially large sets of Ids.\n * Duplicate Ids are included only once in the string representation.\n * @throws Error if two consecutive Ids `x` and `y` exist such that the numerical value of `x` is greater than that of `y` - i.e., the array is not properly sorted.\n * @note The array must be sorted according to the 64-bit numerical value of each Id.\n * @note Invalid Ids are ignored.\n * @see [[CompressedId64Set.decompressArray]] to perform the inverse operation.\n * @see [[OrderedId64Iterable.sortArray]] to ensure the Ids are properly sorted.\n * @see [[CompressedId64Set.sortAndCompress]] to compress any unordered collection of Ids.\n */\n export function compressArray(ids: Id64Array): CompressedId64Set {\n return compressIds(ids);\n }\n\n /** Give a **numerically-ordered** collection of [[Id64String]]s, produce a compact string representation. Useful when serializing potentially large sets of Ids.\n * Duplicate Ids are included only once in the string representation.\n * @throws Error if two consecutive Ids `x` and `y` exist such that the numerical value of `x` is greater than that of `y` - i.e., the collection is not properly sorted.\n * @note The collection must be sorted according to the 64-bit numerical value of each Id.\n * @note Invalid Ids are ignored.\n * @see [[CompressedId64Set.iterable]] to perform the inverse operation.\n * @see [[OrderedId64Iterable.sortArray]] or [[OrderedId64Iterable.compare]] to ensure the Ids are properly sorted.\n * @see [[CompressedId64Set.sortAndCompress]] to compress any unordered collection of Ids.\n */\n export function compressIds(ids: OrderedId64Iterable): CompressedId64Set {\n if (\"string\" === typeof ids)\n return ids;\n\n let str = \"\";\n\n const prevId = new Uint64();\n const rangeIncrement = new Uint64();\n let rangeLen = 0;\n\n const curId = new Uint64();\n const curIncrement = new Uint64();\n for (const id of ids) {\n if (!Id64.isValidId64(id))\n continue; // ignore garbage and invalid Ids (\"0\")\n\n curId.setFromId(id);\n curIncrement.setFromDifference(curId, prevId);\n\n const cmp = prevId.compare(curId);\n if (0 === cmp)\n continue; // ignore duplicates\n else if (cmp > 0)\n throw new Error(\"CompressedId64Set.compressArray requires a sorted array as input\");\n\n prevId.copyFrom(curId);\n\n if (0 === rangeLen) {\n rangeIncrement.copyFrom(curIncrement);\n rangeLen = 1;\n } else if (curIncrement.equals(rangeIncrement)) {\n ++rangeLen;\n } else {\n str += compactRange(rangeIncrement, rangeLen);\n rangeIncrement.copyFrom(curIncrement);\n rangeLen = 1;\n }\n }\n\n if (0 < rangeLen)\n str += compactRange(rangeIncrement, rangeLen);\n\n return str;\n }\n\n /** This exists strictly for the purposes of compressed sets of 64-bit Ids, to avoid the overhead of BigInt for handling 64-bit integers. */\n class Uint64 implements Id64.Uint32Pair {\n private static readonly _base = 0x100000000;\n\n private static assertUint32(num: number): void {\n assert(num >= 0);\n assert(num < Uint64._base);\n assert(Math.floor(num) === num);\n }\n\n private assertConstraints(): void {\n Uint64.assertUint32(this.lower);\n Uint64.assertUint32(this.upper);\n }\n\n constructor(public lower = 0, public upper = 0) {\n this.assertConstraints();\n }\n\n public compare(rhs: Uint64): number {\n const diff = this.upper - rhs.upper;\n return 0 === diff ? this.lower - rhs.lower : diff;\n }\n\n public equals(rhs: Uint64): boolean { return 0 === this.compare(rhs); }\n public isLessThan(rhs: Uint64): boolean { return this.compare(rhs) < 0; }\n public isGreaterThan(rhs: Uint64): boolean { return this.compare(rhs) > 0; }\n\n public get isZero(): boolean { return 0 === this.lower && 0 === this.upper; }\n\n public setFromDifference(lhs: Uint64, rhs: Uint64): void {\n assert(!rhs.isGreaterThan(lhs));\n\n this.lower = lhs.lower - rhs.lower;\n this.upper = lhs.upper - rhs.upper;\n if (this.lower < 0) {\n this.lower += Uint64._base;\n this.upper -= 1;\n }\n }\n\n public add(rhs: Uint64): void {\n let lower = rhs.lower;\n let upper = rhs.upper;\n if (lower + this.lower >= Uint64._base) {\n lower -= Uint64._base;\n upper += 1;\n }\n\n this.lower += lower;\n this.upper += upper;\n this.assertConstraints();\n }\n\n public setFromId(id: Id64String): void {\n Id64.getUint32Pair(id, this);\n }\n\n public copyFrom(other: Uint64): void {\n this.lower = other.lower;\n this.upper = other.upper;\n }\n\n public toString(): string {\n if (0 === this.upper)\n return this.lower.toString(16).toUpperCase();\n\n const upper = this.upper.toString(16);\n const lower = this.lower.toString(16).padStart(8, \"0\");\n assert(lower.length === 8);\n return `${upper}${lower}`.toUpperCase();\n }\n\n public toId64String(): string {\n return Id64.fromUint32Pair(this.lower, this.upper);\n }\n }\n\n /** Supplies an iterator over the [[Id64String]]s in a [[CompressedId64Set]].\n * The Ids are iterated in ascending order based on their unsigned 64-bit integer values.\n */\n export function* iterator(ids: CompressedId64Set): Iterator<Id64String> {\n if (0 === ids.length)\n return; // empty set.\n\n if (\"+\" !== ids[0])\n throw new Error(\"Invalid CompressedId64Set\");\n\n let curIndex = 1; // skip the leading '+'\n const curId = new Uint64();\n\n function parseUint32(): number {\n let value = 0;\n let nChars = 0;\n while (curIndex < ids.length && nChars < 8) {\n ++nChars;\n const ch = ids.charCodeAt(curIndex);\n if (!isHexDigit(ch))\n break; // not a hex digit in [0..9] or [A..F]\n\n value <<= 4;\n value |= (ch >= 65 ? ch - 65 + 10 : ch - 48); // ch - 'A' + 10 or ch - '0'\n value = value >>> 0; // restore unsignedness because silly javascript.\n ++curIndex;\n }\n\n return value;\n }\n\n function parseUint64(uint64: Uint64): void {\n let lower = 0;\n let upper = 0;\n\n // Read up to the first 8 digits.\n const startIndex = curIndex;\n const first = parseUint32();\n\n const nFirstDigits = curIndex - startIndex;\n assert(nFirstDigits <= 8);\n\n if (8 === nFirstDigits && curIndex + 1 < ids.length && isHexDigit(ids.charCodeAt(curIndex + 1))) {\n // We've got up to 8 more digits remaining\n const secondIndex = curIndex;\n const second = parseUint32();\n\n // Transfer excess digits from upper to lower.\n const nSecondDigits = curIndex - secondIndex;\n assert(nSecondDigits > 0 && nSecondDigits <= 8);\n\n const nDigitsToTransfer = 8 - nSecondDigits;\n upper = first >>> (4 * nDigitsToTransfer);\n const transfer = first - ((upper << (4 * nDigitsToTransfer)) >>> 0);\n lower = (second | ((transfer << (4 * nSecondDigits)) >>> 0)) >>> 0;\n } else {\n lower = first;\n }\n\n uint64.lower = lower;\n uint64.upper = upper;\n }\n\n const increment = new Uint64();\n while (curIndex < ids.length) {\n let multiplier = 1;\n parseUint64(increment);\n if (increment.isZero)\n throw new Error(\"Invalid CompressedId64Set\");\n\n if (curIndex < ids.length) {\n switch (ids[curIndex++]) {\n case \"*\":\n multiplier = parseUint32();\n if (0 === multiplier)\n throw new Error(\"Invalid CompressedId64Set\");\n\n if (curIndex !== ids.length && ids[curIndex++] !== \"+\")\n return;\n\n break;\n case \"+\":\n break;\n default:\n throw new Error(\"Invalid CompressedId64Set\");\n }\n }\n\n for (let i = 0; i < multiplier; i++) {\n curId.add(increment);\n yield curId.toId64String();\n }\n }\n }\n\n /** Supplies an iterable over the [[Id64String]]s in a [[CompressedId64Set]].\n * The Ids are iterated in ascending order based on their unsigned 64-bit integer values.\n */\n export function iterable(ids: CompressedId64Set): OrderedId64Iterable {\n return {\n [Symbol.iterator]: () => iterator(ids),\n };\n }\n\n /** Decompress the compact string representation of an [[Id64Set]] into an [[Id64Set]].\n * @param compressedIds The compact string representation.\n * @param out If supplied, the Ids will be inserted into this set rather than allocating and returning a new set.\n * @returns The set containing the decompressed Ids.\n * @throws Error if `compressedIds` is not a well-formed [[CompressedId64Set]].\n * @see [[CompressedId64Set.compressSet]] to perform the inverse operation.\n * @see [[CompressedId64Set.decompressArray]] to decompress as an [[Id64Array]] instead.\n * @see [[CompressedId64Set.iterable]] to efficiently iterate the Ids.\n */\n export function decompressSet(compressedIds: CompressedId64Set, out?: Id64Set): Id64Set {\n const set = out ?? new Set<string>();\n for (const id of iterable(compressedIds))\n set.add(id);\n\n return set;\n }\n\n /** Decompress the compact string representation of an [[Id64Set]] into an [[Id64Array]].\n * @param compressedIds The compact string representation.\n * @param out If supplied, the Ids will be appended to this array rather than allocating and returning a new array.\n * @returns The array containing the decompressed Ids.\n * @throws Error if `compressedIds` is not a well-formed [[CompressedId64Set]].\n * @note The Ids are decompressed and appended to the array in ascending order based on their 64-bit numerical values.\n * @see [[CompressedId64Set.compressArray]] to perform the inverse operation.\n * @see [[CompressedId64Set.decompressSet]] to decompress as an [[Id64Set]] instead.\n * @see [[CompressedId64Set.iterable]] to efficiently iterate the Ids.\n */\n export function decompressArray(compressedIds: CompressedId64Set, out?: Id64Array): Id64Array {\n const arr = out ?? [];\n for (const id of iterable(compressedIds))\n arr.push(id);\n\n return arr;\n }\n}\n\n/** A [[SortedArray]] of unique [[Id64String]]s sorted in ascending order by the 64-bit unsigned integer values of the Ids.\n * @see [[CompressedId64Set]] for an immutable compact string representation.\n * @public\n */\nexport class OrderedId64Array extends SortedArray<Id64String> {\n /** Construct a new, empty array. */\n public constructor() {\n super((lhs, rhs) => OrderedId64Iterable.compare(lhs, rhs));\n }\n\n /** An iterable that iterates over the Ids in sorted order. */\n public get ids(): OrderedId64Iterable { return this._array; }\n\n /** The underlying array of Ids. */\n public get array(): ReadonlyArray<Id64String> { return this._array; }\n}\n\n/** A mutable set of valid [[Id64String]]s sorted in ascending order by the 64-bit unsigned integer value of the Ids.\n * Internally the set of Ids is maintained as a [[CompressedId64Set]] string representation.\n * Insertions and removals are buffered until the string representation needs to be recomputed. The string representation is recomputed by every public method except [[add]] and [[delete]] -\n * therefore, if multiple removals and/or insertions are required, it is most efficient to perform them all before invoking other methods.\n * @public\n */\nexport class MutableCompressedId64Set implements OrderedId64Iterable {\n private _ids: CompressedId64Set;\n private readonly _inserted = new OrderedId64Array();\n private readonly _deleted = new OrderedId64Array();\n\n /** Construct a new set, optionally initialized to contain the Ids represented by `ids`. */\n public constructor(ids?: CompressedId64Set) {\n this._ids = ids ?? \"\";\n }\n\n /** Obtain the compact string representation of the contents of this set. If any insertions or removals are pending, they will be applied and the string recomputed. */\n public get ids(): CompressedId64Set {\n this.updateIds();\n return this._ids;\n }\n\n /** Add the specified Id to the set.\n * @throws Error if `id` is not a valid [[Id64String]].\n */\n public add(id: Id64String): void {\n if (!Id64.isValidId64(id))\n throw new Error(\"MutableCompressedId64Set.add: invalid Id\");\n\n this._deleted.remove(id);\n this._inserted.insert(id);\n }\n\n /** Remove the specified Id from the set.\n * @throws Error if `id` is not a valid [[Id64String]].\n */\n public delete(id: Id64String): void {\n if (!Id64.isValidId64(id))\n throw new Error(\"MutableCompressedId64Set.delete: invalid Id\");\n\n this._inserted.remove(id);\n this._deleted.insert(id);\n }\n\n /** Remove all Ids from the set. */\n public clear(): void {\n this._ids = \"\";\n this._inserted.clear();\n this._deleted.clear();\n }\n\n /** Remove all Ids from the set, then add the specified Ids. */\n public reset(ids?: CompressedId64Set): void {\n this.clear();\n this._ids = ids ?? \"\";\n }\n\n /** Obtain an iterator over the Ids in this set. The Ids are returned in ascending order based on their unsigned 64-bit integer values. */\n public [Symbol.iterator]() {\n return CompressedId64Set.iterator(this.ids);\n }\n\n /** Compute a compact string representation of the union of this and another set of Ids - i.e., those Ids present in either this and/or the other set. */\n public computeUnion(ids: OrderedId64Iterable | CompressedId64Set | MutableCompressedId64Set): CompressedId64Set {\n if (this.isEmpty)\n return CompressedId64Set.compressIds(ids);\n else if (OrderedId64Iterable.isEmptySet(ids) || this.equals(ids))\n return this.ids;\n\n return CompressedId64Set.compressIds(OrderedId64Iterable.union(this, ids));\n }\n\n /** Compute a compact string representation of the intersection of this and another set of Ids - i.e., those Ids present in both this and the other set. */\n public computeIntersection(ids: OrderedId64Iterable | CompressedId64Set | MutableCompressedId64Set): CompressedId64Set {\n if (this.equals(ids))\n return this.ids;\n else if (this.isEmpty || OrderedId64Iterable.isEmptySet(ids))\n return \"\";\n\n return CompressedId64Set.compressIds(OrderedId64Iterable.intersection(this, ids));\n }\n\n /** Compute a compact string representation of the difference between this and another set - i.e., those Ids present in this but not in the other set. */\n public computeDifference(ids: OrderedId64Iterable | CompressedId64Set | MutableCompressedId64Set): CompressedId64Set {\n if (this.isEmpty || this.equals(ids))\n return \"\";\n\n return CompressedId64Set.compressIds(OrderedId64Iterable.difference(this, ids));\n }\n\n /** Return true if this set contains no Ids. */\n public get isEmpty(): boolean {\n return OrderedId64Iterable.isEmptySet(this.ids);\n }\n\n /** Return true if the set of Ids represented by `other` is identical to those in this set.\n * @note This considers only the **distinct** Ids in `other` - duplicates are ignored.\n */\n public equals(other: CompressedId64Set | MutableCompressedId64Set | OrderedId64Iterable): boolean {\n if (other instanceof MutableCompressedId64Set) {\n if (other === this)\n return true;\n\n if (typeof other !== \"string\")\n other = other.ids;\n }\n\n if (typeof other === \"string\")\n return other === this.ids;\n\n this.updateIds();\n return OrderedId64Iterable.areEqualSets(this, other);\n }\n\n private get _isDirty(): boolean {\n return !this._inserted.isEmpty || !this._deleted.isEmpty;\n }\n\n private updateIds(): void {\n if (!this._isDirty)\n return;\n\n const difference = OrderedId64Iterable.difference(CompressedId64Set.iterable(this._ids), this._deleted.ids);\n const union = { [Symbol.iterator]: () => OrderedId64Iterable.unionIterator(difference, this._inserted.ids) };\n this._ids = CompressedId64Set.compressIds(union);\n\n this._inserted.clear();\n this._deleted.clear();\n }\n}\n"]}
|
package/lib/esm/Dictionary.js
CHANGED
|
@@ -7,8 +7,10 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { lowerBound, shallowClone } from "./SortedArray";
|
|
9
9
|
class DictionaryIterator {
|
|
10
|
+
_keys;
|
|
11
|
+
_values;
|
|
12
|
+
_curIndex = -1;
|
|
10
13
|
constructor(keys, values) {
|
|
11
|
-
this._curIndex = -1;
|
|
12
14
|
this._keys = keys;
|
|
13
15
|
this._values = values;
|
|
14
16
|
}
|
|
@@ -43,6 +45,11 @@ class DictionaryIterator {
|
|
|
43
45
|
* @public
|
|
44
46
|
*/
|
|
45
47
|
export class Dictionary {
|
|
48
|
+
_keys = [];
|
|
49
|
+
_compareKeys;
|
|
50
|
+
_cloneKey;
|
|
51
|
+
_values = [];
|
|
52
|
+
_cloneValue;
|
|
46
53
|
/**
|
|
47
54
|
* Construct a new Dictionary<K, V>.
|
|
48
55
|
* @param compareKeys The function used to compare keys within the dictionary.
|
|
@@ -50,8 +57,6 @@ export class Dictionary {
|
|
|
50
57
|
* @param cloneValue The function invoked to clone a value for insertion into the dictionary. The default implementation simply returns its input.
|
|
51
58
|
*/
|
|
52
59
|
constructor(compareKeys, cloneKey = shallowClone, cloneValue = shallowClone) {
|
|
53
|
-
this._keys = [];
|
|
54
|
-
this._values = [];
|
|
55
60
|
this._compareKeys = compareKeys;
|
|
56
61
|
this._cloneKey = cloneKey;
|
|
57
62
|
this._cloneValue = cloneValue;
|
|
@@ -1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AI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;IACzC,CAAC;IAED;;;;OAIG;IACO,UAAU,CAAC,GAAM,IAAuC,OAAO,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;CAC3H","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Collections\n */\n\nimport { OrderedComparator } from \"./Compare\";\nimport { CloneFunction, lowerBound, shallowClone } from \"./SortedArray\";\n\nclass DictionaryIterator<K, V> implements Iterator<DictionaryEntry<K, V>> {\n private _keys: K[];\n private _values: V[];\n private _curIndex = -1;\n\n public constructor(keys: K[], values: V[]) {\n this._keys = keys;\n this._values = values;\n }\n\n public next(): IteratorResult<DictionaryEntry<K, V>> {\n if (++this._curIndex >= this._keys.length) {\n // The ECMAScript spec states that value=undefined is valid if done=true. The TypeScript interface violates the spec hence the cast to any and back below.\n return { done: true } as any as IteratorResult<DictionaryEntry<K, V>>;\n } else {\n return {\n value: {\n key: this._keys[this._curIndex],\n value: this._values[this._curIndex],\n },\n done: false,\n };\n }\n }\n}\n\n/**\n * Represents an entry in a [[Dictionary]].\n * @public\n */\nexport interface DictionaryEntry<K, V> {\n /** The key used for lookup in the Dictionary. */\n key: K;\n /** The value associated with the key in the Dictionary. */\n value: V;\n}\n\n/**\n * Maintains a mapping of keys to values.\n * Unlike the standard Map<K, V>, a Dictionary<K, V> supports custom comparison logic for keys of object type (and for any other type).\n * The user supplies a key comparison function to the constructor, that must meet the following criteria given 'lhs' and 'rhs' of type K:\n * - If lhs is equal to rhs, returns 0\n * - If lhs is less than rhs, returns a negative value\n * - If lhs is greater than rhs, returns a positive value\n * - If compare(lhs, rhs) returns 0, then compare(rhs, lhs) must also return 0\n * - If compare(lhs, rhs) returns a negative value, then compare(rhs, lhs) must return a positive value, and vice versa.\n *\n * Modifying a key in a way that affects the comparison function will produce unpredictable results, the\n * most likely of which is that keys will cease to map to the values with which they were initially inserted.\n * @public\n */\nexport class Dictionary<K, V> implements Iterable<DictionaryEntry<K, V>> {\n protected _keys: K[] = [];\n protected readonly _compareKeys: OrderedComparator<K>;\n protected readonly _cloneKey: CloneFunction<K>;\n protected _values: V[] = [];\n protected readonly _cloneValue: CloneFunction<V>;\n\n /**\n * Construct a new Dictionary<K, V>.\n * @param compareKeys The function used to compare keys within the dictionary.\n * @param cloneKey The function invoked to clone a key for insertion into the dictionary. The default implementation simply returns its input.\n * @param cloneValue The function invoked to clone a value for insertion into the dictionary. The default implementation simply returns its input.\n */\n public constructor(compareKeys: OrderedComparator<K>, cloneKey: CloneFunction<K> = shallowClone, cloneValue: CloneFunction<V> = shallowClone) {\n this._compareKeys = compareKeys;\n this._cloneKey = cloneKey;\n this._cloneValue = cloneValue;\n }\n\n /** The number of entries in the dictionary. */\n public get size(): number { return this._keys.length; }\n\n /** Returns an iterator over the key-value pairs in the Dictionary suitable for use in `for-of` loops. Entries are returned in sorted order by key. */\n public [Symbol.iterator](): Iterator<DictionaryEntry<K, V>> {\n return new DictionaryIterator<K, V>(this._keys, this._values);\n }\n\n /** Provides iteration over the keys in this Dictionary, in sorted order. */\n public keys(): Iterable<K> {\n function * iterator(dict: Dictionary<K, V>) {\n for (const entry of dict)\n yield entry.key;\n }\n\n return {\n [Symbol.iterator]: () => iterator(this),\n };\n }\n\n /** Provides iteration over the values in this Dictionary, in sorted order by the corresponding keys. */\n public values(): Iterable<V> {\n function * iterator(dict: Dictionary<K, V>) {\n for (const entry of dict)\n yield entry.value;\n }\n\n return {\n [Symbol.iterator]: () => iterator(this),\n };\n }\n\n /** Removes all entries from this dictionary */\n public clear(): void {\n this._keys = [];\n this._values = [];\n }\n\n /**\n * Looks up a value by its key.\n * @param key The key to search for\n * @returns the value associated with the key, or undefined if the key is not present in the dictionary.\n */\n public get(key: K): V | undefined {\n const bound = this.lowerBound(key);\n return bound.equal ? this._values[bound.index] : undefined;\n }\n\n /**\n * Determines if an entry exists for the specified key\n * @param key The key to search for\n * @returns true if an entry exists in this dictionary corresponding to the specified key.\n */\n public has(key: K): boolean {\n return this.lowerBound(key).equal;\n }\n\n /**\n * Deletes a value using its key.\n * @param key The key to delete\n * @returns true if the key was found and deleted.\n */\n public delete(key: K): boolean {\n const bound = this.lowerBound(key);\n if (bound.equal) {\n this._values.splice(bound.index, 1);\n this._keys.splice(bound.index, 1);\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * Attempts to insert a new entry into the dictionary. If an entry with an equivalent key exists, the dictionary is unmodified.\n * If the new entry is in fact inserted, both the key and value will be cloned using the functions supplied to the dictionary's constructor.\n * @param key The key to associate with the value\n * @param value The value to associate with the key\n * @returns true if the new entry was inserted, false if an entry with an equivalent key already exists.\n */\n public insert(key: K, value: V): boolean {\n const result = this.findOrInsert(key, value);\n return result.inserted;\n }\n\n /** Obtains the value associated with the specified key, or inserts it if the specified key does not yet exist.\n * @param key The key to search for.\n * @param value The value to associate with `key` if `key` does not yet exist in the dictionary.\n * @returns The found or inserted value and a flag indicating whether the new value was inserted.\n */\n public findOrInsert(key: K, value: V): { value: V, inserted: boolean } {\n const bound = this.lowerBound(key);\n if (bound.equal)\n return { value: this._values[bound.index], inserted: false };\n\n value = this._cloneValue(value);\n this._keys.splice(bound.index, 0, this._cloneKey(key));\n this._values.splice(bound.index, 0, this._cloneValue(value));\n return { value, inserted: true };\n }\n\n /**\n * Sets the value associated with the specified key in the dictionary.\n * If no such key already exists, this is equivalent to insert(key, value); otherwise, the existing value associated with the key is replaced.\n * In either case, the value will be cloned using the function supplied to the dictionary's constructor.\n */\n public set(key: K, value: V): void {\n value = this._cloneValue(value);\n const bound = this.lowerBound(key);\n if (bound.equal) {\n this._values[bound.index] = value;\n } else {\n this._keys.splice(bound.index, 0, this._cloneKey(key));\n this._values.splice(bound.index, 0, value);\n }\n }\n\n /**\n * Extracts the contents of this dictionary as an array of { key, value } pairs, and empties this dictionary.\n * @returns An array of { key, value } pairs sorted by key.\n */\n public extractPairs(): Array<{ key: K, value: V }> {\n const pairs: Array<{ key: K, value: V }> = [];\n for (let i = 0; i < this.size; i++)\n pairs.push({ key: this._keys[i], value: this._values[i] });\n\n this.clear();\n return pairs;\n }\n\n /**\n * Extracts the contents of this dictionary as a pair of { keys, values } arrays, and empties this dictionary.\n * The array of keys is sorted according to the comparison criterion.\n * The position of each value in the array of values corresponds the the position of the corresponding key in the array of keys.\n * @returns a pair of { keys, values } arrays in which key[i] corresponds to value[i] in this dictionary and the keys are in sorted order.\n */\n public extractArrays(): { keys: K[], values: V[] } {\n const result = { keys: this._keys, values: this._values };\n this.clear();\n return result;\n }\n\n /** Apply a function to each (key, value) pair in the dictionary, in sorted order.\n * @param func The function to be applied.\n */\n public forEach(func: (key: K, value: V) => void): void {\n for (let i = 0; i < this.size; i++)\n func(this._keys[i], this._values[i]);\n }\n\n /**\n * Computes the position at which the specified key should be inserted to maintain sorted order.\n * @param key The key whose position is to be computed.\n * @returns an object with 'index' corresponding to the computed position and 'equal' set to true if an equivalent key already exists at that index.\n */\n protected lowerBound(key: K): { index: number, equal: boolean } { return lowerBound(key, this._keys, this._compareKeys); }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Dictionary.js","sourceRoot":"","sources":["../../src/Dictionary.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAGH,OAAO,EAAiB,UAAU,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAExE,MAAM,kBAAkB;IACd,KAAK,CAAM;IACX,OAAO,CAAM;IACb,SAAS,GAAG,CAAC,CAAC,CAAC;IAEvB,YAAmB,IAAS,EAAE,MAAW;QACvC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CA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,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;YACvD,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC;QAC7C,CAAC;IACH,CAAC;IAED;;;OAGG;IACI,YAAY;QACjB,MAAM,KAAK,GAAgC,EAAE,CAAC;QAC9C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE;YAChC,KAAK,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QAE7D,IAAI,CAAC,KAAK,EAAE,CAAC;QACb,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;;;;OAKG;IACI,aAAa;QAClB,MAAM,MAAM,GAAG,EAAE,IAAI,EAAE,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC;QAC1D,IAAI,CAAC,KAAK,EAAE,CAAC;QACb,OAAO,MAAM,CAAC;IAChB,CAAC;IAED;;OAEG;IACI,OAAO,CAAC,IAAgC;QAC7C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE;YAChC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;IACzC,CAAC;IAED;;;;OAIG;IACO,UAAU,CAAC,GAAM,IAAuC,OAAO,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;CAC3H","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Collections\n */\n\nimport { OrderedComparator } from \"./Compare\";\nimport { CloneFunction, lowerBound, shallowClone } from \"./SortedArray\";\n\nclass DictionaryIterator<K, V> implements Iterator<DictionaryEntry<K, V>> {\n private _keys: K[];\n private _values: V[];\n private _curIndex = -1;\n\n public constructor(keys: K[], values: V[]) {\n this._keys = keys;\n this._values = values;\n }\n\n public next(): IteratorResult<DictionaryEntry<K, V>> {\n if (++this._curIndex >= this._keys.length) {\n // The ECMAScript spec states that value=undefined is valid if done=true. The TypeScript interface violates the spec hence the cast to any and back below.\n return { done: true } as any as IteratorResult<DictionaryEntry<K, V>>;\n } else {\n return {\n value: {\n key: this._keys[this._curIndex],\n value: this._values[this._curIndex],\n },\n done: false,\n };\n }\n }\n}\n\n/**\n * Represents an entry in a [[Dictionary]].\n * @public\n */\nexport interface DictionaryEntry<K, V> {\n /** The key used for lookup in the Dictionary. */\n key: K;\n /** The value associated with the key in the Dictionary. */\n value: V;\n}\n\n/**\n * Maintains a mapping of keys to values.\n * Unlike the standard Map<K, V>, a Dictionary<K, V> supports custom comparison logic for keys of object type (and for any other type).\n * The user supplies a key comparison function to the constructor, that must meet the following criteria given 'lhs' and 'rhs' of type K:\n * - If lhs is equal to rhs, returns 0\n * - If lhs is less than rhs, returns a negative value\n * - If lhs is greater than rhs, returns a positive value\n * - If compare(lhs, rhs) returns 0, then compare(rhs, lhs) must also return 0\n * - If compare(lhs, rhs) returns a negative value, then compare(rhs, lhs) must return a positive value, and vice versa.\n *\n * Modifying a key in a way that affects the comparison function will produce unpredictable results, the\n * most likely of which is that keys will cease to map to the values with which they were initially inserted.\n * @public\n */\nexport class Dictionary<K, V> implements Iterable<DictionaryEntry<K, V>> {\n protected _keys: K[] = [];\n protected readonly _compareKeys: OrderedComparator<K>;\n protected readonly _cloneKey: CloneFunction<K>;\n protected _values: V[] = [];\n protected readonly _cloneValue: CloneFunction<V>;\n\n /**\n * Construct a new Dictionary<K, V>.\n * @param compareKeys The function used to compare keys within the dictionary.\n * @param cloneKey The function invoked to clone a key for insertion into the dictionary. The default implementation simply returns its input.\n * @param cloneValue The function invoked to clone a value for insertion into the dictionary. The default implementation simply returns its input.\n */\n public constructor(compareKeys: OrderedComparator<K>, cloneKey: CloneFunction<K> = shallowClone, cloneValue: CloneFunction<V> = shallowClone) {\n this._compareKeys = compareKeys;\n this._cloneKey = cloneKey;\n this._cloneValue = cloneValue;\n }\n\n /** The number of entries in the dictionary. */\n public get size(): number { return this._keys.length; }\n\n /** Returns an iterator over the key-value pairs in the Dictionary suitable for use in `for-of` loops. Entries are returned in sorted order by key. */\n public [Symbol.iterator](): Iterator<DictionaryEntry<K, V>> {\n return new DictionaryIterator<K, V>(this._keys, this._values);\n }\n\n /** Provides iteration over the keys in this Dictionary, in sorted order. */\n public keys(): Iterable<K> {\n function * iterator(dict: Dictionary<K, V>) {\n for (const entry of dict)\n yield entry.key;\n }\n\n return {\n [Symbol.iterator]: () => iterator(this),\n };\n }\n\n /** Provides iteration over the values in this Dictionary, in sorted order by the corresponding keys. */\n public values(): Iterable<V> {\n function * iterator(dict: Dictionary<K, V>) {\n for (const entry of dict)\n yield entry.value;\n }\n\n return {\n [Symbol.iterator]: () => iterator(this),\n };\n }\n\n /** Removes all entries from this dictionary */\n public clear(): void {\n this._keys = [];\n this._values = [];\n }\n\n /**\n * Looks up a value by its key.\n * @param key The key to search for\n * @returns the value associated with the key, or undefined if the key is not present in the dictionary.\n */\n public get(key: K): V | undefined {\n const bound = this.lowerBound(key);\n return bound.equal ? this._values[bound.index] : undefined;\n }\n\n /**\n * Determines if an entry exists for the specified key\n * @param key The key to search for\n * @returns true if an entry exists in this dictionary corresponding to the specified key.\n */\n public has(key: K): boolean {\n return this.lowerBound(key).equal;\n }\n\n /**\n * Deletes a value using its key.\n * @param key The key to delete\n * @returns true if the key was found and deleted.\n */\n public delete(key: K): boolean {\n const bound = this.lowerBound(key);\n if (bound.equal) {\n this._values.splice(bound.index, 1);\n this._keys.splice(bound.index, 1);\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * Attempts to insert a new entry into the dictionary. If an entry with an equivalent key exists, the dictionary is unmodified.\n * If the new entry is in fact inserted, both the key and value will be cloned using the functions supplied to the dictionary's constructor.\n * @param key The key to associate with the value\n * @param value The value to associate with the key\n * @returns true if the new entry was inserted, false if an entry with an equivalent key already exists.\n */\n public insert(key: K, value: V): boolean {\n const result = this.findOrInsert(key, value);\n return result.inserted;\n }\n\n /** Obtains the value associated with the specified key, or inserts it if the specified key does not yet exist.\n * @param key The key to search for.\n * @param value The value to associate with `key` if `key` does not yet exist in the dictionary.\n * @returns The found or inserted value and a flag indicating whether the new value was inserted.\n */\n public findOrInsert(key: K, value: V): { value: V, inserted: boolean } {\n const bound = this.lowerBound(key);\n if (bound.equal)\n return { value: this._values[bound.index], inserted: false };\n\n value = this._cloneValue(value);\n this._keys.splice(bound.index, 0, this._cloneKey(key));\n this._values.splice(bound.index, 0, this._cloneValue(value));\n return { value, inserted: true };\n }\n\n /**\n * Sets the value associated with the specified key in the dictionary.\n * If no such key already exists, this is equivalent to insert(key, value); otherwise, the existing value associated with the key is replaced.\n * In either case, the value will be cloned using the function supplied to the dictionary's constructor.\n */\n public set(key: K, value: V): void {\n value = this._cloneValue(value);\n const bound = this.lowerBound(key);\n if (bound.equal) {\n this._values[bound.index] = value;\n } else {\n this._keys.splice(bound.index, 0, this._cloneKey(key));\n this._values.splice(bound.index, 0, value);\n }\n }\n\n /**\n * Extracts the contents of this dictionary as an array of { key, value } pairs, and empties this dictionary.\n * @returns An array of { key, value } pairs sorted by key.\n */\n public extractPairs(): Array<{ key: K, value: V }> {\n const pairs: Array<{ key: K, value: V }> = [];\n for (let i = 0; i < this.size; i++)\n pairs.push({ key: this._keys[i], value: this._values[i] });\n\n this.clear();\n return pairs;\n }\n\n /**\n * Extracts the contents of this dictionary as a pair of { keys, values } arrays, and empties this dictionary.\n * The array of keys is sorted according to the comparison criterion.\n * The position of each value in the array of values corresponds the the position of the corresponding key in the array of keys.\n * @returns a pair of { keys, values } arrays in which key[i] corresponds to value[i] in this dictionary and the keys are in sorted order.\n */\n public extractArrays(): { keys: K[], values: V[] } {\n const result = { keys: this._keys, values: this._values };\n this.clear();\n return result;\n }\n\n /** Apply a function to each (key, value) pair in the dictionary, in sorted order.\n * @param func The function to be applied.\n */\n public forEach(func: (key: K, value: V) => void): void {\n for (let i = 0; i < this.size; i++)\n func(this._keys[i], this._values[i]);\n }\n\n /**\n * Computes the position at which the specified key should be inserted to maintain sorted order.\n * @param key The key whose position is to be computed.\n * @returns an object with 'index' corresponding to the computed position and 'equal' set to true if an equivalent key already exists at that index.\n */\n protected lowerBound(key: K): { index: number, equal: boolean } { return lowerBound(key, this._keys, this._compareKeys); }\n}\n"]}
|
package/lib/esm/Disposable.d.ts
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
*
|
|
15
15
|
* Implementations of IDisposable tend to be more "low-level" types. The disposal of such types is often handled on your behalf.
|
|
16
16
|
* However, always consult the documentation for an IDisposable type to determine under what circumstances you are expected to explicitly dispose of it.
|
|
17
|
+
* @deprecated in 5.0 Use builtin Disposable type instead.
|
|
17
18
|
* @public
|
|
18
19
|
*/
|
|
19
20
|
export interface IDisposable {
|
|
@@ -24,9 +25,15 @@ export interface IDisposable {
|
|
|
24
25
|
}
|
|
25
26
|
/**
|
|
26
27
|
* A type guard that checks whether the given argument implements `IDisposable` interface
|
|
28
|
+
* @deprecated in 5.0 Use isDisposable instead.
|
|
27
29
|
* @public
|
|
28
30
|
*/
|
|
29
31
|
export declare function isIDisposable(obj: unknown): obj is IDisposable;
|
|
32
|
+
/**
|
|
33
|
+
* A type guard that checks whether the given argument implements `Disposable` interface
|
|
34
|
+
* @public
|
|
35
|
+
*/
|
|
36
|
+
export declare function isDisposable(obj: unknown): obj is Disposable;
|
|
30
37
|
/** Convenience function for disposing of a disposable object that may be undefined.
|
|
31
38
|
* This is primarily used to simplify implementations of [[IDisposable.dispose]].
|
|
32
39
|
* As a simple example:
|
|
@@ -45,18 +52,29 @@ export declare function isIDisposable(obj: unknown): obj is IDisposable;
|
|
|
45
52
|
* @returns undefined
|
|
46
53
|
* @public
|
|
47
54
|
*/
|
|
55
|
+
export declare function dispose(disposable?: Disposable): undefined;
|
|
56
|
+
/**
|
|
57
|
+
* @deprecated in 5.0 Use builtin Disposable type instead.
|
|
58
|
+
* @public
|
|
59
|
+
*/
|
|
48
60
|
export declare function dispose(disposable?: IDisposable): undefined;
|
|
49
61
|
/** Disposes of and empties a list of disposable objects.
|
|
50
62
|
* @param list The list of disposable objects.
|
|
51
63
|
* @returns undefined
|
|
52
64
|
* @public
|
|
53
65
|
*/
|
|
66
|
+
export declare function disposeArray(list?: Disposable[]): undefined;
|
|
67
|
+
/**
|
|
68
|
+
* @deprecated in 5.0 Use builtin Disposable type instead.
|
|
69
|
+
* @public
|
|
70
|
+
*/
|
|
54
71
|
export declare function disposeArray(list?: IDisposable[]): undefined;
|
|
55
72
|
/** A 'using' function which is a substitution for .NET's using statement. It makes sure that 'dispose'
|
|
56
73
|
* is called on the resource no matter if the func returns or throws. If func returns, the return value
|
|
57
74
|
* of this function is equal to return value of func. If func throws, this function also throws (after
|
|
58
75
|
* disposing the resource).
|
|
59
76
|
* @public
|
|
77
|
+
* @deprecated in 5.0 Use `using` declarations instead.
|
|
60
78
|
*/
|
|
61
79
|
export declare function using<T extends IDisposable, TResult>(resources: T | T[], func: (...r: T[]) => TResult): TResult;
|
|
62
80
|
/** A definition of function which may be called to dispose an object
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Disposable.d.ts","sourceRoot":"","sources":["../../src/Disposable.ts"],"names":[],"mappings":"AAIA;;GAEG;
|
|
1
|
+
{"version":3,"file":"Disposable.d.ts","sourceRoot":"","sources":["../../src/Disposable.ts"],"names":[],"mappings":"AAIA;;GAEG;AAMH;;;;;;;;;;;;;;;GAeG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/esm/Disposable.js
CHANGED
|
@@ -5,46 +5,42 @@
|
|
|
5
5
|
/** @packageDocumentation
|
|
6
6
|
* @module Utils
|
|
7
7
|
*/
|
|
8
|
+
/* eslint-disable @typescript-eslint/no-deprecated */
|
|
9
|
+
Symbol.dispose ??= Symbol("Symbol.dispose");
|
|
10
|
+
Symbol.asyncDispose ??= Symbol("Symbol.asyncDispose");
|
|
8
11
|
/**
|
|
9
12
|
* A type guard that checks whether the given argument implements `IDisposable` interface
|
|
13
|
+
* @deprecated in 5.0 Use isDisposable instead.
|
|
10
14
|
* @public
|
|
11
15
|
*/
|
|
12
16
|
export function isIDisposable(obj) {
|
|
13
17
|
return !!obj && (obj instanceof Object) && !!obj.dispose && (typeof obj.dispose === "function");
|
|
14
18
|
}
|
|
15
|
-
/**
|
|
16
|
-
*
|
|
17
|
-
* As a simple example:
|
|
18
|
-
* ```ts
|
|
19
|
-
* class Disposable implements IDisposable {
|
|
20
|
-
* public member1?: DisposableType1;
|
|
21
|
-
* public member2?: DisposableType2;
|
|
22
|
-
*
|
|
23
|
-
* public dispose() {
|
|
24
|
-
* this.member1 = dispose(this.member1); // If member1 is defined, dispose of it and set it to undefined.
|
|
25
|
-
* this.member2 = dispose(this.member2); // Likewise for member2.
|
|
26
|
-
* }
|
|
27
|
-
* }
|
|
28
|
-
* ```
|
|
29
|
-
* @param disposable The object to be disposed of.
|
|
30
|
-
* @returns undefined
|
|
19
|
+
/**
|
|
20
|
+
* A type guard that checks whether the given argument implements `Disposable` interface
|
|
31
21
|
* @public
|
|
32
22
|
*/
|
|
23
|
+
export function isDisposable(obj) {
|
|
24
|
+
return !!obj && (obj instanceof Object) && !!obj[Symbol.dispose] && (typeof obj[Symbol.dispose] === "function");
|
|
25
|
+
}
|
|
33
26
|
export function dispose(disposable) {
|
|
34
|
-
if (undefined !== disposable)
|
|
35
|
-
|
|
27
|
+
if (undefined !== disposable) {
|
|
28
|
+
if (Symbol.dispose in disposable)
|
|
29
|
+
disposable[Symbol.dispose]();
|
|
30
|
+
else
|
|
31
|
+
disposable.dispose();
|
|
32
|
+
}
|
|
36
33
|
return undefined;
|
|
37
34
|
}
|
|
38
|
-
/** Disposes of and empties a list of disposable objects.
|
|
39
|
-
* @param list The list of disposable objects.
|
|
40
|
-
* @returns undefined
|
|
41
|
-
* @public
|
|
42
|
-
*/
|
|
43
35
|
export function disposeArray(list) {
|
|
44
36
|
if (undefined === list)
|
|
45
37
|
return undefined;
|
|
46
|
-
for (const entry of list)
|
|
47
|
-
dispose
|
|
38
|
+
for (const entry of list) {
|
|
39
|
+
if (Symbol.dispose in entry)
|
|
40
|
+
entry[Symbol.dispose]();
|
|
41
|
+
else
|
|
42
|
+
entry.dispose();
|
|
43
|
+
}
|
|
48
44
|
list.length = 0;
|
|
49
45
|
return undefined;
|
|
50
46
|
}
|
|
@@ -53,6 +49,7 @@ export function disposeArray(list) {
|
|
|
53
49
|
* of this function is equal to return value of func. If func throws, this function also throws (after
|
|
54
50
|
* disposing the resource).
|
|
55
51
|
* @public
|
|
52
|
+
* @deprecated in 5.0 Use `using` declarations instead.
|
|
56
53
|
*/
|
|
57
54
|
export function using(resources, func) {
|
|
58
55
|
if (!Array.isArray(resources))
|
|
@@ -73,6 +70,7 @@ export function using(resources, func) {
|
|
|
73
70
|
}
|
|
74
71
|
}
|
|
75
72
|
class FuncDisposable {
|
|
73
|
+
_disposeFunc;
|
|
76
74
|
constructor(disposeFunc) { this._disposeFunc = disposeFunc; }
|
|
77
75
|
dispose() { this._disposeFunc(); }
|
|
78
76
|
}
|
|
@@ -80,6 +78,7 @@ class FuncDisposable {
|
|
|
80
78
|
* @public
|
|
81
79
|
*/
|
|
82
80
|
export class DisposableList {
|
|
81
|
+
_disposables;
|
|
83
82
|
/** Creates a disposable list. */
|
|
84
83
|
constructor(disposables = []) {
|
|
85
84
|
this._disposables = [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Disposable.js","sourceRoot":"","sources":["../../src/Disposable.ts"],"names":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YACxC,UAAU,CAAC,OAAO,EAAE,CAAC;IACzB,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Utils\n */\n\n/** Interface adopted by a type which has deterministic cleanup logic.\n * For example:\n * - Most rendering-related types, such as [[RenderGraphic]] and [[Viewport]], own WebGL resources which must be explicitly released when no longer needed.\n * - Some low-level objects like [[ECDb]] own native types defined in C++ code which must be explicitly released when no longer needed.\n *\n * A similar concept exists in languages like C++ (implemented as \"destructors\") and C# (\"IDisposable\").\n * However, because TypeScript and Javascript lack any built-in support for deterministic destruction, it is up to the programmer to ensure dispose() is called appropriately.\n * Failure to do so may result in memory leaks or leaking of other resources.\n *\n * IDisposable tends to be contagious; that is, if a type has members which implement IDisposable, that type should also implement IDisposable to dispose of those members.\n *\n * Implementations of IDisposable tend to be more \"low-level\" types. The disposal of such types is often handled on your behalf.\n * However, always consult the documentation for an IDisposable type to determine under what circumstances you are expected to explicitly dispose of it.\n * @public\n */\nexport interface IDisposable {\n /** Disposes of any resources owned by this object.\n * @note The object is generally considered unusable after it has been disposed of.\n */\n dispose(): void;\n}\n\n/**\n * A type guard that checks whether the given argument implements `IDisposable` interface\n * @public\n */\nexport function isIDisposable(obj: unknown): obj is IDisposable {\n return !!obj && (obj instanceof Object) && !!(obj as IDisposable).dispose && (typeof (obj as IDisposable).dispose === \"function\");\n}\n\n/** Convenience function for disposing of a disposable object that may be undefined.\n * This is primarily used to simplify implementations of [[IDisposable.dispose]].\n * As a simple example:\n * ```ts\n * class Disposable implements IDisposable {\n * public member1?: DisposableType1;\n * public member2?: DisposableType2;\n *\n * public dispose() {\n * this.member1 = dispose(this.member1); // If member1 is defined, dispose of it and set it to undefined.\n * this.member2 = dispose(this.member2); // Likewise for member2.\n * }\n * }\n * ```\n * @param disposable The object to be disposed of.\n * @returns undefined\n * @public\n */\nexport function dispose(disposable?: IDisposable): undefined {\n if (undefined !== disposable)\n disposable.dispose();\n return undefined;\n}\n\n/** Disposes of and empties a list of disposable objects.\n * @param list The list of disposable objects.\n * @returns undefined\n * @public\n */\nexport function disposeArray(list?: IDisposable[]): undefined {\n if (undefined === list)\n return undefined;\n\n for (const entry of list)\n dispose(entry);\n\n list.length = 0;\n return undefined;\n}\n\n/** A 'using' function which is a substitution for .NET's using statement. It makes sure that 'dispose'\n * is called on the resource no matter if the func returns or throws. If func returns, the return value\n * of this function is equal to return value of func. If func throws, this function also throws (after\n * disposing the resource).\n * @public\n */\nexport function using<T extends IDisposable, TResult>(resources: T | T[], func: (...r: T[]) => TResult): TResult {\n if (!Array.isArray(resources))\n return using([resources], func);\n\n const doDispose = () => resources.forEach((disposable) => disposable.dispose());\n let shouldDisposeImmediately = true;\n\n try {\n const result = func(...resources);\n if (result instanceof Promise) {\n shouldDisposeImmediately = false;\n result.then(doDispose, doDispose);\n }\n return result;\n } finally {\n if (shouldDisposeImmediately)\n doDispose();\n }\n}\n\n/** A definition of function which may be called to dispose an object\n * @public\n */\nexport type DisposeFunc = () => void;\n\nclass FuncDisposable implements IDisposable {\n private _disposeFunc: () => void;\n constructor(disposeFunc: () => void) { this._disposeFunc = disposeFunc; }\n public dispose() { this._disposeFunc(); }\n}\n\n/** A disposable container of disposable objects.\n * @public\n */\nexport class DisposableList implements IDisposable {\n private _disposables: IDisposable[];\n\n /** Creates a disposable list. */\n constructor(disposables: Array<IDisposable | DisposeFunc> = []) {\n this._disposables = [];\n disposables.forEach((disposable) => {\n this.add(disposable);\n });\n }\n\n private isDisposable(x: IDisposable | DisposeFunc): x is IDisposable {\n return (x as IDisposable).dispose !== undefined;\n }\n\n /** Register an object for disposal. */\n public add(disposable: IDisposable | DisposeFunc) {\n if (this.isDisposable(disposable))\n this._disposables.push(disposable);\n else\n this._disposables.push(new FuncDisposable(disposable));\n }\n\n /** Unregister disposable object. */\n public remove(disposable: IDisposable): void {\n const idx = this._disposables.indexOf(disposable);\n if (-1 !== idx)\n this._disposables.splice(idx, 1);\n }\n\n /** Disposes all registered objects. */\n public dispose(): void {\n for (const disposable of this._disposables)\n disposable.dispose();\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Disposable.js","sourceRoot":"","sources":["../../src/Disposable.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,qDAAqD;AACpD,MAAc,CAAC,OAAO,KAAK,MAAM,CAAC,gBAAgB,CAAC,CAAC;AACpD,MAAc,CAAC,YAAY,KAAK,MAAM,CAAC,qBAAqB,CAAC,CAAC;AAyB/D;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,GAAY;IACxC,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,YAAY,MAAM,CAAC,IAAI,CAAC,CAAE,GAAmB,CAAC,OAAO,IAAI,CAAC,OAAQ,GAAmB,CAAC,OAAO,KAAK,UAAU,CAAC,CAAC;AACpI,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,GAAY;IACvC,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,YAAY,MAAM,CAAC,IAAI,CAAC,CAAE,GAAkB,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,OAAQ,GAAkB,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,CAAC,CAAC;AAClJ,CAAC;AA0BD,MAAM,UAAU,OAAO,CAAC,UAAqC;IAC3D,IAAI,SAAS,KAAK,UAAU,EAAE,CAAC;QAC7B,IAAI,MAAM,CAAC,OAAO,IAAI,UAAU;YAC9B,UAAU,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;;YAE7B,UAAU,CAAC,OAAO,EAAE,CAAC;IACzB,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAaD,MAAM,UAAU,YAAY,CAAC,IAAmC;IAC9D,IAAI,SAAS,KAAK,IAAI;QACpB,OAAO,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jC,YAAY,cAAgD,EAAE;QAC5D,IAAI,CAAC,YAAY,GAAG,EAAE,CAAC;QACvB,WAAW,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,EAAE;YACjC,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QACvB,CAAC,CAAC,CAAC;IACL,CAAC;IAEO,YAAY,CAAC,CAA4B;QAC/C,OAAQ,CAAiB,CAAC,OAAO,KAAK,SAAS,CAAC;IAClD,CAAC;IAED,uCAAuC;IAChC,GAAG,CAAC,UAAqC;QAC9C,IAAI,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC;YAC/B,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;;YAEnC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,cAAc,CAAC,UAAU,CAAC,CAAC,CAAC;IAC3D,CAAC;IAED,oCAAoC;IAC7B,MAAM,CAAC,UAAuB;QACnC,MAAM,GAAG,GAAG,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QAClD,IAAI,CAAC,CAAC,KAAK,GAAG;YACZ,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;IACrC,CAAC;IAED,uCAAuC;IAChC,OAAO;QACZ,KAAK,MAAM,UAAU,IAAI,IAAI,CAAC,YAAY;YACxC,UAAU,CAAC,OAAO,EAAE,CAAC;IACzB,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Utils\n */\n\n/* eslint-disable @typescript-eslint/no-deprecated */\n(Symbol as any).dispose ??= Symbol(\"Symbol.dispose\");\n(Symbol as any).asyncDispose ??= Symbol(\"Symbol.asyncDispose\");\n\n/** Interface adopted by a type which has deterministic cleanup logic.\n * For example:\n * - Most rendering-related types, such as [[RenderGraphic]] and [[Viewport]], own WebGL resources which must be explicitly released when no longer needed.\n * - Some low-level objects like [[ECDb]] own native types defined in C++ code which must be explicitly released when no longer needed.\n *\n * A similar concept exists in languages like C++ (implemented as \"destructors\") and C# (\"IDisposable\").\n * However, because TypeScript and Javascript lack any built-in support for deterministic destruction, it is up to the programmer to ensure dispose() is called appropriately.\n * Failure to do so may result in memory leaks or leaking of other resources.\n *\n * IDisposable tends to be contagious; that is, if a type has members which implement IDisposable, that type should also implement IDisposable to dispose of those members.\n *\n * Implementations of IDisposable tend to be more \"low-level\" types. The disposal of such types is often handled on your behalf.\n * However, always consult the documentation for an IDisposable type to determine under what circumstances you are expected to explicitly dispose of it.\n * @deprecated in 5.0 Use builtin Disposable type instead.\n * @public\n */\nexport interface IDisposable {\n /** Disposes of any resources owned by this object.\n * @note The object is generally considered unusable after it has been disposed of.\n */\n dispose(): void;\n}\n\n/**\n * A type guard that checks whether the given argument implements `IDisposable` interface\n * @deprecated in 5.0 Use isDisposable instead.\n * @public\n */\nexport function isIDisposable(obj: unknown): obj is IDisposable {\n return !!obj && (obj instanceof Object) && !!(obj as IDisposable).dispose && (typeof (obj as IDisposable).dispose === \"function\");\n}\n\n/**\n * A type guard that checks whether the given argument implements `Disposable` interface\n * @public\n */\nexport function isDisposable(obj: unknown): obj is Disposable {\n return !!obj && (obj instanceof Object) && !!(obj as Disposable)[Symbol.dispose] && (typeof (obj as Disposable)[Symbol.dispose] === \"function\");\n}\n\n/** Convenience function for disposing of a disposable object that may be undefined.\n * This is primarily used to simplify implementations of [[IDisposable.dispose]].\n * As a simple example:\n * ```ts\n * class Disposable implements IDisposable {\n * public member1?: DisposableType1;\n * public member2?: DisposableType2;\n *\n * public dispose() {\n * this.member1 = dispose(this.member1); // If member1 is defined, dispose of it and set it to undefined.\n * this.member2 = dispose(this.member2); // Likewise for member2.\n * }\n * }\n * ```\n * @param disposable The object to be disposed of.\n * @returns undefined\n * @public\n */\nexport function dispose(disposable?: Disposable): undefined;\n/**\n * @deprecated in 5.0 Use builtin Disposable type instead.\n * @public\n */\nexport function dispose(disposable?: IDisposable): undefined; // eslint-disable-line @typescript-eslint/unified-signatures\nexport function dispose(disposable?: Disposable | IDisposable): undefined {\n if (undefined !== disposable) {\n if (Symbol.dispose in disposable)\n disposable[Symbol.dispose]();\n else\n disposable.dispose();\n }\n return undefined;\n}\n\n/** Disposes of and empties a list of disposable objects.\n * @param list The list of disposable objects.\n * @returns undefined\n * @public\n */\nexport function disposeArray(list?: Disposable[]): undefined;\n/**\n * @deprecated in 5.0 Use builtin Disposable type instead.\n * @public\n */\nexport function disposeArray(list?: IDisposable[]): undefined; // eslint-disable-line @typescript-eslint/unified-signatures\nexport function disposeArray(list?: Disposable[] | IDisposable[]): undefined {\n if (undefined === list)\n return undefined;\n\n for (const entry of list) {\n if (Symbol.dispose in entry)\n entry[Symbol.dispose]();\n else\n entry.dispose();\n }\n\n list.length = 0;\n return undefined;\n}\n\n/** A 'using' function which is a substitution for .NET's using statement. It makes sure that 'dispose'\n * is called on the resource no matter if the func returns or throws. If func returns, the return value\n * of this function is equal to return value of func. If func throws, this function also throws (after\n * disposing the resource).\n * @public\n * @deprecated in 5.0 Use `using` declarations instead.\n */\nexport function using<T extends IDisposable, TResult>(resources: T | T[], func: (...r: T[]) => TResult): TResult {\n if (!Array.isArray(resources))\n return using([resources], func);\n\n const doDispose = () => resources.forEach((disposable) => disposable.dispose());\n let shouldDisposeImmediately = true;\n\n try {\n const result = func(...resources);\n if (result instanceof Promise) {\n shouldDisposeImmediately = false;\n result.then(doDispose, doDispose);\n }\n return result;\n } finally {\n if (shouldDisposeImmediately)\n doDispose();\n }\n}\n\n/** A definition of function which may be called to dispose an object\n * @public\n */\nexport type DisposeFunc = () => void;\n\nclass FuncDisposable implements IDisposable {\n private _disposeFunc: () => void;\n constructor(disposeFunc: () => void) { this._disposeFunc = disposeFunc; }\n public dispose() { this._disposeFunc(); }\n}\n\n/** A disposable container of disposable objects.\n * @public\n */\nexport class DisposableList implements IDisposable {\n private _disposables: IDisposable[];\n\n /** Creates a disposable list. */\n constructor(disposables: Array<IDisposable | DisposeFunc> = []) {\n this._disposables = [];\n disposables.forEach((disposable) => {\n this.add(disposable);\n });\n }\n\n private isDisposable(x: IDisposable | DisposeFunc): x is IDisposable {\n return (x as IDisposable).dispose !== undefined;\n }\n\n /** Register an object for disposal. */\n public add(disposable: IDisposable | DisposeFunc) {\n if (this.isDisposable(disposable))\n this._disposables.push(disposable);\n else\n this._disposables.push(new FuncDisposable(disposable));\n }\n\n /** Unregister disposable object. */\n public remove(disposable: IDisposable): void {\n const idx = this._disposables.indexOf(disposable);\n if (-1 !== idx)\n this._disposables.splice(idx, 1);\n }\n\n /** Disposes all registered objects. */\n public dispose(): void {\n for (const disposable of this._disposables)\n disposable.dispose();\n }\n}\n"]}
|
package/lib/esm/Id.d.ts
CHANGED
|
@@ -276,10 +276,6 @@ export declare class TransientIdSequence {
|
|
|
276
276
|
* Each call to [[getNext]] increments this by 1 and uses it as the local Id of the generated [[Id64String]].
|
|
277
277
|
*/
|
|
278
278
|
get currentLocalId(): number;
|
|
279
|
-
/** Generate and return the next transient Id64String in the sequence.
|
|
280
|
-
* @deprecated in 3.x. Use [[getNext]].
|
|
281
|
-
*/
|
|
282
|
-
get next(): Id64String;
|
|
283
279
|
/** Generate and return the next transient Id64String in the sequence. */
|
|
284
280
|
getNext(): Id64String;
|
|
285
281
|
/** Preview the transient Id64String that will be returned by the next call to [[getNext]].
|
package/lib/esm/Id.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Id.d.ts","sourceRoot":"","sources":["../../src/Id.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC;AAEhC;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC;AAEhC;;GAEG;AACH,MAAM,MAAM,OAAO,GAAG,GAAG,CAAC,UA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,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAE/C;IAED,iCAAiC;IACjC,SAAgB,WAAW,IAAI,UAAU,CAOxC;IAED;;;;;;;OAOG;IACH,SAAgB,SAAS,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU,CAkBvD;CACF"}
|
package/lib/esm/Id.js
CHANGED
|
@@ -417,11 +417,11 @@ export var Id64;
|
|
|
417
417
|
* @public
|
|
418
418
|
*/
|
|
419
419
|
class Uint32Set {
|
|
420
|
+
_map = new Map();
|
|
420
421
|
/** Construct a new Uint32Set.
|
|
421
422
|
* @param ids If supplied, all of the specified Ids will be added to the new set.
|
|
422
423
|
*/
|
|
423
424
|
constructor(ids) {
|
|
424
|
-
this._map = new Map();
|
|
425
425
|
if (undefined !== ids)
|
|
426
426
|
this.addIds(ids);
|
|
427
427
|
}
|
|
@@ -482,8 +482,11 @@ export var Id64;
|
|
|
482
482
|
/** Remove an Id from the set. */
|
|
483
483
|
delete(low, high) {
|
|
484
484
|
const set = this._map.get(high);
|
|
485
|
-
if (undefined !== set)
|
|
485
|
+
if (undefined !== set) {
|
|
486
486
|
set.delete(low);
|
|
487
|
+
if (set.size === 0)
|
|
488
|
+
this._map.delete(high);
|
|
489
|
+
}
|
|
487
490
|
}
|
|
488
491
|
/** Returns true if the set contains the specified Id. */
|
|
489
492
|
has(low, high) {
|
|
@@ -532,9 +535,7 @@ export var Id64;
|
|
|
532
535
|
* @public
|
|
533
536
|
*/
|
|
534
537
|
class Uint32Map {
|
|
535
|
-
|
|
536
|
-
this._map = new Map();
|
|
537
|
-
}
|
|
538
|
+
_map = new Map();
|
|
538
539
|
/** Remove all entries from the map. */
|
|
539
540
|
clear() { this._map.clear(); }
|
|
540
541
|
/** Find an entry in the map by Id. */
|
|
@@ -585,6 +586,9 @@ function validateLocalId(num) {
|
|
|
585
586
|
* @public
|
|
586
587
|
*/
|
|
587
588
|
export class TransientIdSequence {
|
|
589
|
+
/** The starting local Id provided to the constructor. The sequence begins at `initialLocalId + 1`. */
|
|
590
|
+
initialLocalId;
|
|
591
|
+
_localId;
|
|
588
592
|
/** Constructor.
|
|
589
593
|
* @param initialLocalId The starting local Id. The local Id of the first [[Id64String]] generated by [[getNext]] will be `initialLocalId + 1`.
|
|
590
594
|
*/
|
|
@@ -600,12 +604,6 @@ export class TransientIdSequence {
|
|
|
600
604
|
get currentLocalId() {
|
|
601
605
|
return this._localId;
|
|
602
606
|
}
|
|
603
|
-
/** Generate and return the next transient Id64String in the sequence.
|
|
604
|
-
* @deprecated in 3.x. Use [[getNext]].
|
|
605
|
-
*/
|
|
606
|
-
get next() {
|
|
607
|
-
return this.getNext();
|
|
608
|
-
}
|
|
609
607
|
/** Generate and return the next transient Id64String in the sequence. */
|
|
610
608
|
getNext() {
|
|
611
609
|
return Id64.fromLocalAndBriefcaseIds(++this._localId, 0xffffff);
|