@itwin/core-bentley
Version:
Bentley JavaScript core components
75 lines • 6.11 kB
TypeScript
/** @packageDocumentation
* @module Ids
*/
import { CompressedId64Set } from "./CompressedId64Set";
import { Id64Array, Id64String } from "./Id";
/** @public */
export type OrderedId64Iterable = Iterable<Id64String>;
/** A collection of **valid** [[Id64String]]s sorted in ascending order by the unsigned 64-bit integer value of the Ids.
* This ordering is a requirement for several groups of APIs including [[CompressedId64Set]].
* When used as input to a function, duplicate Ids are ignored; when returned as a function output, no duplicates are present.
* @see [[CompressedId64Set]] for a compact string representation of such an ordered collection.
* @see [[OrderedId64Iterable.compare]] for a function that compares Ids based on this criterion.
* @see [[OrderedId64Array]] for a mutable implementation.
* @public
*/
export declare namespace OrderedId64Iterable {
/** An ordered comparison of [[Id64String]]s suitable for use with sorting routines like
* [Array.sort](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort) and sorted containers
* like [[SortedArray]] and [[Dictionary]]. The comparison compares the 64-bit numerical values of the two Ids, returning a negative number if lhs < rhs,
* a positive number if lhs > rhs, or zero if lhs == rhs.
* The default string comparison is fine (and more efficient) when numerical ordering is not required; use this instead if you want e.g., "0x100" to be greater than "0xf".
* @see [[OrderedId64Iterable.sortArray]] for a convenient way to sort an array of Id64Strings.
*/
function compare(lhs: Id64String, rhs: Id64String): number;
/** Sort an array of [[Id64String]]s **in-place** in ascending order by their 64-bit numerical values.
* @see [[OrderedId64Iterable.compare]] for the comparison routine used.
* @returns the input array.
* @note This function returns its input for consistency with Javascript's
* [Array.sort](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort) method.
* It **does not** create a **new** array.
*/
function sortArray(ids: Id64Array): Id64Array;
/** Given two ordered collections of [[Id64String]]s, determine whether they are identical sets. Duplicate Ids are ignored.
* @note If the inputs are not ordered as required by [[OrderedId64Iterable]], the results are unpredictable.
*/
function areEqualSets(ids1: OrderedId64Iterable, ids2: OrderedId64Iterable): boolean;
/** Given an ordered collection of [[Id64String]]s, determine if it contains any Ids.
* @param ids A well-formed, ordered collection of zero or more valid Ids.
* @returns true if the input represents an empty set of Ids. The result is unspecified if the input does not meet the criteria for the input type.
*/
function isEmptySet(ids: OrderedId64Iterable | CompressedId64Set): boolean;
/** Given an ordered collection of [[Id64String]]s possibly containing duplicates, produce an ordered collection containing no duplicates.
* @note If the inputs are not ordered as required by [[OrderedId64Iterable]], the results are unpredictable.
*/
function unique(ids: OrderedId64Iterable): OrderedId64Iterable;
/** Given an ordered collection of [[Id64String]]s possibly containing duplicates, produce an ordered iterator over the distinct Ids, eliminating duplicates.
* @note If the inputs are not ordered as required by [[OrderedId64Iterable]], the results are unpredictable.
*/
function uniqueIterator(ids: OrderedId64Iterable): Generator<string, void, unknown>;
/** Given two ordered collections of [[Id64String]]s, produce a collection representing their union - i.e., the Ids that are present in either or both collections.
* @note If the inputs are not ordered as required by [[OrderedId64Iterable]], the results are unpredictable.
*/
function union(ids1: OrderedId64Iterable, ids2: OrderedId64Iterable): OrderedId64Iterable;
/** Given two ordered collections of [[Id64String]]s, produce an iterator representing their intersection - i.e., the Ids that are present in both collections.
* @note If the inputs are not ordered as required by [[OrderedId64Iterable]], the results are unpredictable.
*/
function intersection(ids1: OrderedId64Iterable, ids2: OrderedId64Iterable): OrderedId64Iterable;
/** Given two ordered collections of [[Id64String]]s, produce an iterator representing their difference - i.e., the Ids that are present in `ids1` but not present in `ids2`.
* @note If the inputs are not ordered as required by [[OrderedId64Iterable]], the results are unpredictable.
*/
function difference(ids1: OrderedId64Iterable, ids2: OrderedId64Iterable): OrderedId64Iterable;
/** Given two ordered collections of [[Id64String]]s, produce an iterator representing their union - i.e., the Ids that are present in either or both collections.
* @note If the inputs are not ordered as required by [[OrderedId64Iterable]], the results are unpredictable.
*/
function unionIterator(ids1: OrderedId64Iterable, ids2: OrderedId64Iterable): Generator<string, void, unknown>;
/** Given two ordered collections of [[Id64String]]s, produce an iterator representing their intersection - i.e., the Ids that are present in both collections.
* @note If the inputs are not ordered as required by [[OrderedId64Iterable]], the results are unpredictable.
*/
function intersectionIterator(ids1: OrderedId64Iterable, ids2: OrderedId64Iterable): Generator<string, void, unknown>;
/** Given two ordered collections of [[Id64String]]s, produce an iterator representing their difference - i.e., the Ids that are present in `ids1` but not present in `ids2`.
* @note If the inputs are not ordered as required by [[OrderedId64Iterable]], the results are unpredictable.
*/
function differenceIterator(ids1: OrderedId64Iterable, ids2: OrderedId64Iterable): Generator<string, void, unknown>;
}
//# sourceMappingURL=OrderedId64Iterable.d.ts.map