/** * TypedFastBitSet.js : a fast bit set implementation in JavaScript. * (c) the authors * Licensed under the Apache License, Version 2.0. * * Speed-optimized BitSet implementation for modern browsers and JavaScript engines. * * Alternative version to TypedFastBitSet * This starts of as storing entries as an array in a Uint32Array Typed Array * The largest set value is first in the array. Everything else has no defined order * The largest set value is used when converting into a bitset to correctly size new Array * Once more than 256 entries have been added structure will convert to a bitset if it will create a smaller array * Very sparse data will remain an array until 1024 entries where it will convert to a bitset */ import { BitSet } from "./utils"; declare enum Type { ARRAY = 0, BITSET = 1, MIXED = 2 } /** * you can provide an iterable * an exception is thrown if typed arrays are not supported */ export declare class SparseTypedFastBitSet implements BitSet { private data; private arraySize; get words(): Uint32Array; constructor(iterable?: Iterable | null, data?: Uint32Array); private toBitset; /** * Add the value (Set the bit at index to true) */ add(index: number): void; /** * If the value was not in the set, add it, otherwise remove it (flip bit at index) */ flip(index: number): void; /** * Remove all values, reset memory usage */ clear(): void; /** * Set the bit at index to false */ remove(index: number): void; /** * Set bits from start (inclusive) to end (exclusive) */ addRange(start: number, end: number): void; /** * Remove bits from start (inclusive) to end (exclusive) */ removeRange(start: number, end: number): void; /** * @returns true if no bit is set */ isEmpty(): boolean; /** * Is the value contained in the set? Is the bit at index true or false? */ has(index: number): boolean; /** * Tries to add the value (Set the bit at index to true) * * @returns 1 if the value was added, 0 if the value was already present */ checkedAdd(index: number): 1 | 0; /** * Reduce the memory usage to a minimum */ trim(): void; /** * Resize the bitset so that we can write a value at index */ resize(index: number, capacity?: number): Type.ARRAY | Type.BITSET; /** * How many values stored in the set? How many set bits? */ size(): number; /** * @returns the set bit locations (values) */ array(): number[]; forEach(fnc: (id: number) => void): void; /** * Iterator of set bit locations (values) */ [Symbol.iterator](): IterableIterator; /** * Creates a copy of this bitmap */ clone(): SparseTypedFastBitSet; /** * Check if this bitset intersects with another one, * no bitmap is modified */ intersects(otherbitmap: BitSet): boolean; /** * Computes the intersection between this bitset and another one, * the current bitmap is modified (and returned by the function) */ intersection(otherbitmap: BitSet): BitSet; /** * Computes the size of the intersection between this bitset and another one */ intersection_size(otherbitmap: BitSet): number; /** * Computes the intersection between this bitset and another one, * a new bitmap is generated */ new_intersection(otherbitmap: BitSet): BitSet; /** * Computes the intersection between this bitset and another one, * the current bitmap is modified */ equals(otherbitmap: BitSet): boolean; /** * Computes the difference between this bitset and another one, * the current bitset is modified (and returned by the function) */ difference(otherbitmap: BitSet): BitSet; /** * Computes the difference between this bitset and another one, * the other bitset is modified (and returned by the function) * * (for this set A and other set B, this computes B = A - B and returns B) */ difference2(otherbitmap: T): T; /** * Computes the difference between this bitset and another one, * a new bitmap is generated */ new_difference(otherbitmap: BitSet): BitSet; /** * Computes the size of the difference between this bitset and another one */ difference_size(otherbitmap: BitSet): number; /** * Computes the changed elements (XOR) between this bitset and another one, * the current bitset is modified (and returned by the function) */ change(otherbitmap: BitSet): this; /** * Computes the change between this bitset and another one, * a new bitmap is generated */ new_change(otherbitmap: BitSet): SparseTypedFastBitSet; /** * Computes the number of changed elements between this bitset and another one */ change_size(otherbitmap: BitSet): number; /** * @returns a string representation */ toString(): string; /** * Computes the union between this bitset and another one, * the current bitset is modified (and returned by the function) */ union(otherbitmap: BitSet): this; /** * Computes the union between this bitset and another one, * a new bitmap is generated */ new_union(otherbitmap: BitSet): SparseTypedFastBitSet; /** * Computes the size union between this bitset and another one */ union_size(otherbitmap: BitSet): number; /** * will put array based one first and return type if both array smallest first */ private static order; } export {};