UNPKG

@itwin/core-bentley

Version:

Bentley JavaScript core components

41 lines 2.12 kB
/** @packageDocumentation * @module Collections */ import { OrderedComparator } from "./Compare"; import { CloneFunction, SortedArray } from "./SortedArray"; /** A read-only equivalent of `Set<T>` that maintains its elements in sorted order as specified by a comparison function. * Iteration returns elements in the order specified by the comparison function, as opposed to `Set` which returns elements in insertion order. * Implemented in terms of [[SortedArray]]. * @public */ export declare class ReadonlyOrderedSet<T> implements Iterable<T> { protected readonly _array: SortedArray<T>; /** Construct a new ReadonlyOrderedSet<T>. * @param compare The function used to compare elements within the set, determining their ordering. * @param clone The function invoked to clone a new element for insertion into the set. The default implementation simply returns its input. */ constructor(compare: OrderedComparator<T>, clone?: CloneFunction<T>); /** The number of elements in the set. */ get size(): number; /** Returns true if `value` is present in the set. */ has(value: T): boolean; /** Iterate over the elements in sorted order (as opposed to `Set`'s iterator, which returns elements in insertion order). */ [Symbol.iterator](): Iterator<T>; } /** A mutable [[ReadonlyOrderedSet]]. * @public */ export declare class OrderedSet<T> extends ReadonlyOrderedSet<T> { /** Construct a new OrderedSet<T>. * @param compare The function used to compare elements within the set, determining their ordering. * @param clone The function invoked to clone a new element for insertion into the set. The default implementation simply returns its input. */ constructor(compare: OrderedComparator<T>, clone?: CloneFunction<T>); /** Remove all elements from the set. */ clear(): void; /** Add the specified element to the set. Returns this set. */ add(value: T): this; /** Removes the specified element from the set. Returns `true` if the element was present. */ delete(value: T): boolean; } //# sourceMappingURL=OrderedSet.d.ts.map