Creates an instance of RoaringBitmap32 with a given initial capacity.
Optional
capacity: numberThe initial capacity of the bitmap.
RoaringBitmap32
Creates an instance of RoaringBitmap32, or copies the given bitmap.
Is faster to pass a Uint32Array instance instead of an array or an iterable.
Is even faster if the given argument is a RoaringBitmap32 (performs a fast copy).
Optional
values: Iterable<number>RoaringBitmap32
Creates a new frozen readonly view of the given bitmap. The bitmap will contain the same data, and if the first bitmap is modified the second one will be modified too. The created bitmap is frozen, so it is not possible to modify it.
The source RoaringBitmap32.
Must be "frozen"
RoaringBitmap32Iterator
Readonly
DeserializationReadonly
FileReadonly
FileReadonly
FrozenReadonly
SerializationReturns always "RoaringBitmap32".
To have a standard string representation of the content as a string, call contentToString() instead.
"Set"
RoaringBitmap32
Static
Readonly
DeserializationStatic
Readonly
FileStatic
Readonly
FileStatic
Readonly
FrozenStatic
Readonly
SerializationStatic
Private
Readonly
defaultProperty: The version of the CRoaring libary as a string. Example: "0.9.2"
RoaringBitmap32
Property: The version of the roaring npm package as a string. Example: "1.2.0"
RoaringBitmap32
Property. True if the bitmap is empty.
ReadonlyRoaringBitmap32
Property. True if the bitmap is read-only. A read-only bitmap cannot be modified, every operation will throw an error. You can freeze a bitmap using the freeze() method. A bitmap cannot be unfrozen.
ReadonlyRoaringBitmap32
Property. Gets the number of items in the set (cardinality).
ReadonlyRoaringBitmap32
Static
CRoaringProperty: The version of the CRoaring libary as a string. Example: "0.4.0"
Static
PackageProperty: The version of the roaring npm package as a string. Example: "1.2.0"
Symbol.iterator Gets a new iterator able to iterate all values in the set in ascending order.
WARNING: Is not allowed to change the bitmap while iterating. The iterator may throw exception if the bitmap is changed during the iteration.
A new iterator
RoaringBitmap32
Adds multiple values to the set.
Faster than calling add() multiple times.
It is faster to insert sorted or partially sorted values.
Is faster to use Uint32Array instead of arrays or iterables.
Is optimized if the argument is an instance of RoaringBitmap32 (it performs an OR union).
An iterable of values to insert.
This RoaringBitmap32 instance.
RoaringBitmap32
Adds all the values in the interval: [rangeStart, rangeEnd).
First element is included, last element is excluded. The number of added values is rangeEnd - rangeStart.
Areas outside the range are passed through unchanged.
The start index. Trimmed to 0.
Optional
rangeEnd: numberThe end index. Trimmed to 4294967296.
This RoaringBitmap32 instance.
RoaringBitmap32
Computes the size of the intersection between two bitmaps (the number of values in common).
Returns -1 if the given argument is not a ReadonlyRoaringBitmap32 instance.
The other set to compare for intersection.
The number of elements in common.
ReadonlyRoaringBitmap32
Performs the intersection (and) between the current bitmap and the provided bitmap, writing the result in the current bitmap.
Is faster to use Uint32Array instead of arrays or iterables.
This function is optimized if the argument is an instance of RoaringBitmap32.
The provided bitmap is not modified.
A RoaringBitmap32 instance or an iterable of unsigned 32 bit integers.
This RoaringBitmap32 instance.
RoaringBitmap32
Computes the size of the difference (andnot) between two bitmaps.
Returns -1 if the given argument is not a ReadonlyRoaringBitmap32 instance.
The other set to compare for intersection.
The number of elements in common.
ReadonlyRoaringBitmap32
Performs a AND NOT operation in place ("this = this AND NOT values"), same as removeMany.
Is faster to use Uint32Array instead of arrays or iterables.
This function is optimized if the argument is an instance of RoaringBitmap32.
A RoaringBitmap32 instance or an iterable of unsigned 32 bit integers.
This RoaringBitmap32 instance.
RoaringBitmap32
A readonly view on this bitmap. It returns always the same instance. Can return this if this bitmap is fully hard frozen. The bitmap will contain the same data, and if the first bitmap is modified the readonlyView bitmap one will be modified too. The readonlyView bitmap is readonly, so it is not possible to modify it.
The at() method takes an integer value and returns the item at that index, allowing for positive and negative integers. Negative integers count back from the last item in the set.
Zero-based index of the array element to be returned, converted to an integer. Negative index counts back from the end of the array — if index < 0, index + array.length is accessed.
The element in the set matching the given index. Always returns undefined if index < -array.length or index >= array.length without attempting to access the corresponding property.
RoaringBitmap32
Returns a new bitmap that is a copy of this bitmap, same as new RoaringBitmap32(copy)
A cloned RoaringBitmap32 instance
ReadonlyRoaringBitmap32
Returns a standard string representation of the content of this ReadonlyRoaringBitmap32 instance. It may return a very long string.
Default max length is 32000 characters, everything after maxLength is truncated (ellipsis added).
Optional
maxLength: numberApproximate maximum length of the string. Default is 32000. Ellipsis will be added if the string is longer.
A string in the format "[1,2,3...]"
ReadonlyRoaringBitmap32
Overwrite the content of this bitmap copying it from an Iterable or another RoaringBitmap32.
Is faster to pass a Uint32Array instance instead of an array or an iterable. Is even faster if a RoaringBitmap32 instance is used (it performs a simple copy).
The new values or a RoaringBitmap32 instance.
This RoaringBitmap32 instance.
RoaringBitmap32
Removes a value (or multiple values) from the set.
Returns true if the value (or at least one value) was removed during this call, false if not.
Rest
...values: (undefined | null | string | number)[]The unsigned 32 bit values to remove.
True if the value was removed during this call, false if not.
RoaringBitmap32
Deserializes the bitmap from an Uint8Array or a Buffer.
Setting the portable flag to false enable a custom format that can save space compared to the portable format (e.g., for very sparse bitmaps). The portable version is meant to be compatible with Java and Go versions.
An Uint8Array or a node Buffer that contains the serialized data.
The format of the serialized data. true means "portable". false means "croaring".
This ReadonlyRoaringBitmap32 instance.
ReadonlyRoaringBitmap32
Gets a new iterator able to iterate all value pairs [value, value] in the set in ascending order.
This is just for compatibility with the Set
WARNING: Is not allowed to change the bitmap while iterating. Undefined behaviour. The iterator may throw exception if the bitmap is changed during the iteration.
Same as Symbol.iterator
A new iterator
ReadonlyRoaringBitmap32
Behaves like array.every. The every() method tests whether all elements in the set pass the test implemented by the provided function. It returns a Boolean value.
WARNING: this can potentially iterate a large set of to 4 billion elements.
WARNING: Is not allowed to change the bitmap while iterating. Undefined behaviour.
Optional
thisArg: unknownIt behaves like array.filter. WARNING: The returned array may be very big, up to 4 billion elements. WARNING: Is not allowed to change the bitmap while iterating. Undefined behaviour.
Optional
thisArg: unknownAn object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
Optional
output: number[]A new array containing all elements of the array that satisfy the given predicate.
ReadonlyRoaringBitmap32
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter
Behaves like array.find. The find() method returns the value of the first element in the set that satisfies the provided testing function. Otherwise undefined is returned. WARNING: this can potentially iterate a large set of to 4 billion elements. WARNING: Is not allowed to change the bitmap while iterating. Undefined behaviour.
find calls predicate once for each element of the set, in ascending order, until it finds one where predicate returns true. If such an element is found, find immediately returns that element value. Otherwise, find returns undefined.
Optional
thisArg: unknownIf provided, it will be used as the this value for each invocation of predicate. If it is not provided, undefined is used instead.
The value of the first element in the set that satisfies the provided testing function. Otherwise undefined is returned.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find
ReadonlyRoaringBitmap32
Behaves like array.findIndex. The findIndex() method returns the index of the first element in the set that satisfies the provided testing function. Otherwise, it returns -1, indicating that no element passed the test. WARNING: this can potentially iterate a large set of to 4 billion elements. WARNING: Is not allowed to change the bitmap while iterating. Undefined behaviour.
find calls predicate once for each element of the set, in ascending order, until it finds one where predicate returns true. If such an element is found, findIndex immediately returns that element index. Otherwise, findIndex returns -1.
Optional
thisArg: unknownIf provided, it will be used as the this value for each invocation of predicate. If it is not provided, undefined is used instead.
The index of the first element in the set that satisfies the provided testing function. Otherwise, it returns -1, indicating that no element passed the test.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex
ReadonlyRoaringBitmap32
Negates (in place) the roaring bitmap within a specified interval: [rangeStart, rangeEnd).
First element is included, last element is excluded. The number of negated values is rangeEnd - rangeStart.
Areas outside the range are passed through unchanged.
The start index. Trimmed to 0.
Optional
rangeEnd: numberThe end index. Trimmed to 4294967296.
This RoaringBitmap32 instance.
RoaringBitmap32
Executes a function for each value in the set, in ascending order.
The callback has 3 arguments, the value, the value and this (this set). This is to match the Set
WARNING: Is not allowed to change the bitmap while iterating. Undefined behaviour.
WARNING: the second parameter of the callback is not the index, but the value itself, the same as the first argument.
This is required to match the Set
How many bytes are required to serialize this bitmap.
Setting the format flag to false enable a custom format that can save space compared to the portable format (e.g., for very sparse bitmaps). The portable version is meant to be compatible with Java and Go versions.
One of the SerializationFormat enum values, or a boolean value: if false, optimized C/C++ format is used. If true, Java and Go portable format is used.
How many bytes are required to serialize this bitmap.
ReadonlyRoaringBitmap32
Check whether a range of values from rangeStart (included) to rangeEnd (excluded) is present
The start index (inclusive).
Optional
rangeEnd: numberThe end index (exclusive).
True if the bitmap contains the whole range of values from rangeStart (included) to rangeEnd (excluded), false if not.
ReadonlyRoaringBitmap32
Returns the index of value in the set, index start from 0. If the set doesn't contain value, this function will return -1. The difference with rank function is that this function will return -1 when value isn't in the set, but the rank function will return a non-negative number.
A 32 bit unsigned integer to search.
Optional
fromIndex: numberThe index to start the search at, defaults to 0. It does not have performance difference, is just for compatibility with array.indexOf.
True if the set contains the given value, false if not.
ReadonlyRoaringBitmap32
Check whether the two bitmaps intersect.
Returns true if there is at least one item in common, false if not.
Returns false also if the given argument is not a ReadonlyRoaringBitmap32 instance.
The other set to compare for intersection.
True if the two set intersects, false if not.
ReadonlyRoaringBitmap32
Checks wether this set is equal to another set.
Returns false also if the given argument is not a ReadonlyRoaringBitmap32 instance.
The other set to compare for equality.
True if the two sets contains the same elements, false if not.
ReadonlyRoaringBitmap32
Checks wether this set is a strict subset of the given set.
Returns false if the sets are the same.
Returns false also if the given argument is not a ReadonlyRoaringBitmap32 instance.
The other ReadonlyRoaringBitmap32 instance.
True if this set is a strict subset of the given ReadonlyRoaringBitmap32. False if not.
ReadonlyRoaringBitmap32
Checks wether this set is a subset or the same as the given set.
Returns false also if the given argument is not a ReadonlyRoaringBitmap32 instance.
The other set.
True if this set is a subset of the given ReadonlyRoaringBitmap32. False if not.
ReadonlyRoaringBitmap32
Gets a new iterator able to iterate all values in the set in ascending order.
WARNING: Is not allowed to change the bitmap while iterating. The iterator may throw exception if the bitmap is changed during the iteration.
Same as Symbol.iterator
A new iterator
ReadonlyRoaringBitmap32
Computes the Jaccard index between two bitmaps. (Also known as the Tanimoto distance or the Jaccard similarity coefficient).
See https://en.wikipedia.org/wiki/Jaccard_index
The Jaccard index is undefined if both bitmaps are empty.
Returns -1 if the given argument is not a ReadonlyRoaringBitmap32 instance.
The other ReadonlyRoaringBitmap32 to compare.
The Jaccard index.
ReadonlyRoaringBitmap32
Returns a standard string representation of the content of this ReadonlyRoaringBitmap32 instance.
WARNING: this can potentially iterate a large set of to 4 billion elements.
Optional
separator: stringThe separator to use between elements. Default is ",".
A string in the format "1
ReadonlyRoaringBitmap32
Gets a new iterator able to iterate all values in the set in ascending order.
This is just for compatibility with the Set
WARNING: Is not allowed to change the bitmap while iterating. Undefined behaviour. The iterator may throw exception if the bitmap is changed during the iteration.
Same as Symbol.iterator
A new iterator
RoaringBitmap32
Returns the index of value in the set, index start from 0. If the set doesn't contain value, this function will return -1. The difference with rank function is that this function will return -1 when value isn't in the set, but the rank function will return a non-negative number. If fromIndex is not specified, is the same as this.indexOf(value). It behaves like array.lastIndexOf, but it doesn't have performance difference, is just for compatibility with array.lastIndexOf.
A 32 bit unsigned integer to search.
Optional
fromIndex: numberThe index to start the search at, defaults to 0. It does not have performance difference, is just for compatibility with array.indexOf.
True if the set contains the given value, false if not.
ReadonlyRoaringBitmap32
It behaves like array.map. WARNING: The returned array may be very big, up to 4 billion elements. WARNING: Is not allowed to change the bitmap while iterating. Undefined behaviour.
A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.
Optional
thisArg: ThisAn object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
Optional
output: U[]An array containing the results of calling the callbackfn function on each element in the set.
ReadonlyRoaringBitmap32
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map
Computes the size of the union between two bitmaps.
Returns -1 if the given argument is not a ReadonlyRoaringBitmap32 instance.
The other set to compare for intersection.
The number of elements in common.
ReadonlyRoaringBitmap32
Performs an union in place ("this = this OR values"), same as addMany.
Is faster to use Uint32Array instead of arrays or iterables.
This function is optimized if the argument is an instance of RoaringBitmap32.
A RoaringBitmap32 instance or an iterable of unsigned 32 bit integers.
This RoaringBitmap32 instance.
RoaringBitmap32
Gets the cardinality (number of elements) between rangeStart (included) to rangeEnd (excluded) of the bitmap. Returns 0 if range is invalid or if no element was found in the given range.
The start index (inclusive).
Optional
rangeEnd: numberThe end index (exclusive).
The number of elements between rangeStart (included) to rangeEnd (excluded).
toUint32Array array with pagination
Optional
limit: numberA new Uint32Array instance containing paginated items in the set in order.
ReadonlyRoaringBitmap32
toUint32Array array with pagination
A new Uint32Array instance containing paginated items in the set in order.
ReadonlyRoaringBitmap32
toUint32Array array with pagination
The output array.
The output array. Limited to the resulting size.
ReadonlyRoaringBitmap32
toUint32Array array with pagination
The output array.
The output array. Limited to the resulting size.
ReadonlyRoaringBitmap32
Same as toUint32Array
The output array.
The output array. Limited to the resulting size.
ReadonlyRoaringBitmap32
Behaves like array.reduce. The reduce() method applies a function against an accumulator and each value of the set (from left-to-right) to reduce it to a single value.
WARNING: this can potentially iterate a large set of to 4 billion elements.
WARNING: Is not allowed to change the bitmap while iterating. Undefined behaviour.
A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the set.
The value that results from the reduction.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce
ReadonlyRoaringBitmap32
Behaves like array.reduceRight. The reduceRight() method applies a function against an accumulator and each value of the set (from right-to-left) to reduce it to a single value. WARNING: this can potentially iterate a large set of to 4 billion elements. WARNING: Is not allowed to change the bitmap while iterating. Undefined behaviour.
A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the set.
The value that results from the reduction.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduceRight
ReadonlyRoaringBitmap32
Removes a value (or multiple values) from the set.
Returns true if the value (or at least one value) was removed during this call, false if not.
Rest
...values: (undefined | null | string | number)[]The unsigned 32 bit values to remove.
True if the value was removed during this call, false if not.
RoaringBitmap32
Removes multiple values from the set.
Faster than calling remove() multiple times.
Is faster to use Uint32Array instead of arrays or iterables.
This function is optimized if the argument is an instance of RoaringBitmap32 (it performs an AND NOT operation).
An iterable of values to remove.
This RoaringBitmap32 instance.
RoaringBitmap32
Removes all the values in the interval: [rangeStart, rangeEnd).
First element is included, last element is excluded. The number of renived values is rangeEnd - rangeStart.
Areas outside the range are passed through unchanged.
The start index. Trimmed to 0.
Optional
rangeEnd: numberThe end index. Trimmed to 4294967296.
This RoaringBitmap32 instance.
RoaringBitmap32
Gets a new iterator able to iterate all values in the set in descending order.
WARNING: Is not allowed to change the bitmap while iterating. The iterator may throw exception if the bitmap is changed during the iteration.
A new reverse iterator
ReadonlyRoaringBitmap32
Convert array and bitmap containers to run containers when it is more efficient; also convert from run containers when more space efficient.
Returns true if the bitmap has at least one run container.
Additional savings might be possible by calling shrinkToFit().
True if the bitmap has at least one run container.
RoaringBitmap32
If the size of the roaring bitmap is strictly greater than rank, then this function returns the element of given rank.
Otherwise, it returns undefined.
The rank, an unsigned 32 bit integer.
The element of the given rank or undefined if not found.
ReadonlyRoaringBitmap32
Serializes the bitmap into a new Buffer.
Setting the formatg to false enable a custom format that can save space compared to the portable format (e.g., for very sparse bitmaps). The portable version is meant to be compatible with Java and Go versions.
One of the SerializationFormat enum values, or a boolean value: if false, optimized C/C++ format is used. If true, Java and Go portable format is used.
Optional
_output: undefinedA new node Buffer that contains the serialized bitmap.
ReadonlyRoaringBitmap32
Serializes the bitmap into the given Buffer, starting to write at the given outputStartIndex position. The operation will fail with an error if the buffer is smaller than what getSerializationSizeInBytes(format) returns.
Setting the format to false enable a custom format that can save space compared to the portable format (e.g., for very sparse bitmaps). The portable version is meant to be compatible with Java and Go versions.
If false, optimized C/C++ format is used. If true, Java and Go portable format is used.
The node Buffer where to write the serialized data.
The output Buffer. If the input buffer was exactly of the same size. Otherwise, a new buffer backed by the same storage is returned, with the correct offset and length.
ReadonlyRoaringBitmap32
Serializes the bitmap into the given Buffer, starting to write at position 0. The operation will fail with an error if the buffer is smaller than what getSerializationSizeInBytes(format) returns.
Setting the portable flag to false enable a custom format that can save space compared to the portable format (e.g., for very sparse bitmaps). The portable version is meant to be compatible with Java and Go versions.
The node Buffer where to write the serialized data.
The output Buffer. If the input buffer was exactly of the same size. Otherwise, a new buffer backed by the same storage is returned, with the correct offset and length.
ReadonlyRoaringBitmap32
Serializes the bitmap into a new Buffer. The bitmap will be temporarily frozen until the operation completes.
Setting the portable flag to false enable a custom format that can save space compared to the portable format (e.g., for very sparse bitmaps). The portable version is meant to be compatible with Java and Go versions.
One of the SerializationFormat enum values, or a boolean value: if false, optimized C/C++ format is used. If true, Java and Go portable format is used.
Optional
_output: undefinedA new node Buffer that contains the serialized bitmap.
ReadonlyRoaringBitmap32
Serializes the bitmap into the given Buffer, starting to write at the given outputStartIndex position. The bitmap will be temporarily frozen until the operation completes. The operation will fail with an error if the buffer is smaller than what getSerializationSizeInBytes(format) returns.
Setting the portable flag to false enable a custom format that can save space compared to the portable format (e.g., for very sparse bitmaps). The portable version is meant to be compatible with Java and Go versions.
If false, optimized C/C++ format is used. If true, Java and Go portable format is used.
The node Buffer where to write the serialized data.
The output Buffer. If the input buffer was exactly of the same size, the same buffer is returned. Otherwise, a new buffer backed by the same storage is returned, with the correct offset and length.
ReadonlyRoaringBitmap32
Serializes the bitmap into the given Buffer, starting to write at position 0. The bitmap will be temporarily frozen until the operation completes. The operation will fail with an error if the buffer is smaller than what getSerializationSizeInBytes(format) returns.
Setting the portable flag to false enable a custom format that can save space compared to the portable format (e.g., for very sparse bitmaps). The portable version is meant to be compatible with Java and Go versions.
The node Buffer where to write the serialized data.
The output Buffer. If the input buffer was exactly of the same size, the same buffer is returned. Otherwise, a new buffer backed by the same storage is returned, with the correct offset and length.
ReadonlyRoaringBitmap32
Serializes the bitmap into a file, asynchronously. The bitmap will be temporarily frozen until the operation completes.
This is faster, everything runs in its own thread and it consumes less memory than serializing to a Buffer and then to write to a file, internally it uses memory mapped files and skip all the JS overhead.
One of the SerializationFormat enum values, or a boolean value: if false, optimized C/C++ format is used. If true, Java and Go portable format is used.
ReadonlyRoaringBitmap32
Behaves like array.some. The some() method tests whether at least one element in the set passes the test implemented by the provided function. It returns true if, in the set, it finds an element for which the provided function returns true; otherwise it returns false.
WARNING: this can potentially iterate a large set of to 4 billion elements.
WARNING: Is not allowed to change the bitmap while iterating. Undefined behaviour.
Optional
thisArg: unknownReturns an object that contains statistic information about this ReadonlyRoaringBitmap32 instance.
An object containing several statistics for the bitmap.
ReadonlyRoaringBitmap32
Creates a new plain JS array and fills it with all the values in the bitmap.
The returned array may be very big, use this function only when you know what you are doing.
Optional
maxLength: numberThe maximum number of elements to return.
A new plain JS array that contains all the items in the set in order.
ReadonlyRoaringBitmap32
Append all the values in this bitmap to the given plain JS array.
The resulting array may be very big, use this function only when you know what you are doing.
The output array.
Optional
maxLength: numberThe maximum number of elements to return.
Optional
offset: numberThe output array.
ReadonlyRoaringBitmap32
Creates a new plain JS Set
The returned set may be very big, use this function only when you know what you are doing.
Optional
maxLength: numberThe maximum number of elements to return.
A new plain JS array that contains all the items in the set in order.
ReadonlyRoaringBitmap32
Adds all the values in this bitmap to the given plain JS Set
The resulting set may be very big, use this function only when you know what you are doing.
The output set.
Optional
maxLength: numberThe maximum number of elements to return.
The output set.
ReadonlyRoaringBitmap32
It behaves like array.toSorted. Returns a new array that is this set sorted according to the compare function. If no sorting function is provided, the array is sorted according to the numeric order of the values (the same as calling this.toArray()).
WARNING: The returned array may be very big, up to 4 billion elements. WARNING: Is not allowed to change the bitmap while iterating. Undefined behaviour.
Optional
cmp: ((a, b) => number)A function that defines an alternative sort order. The sort method calls the compareFunction function once for each element in the array.
A new sorted array that contains all the elements of this set.
ReadonlyRoaringBitmap32
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toSorted
Creates a new Uint32Array and fills it with all the values in the bitmap.
The returned array may be very big, up to 4 billion elements.
Use this function only when you know what you are doing.
This function is faster than calling new Uint32Array(bitmap);
See rangeUint32Array to paginate.
A new Uint32Array instance containing all the items in the set in order.
ReadonlyRoaringBitmap32
Creates a new Uint32Array and fills it with all the values in the bitmap up to the given length.
See rangeUint32Array to paginate.
A new Uint32Array instance containing all the items in the set in order.
ReadonlyRoaringBitmap32
Copies all the values in the roaring bitmap to an Uint32Array.
This function is faster than calling new Uint32Array(bitmap); Throws if the given array is not a valid Uint32Array or Int32Array or is not big enough.
See rangeUint32Array to paginate.
The output array.
The output array. Limited to the resulting size.
ReadonlyRoaringBitmap32
Creates a new Uint32Array and fills it with all the values in the bitmap, asynchronously. The bitmap will be temporarily frozen until the operation completes.
The returned array may be very big, up to 4 billion elements.
Use this function only when you know what you are doing.
This function is faster than calling new Uint32Array(bitmap);
See rangeUint32Array to paginate.
A new Uint32Array instance containing all the items in the set in order.
ReadonlyRoaringBitmap32
Copies all the values in the roaring bitmap to an Uint32Array, asynchronously. The bitmap will be temporarily frozen until the operation completes.
This function is faster than calling new Uint32Array(bitmap); Throws if the given array is not a valid Uint32Array or Int32Array or is not big enough.
See rangeUint32Array to paginate.
The output array.
The output array. Limited to the resulting size.
ReadonlyRoaringBitmap32
Tries to add the given value (or values) to the set.
Returns true if the value (or at least one value) was added during this call, false if already existing or not a valid value.
Rest
...values: (undefined | null | string | number)[]The values to add.
True if operation was succesfull (values were added), false if not (values did not exists or are invalid values).
RoaringBitmap32
Gets a new iterator able to iterate all values in the set in ascending order.
This is just for compatibility with the Set
WARNING: Is not allowed to change the bitmap while iterating. Undefined behaviour. The iterator may throw exception if the bitmap is changed during the iteration.
Same as Symbol.iterator
A new iterator
RoaringBitmap32
Computes the size of the symmetric difference (xor) between two bitmaps.
Returns -1 if the given argument is not a ReadonlyRoaringBitmap32 instance.
The other set to compare for intersection.
The number of elements in common.
ReadonlyRoaringBitmap32
Performs the symmetric union (xor) between the current bitmap and the provided bitmap, writing the result in the current bitmap.
Is faster to use Uint32Array instead of arrays or iterables.
This function is optimized if the argument is an instance of RoaringBitmap32.
The provided bitmap is not modified.
A RoaringBitmap32 instance or an iterable of unsigned 32 bit integers.
This RoaringBitmap32 instance.
RoaringBitmap32
Static
addaddOffset adds the value 'offset' to each and every value in a bitmap, generating a new bitmap in the process. If offset + element is outside of the range [0,2^32), that the element will be dropped.
The input bitmap.
The offset to add to each element. Can be positive or negative.
A new bitmap with the offset added to each element.
Static
andReturns a new RoaringBitmap32 with the intersection (and) between the given two bitmaps.
The provided bitmaps are not modified.
The first RoaringBitmap32 instance to and.
The second RoaringBitmap32 instance to and.
A new RoaringBitmap32 that contains the intersection a AND b
RoaringBitmap32
Static
andReturns a new RoaringBitmap32 with the difference (and not) between the two given bitmaps.
The provided bitmaps are not modified.
The first RoaringBitmap32 instance.
The second RoaringBitmap32 instance.
RoaringBitmap32 A new bitmap, a AND NOT b
Static
bufferCreates a new buffer with the given size and alignment. If alignment is not specified, the default alignment of 32 is used. The buffer does not come from the nodejs buffer pool, it is allocated using aligned_malloc.
Is the same as Buffer.alloc but is aligned. We need an aligned buffer to create a roaring bitmap frozen view.
The size of the buffer to allocate.
Optional
alignment: numberThe alignment of the buffer to allocate.
RoaringBitmap32
Static
bufferCreates a new buffer backed by a SharedArrayBuffer with the given size and alignment. If alignment is not specified, the default alignment of 32 is used. The buffer does not come from the nodejs buffer pool, it is allocated using aligned_malloc.
Is the same as Buffer.alloc but is aligned and uses a SharedArrayBuffer as storage. We need an aligned buffer to create a roaring bitmap frozen view.
The size of the buffer to allocate.
Optional
alignment: numberThe alignment of the buffer to allocate.
Static
bufferCreates a new buffer backed by a SharedArrayBuffer with the given size and alignment. If alignment is not specified, the default alignment of 32 is used. The buffer does not come from the nodejs buffer pool, it is allocated using aligned_malloc.
Is the same as Buffer.allocUnsafe but is aligned and uses a SharedArrayBuffer as storage. We need an aligned buffer to create a roaring bitmap frozen view.
WARNING: this function is unsafe because the returned buffer may contain previously unallocated memory that may contain sensitive data.
The size of the buffer to allocate.
Optional
alignment: numberThe alignment of the buffer to allocate.
Static
bufferCreates a new buffer not initialized with the given size and alignment. If alignment is not specified, the default alignment of 32 is used. The buffer does not come from the nodejs buffer pool, it is allocated using aligned_malloc.
Is the same as Buffer.allocUnsafe but is aligned. We need an aligned buffer to create a roaring bitmap frozen view.
WARNING: this function is unsafe because the returned buffer may contain previously unallocated memory that may contain sensitive data.
The size of the buffer to allocate.
Optional
alignment: numberThe alignment of the buffer to allocate.
RoaringBitmap32
Static
deserializeDeserializes the bitmap from an Uint8Array or a Buffer.
Returns a new RoaringBitmap32 instance.
Setting the portable flag to false enable a custom format that can save space compared to the portable format (e.g., for very sparse bitmaps). The portable version is meant to be compatible with Java and Go versions. When a frozen format is used, the buffer will be copied and the bitmap will be frozen.
NOTE: this field was optional before, now is required and an Error is thrown if the portable flag is not passed.
An Uint8Array or a node Buffer that contains the serialized data.
The format of the serialized data. true means "portable". false means "croaring".
A new RoaringBitmap32 instance.
RoaringBitmap32
Static
deserializeDeserializes the bitmap from an Uint8Array or a Buffer asynchrnously in a parallel thread.
Returns a Promise that resolves to a new RoaringBitmap32 instance.
The portable version is meant to be compatible with Java and Go versions. The croaring version is compatible with the C version, it can be smaller than the portable version. When a frozen format is used, the buffer will be copied and the bitmap will be frozen.
An Uint8Array or a node Buffer that contains the serialized data.
The format of the serialized data. true means "portable". false means "croaring".
A promise that resolves to a new RoaringBitmap32 instance.
RoaringBitmap32
Deserializes the bitmap from an Uint8Array or a Buffer asynchrnously in a parallel thread.
When deserialization is completed or failed, the given callback will be executed.
The portable version is meant to be compatible with Java and Go versions. The croaring version is compatible with the C version, it can be smaller than the portable version. When a frozen format is used, the buffer will be copied and the bitmap will be frozen.
An Uint8Array or a node Buffer that contains the.
The format of the serialized data. true means "portable". false means "croaring".
The callback to execute when the operation completes.
RoaringBitmap32
Static
deserializeDeserializes the bitmap from a file asynchronously. Returns a new RoaringBitmap32 instance.
The portable version is meant to be compatible with Java and Go versions. The croaring version is compatible with the C version, it can be smaller than the portable version. When a frozen format is used, the buffer will be copied and the bitmap will be frozen.
This is faster, everything runs in its own thread and it consumes less memory than serializing to a Buffer and then to write to a file, internally it uses memory mapped files and skip all the JS overhead.
The path of the file to read.
The format of the serialized data. true means "portable". false means "croaring".
A promise that resolves to a new RoaringBitmap32 instance.
RoaringBitmap32
Static
deserializeDeserializes many bitmaps from an array of Uint8Array or an array of Buffer asynchronously in multiple parallel threads.
Returns a Promise that resolves to an array of new RoaringBitmap32 instance.
Setting the portable flag to false enable a custom format that can save space compared to the portable format (e.g., for very sparse bitmaps). The portable version is meant to be compatible with Java and Go versions. When a frozen format is used, the buffer will be copied and the bitmap will be frozen.
NOTE: portable argument was optional before, now is required and an Error is thrown if the portable flag is not passed.
An Uint8Array or a node Buffer that contains the serialized data.
The format of the serialized data. true means "portable". false means "croaring".
A promise that resolves to a new RoaringBitmap32 instance.
RoaringBitmap32
Deserializes many bitmaps from an array of Uint8Array or an array of Buffer asynchronously in a parallel thread.
Deserialization in the parallel thread will be executed in sequence, if one fails, all fails.
Setting the portable flag to false enable a custom format that can save space compared to the portable format (e.g., for very sparse bitmaps). The portable version is meant to be compatible with Java and Go versions. When a frozen format is used, the buffer will be copied and the bitmap will be frozen.
NOTE: portable argument was optional before, now is required and an Error is thrown if the portable flag is not passed.
When deserialization is completed or failed, the given callback will be executed.
An array of Uint8Array or node Buffers that contains the non portable serialized data.
The format of the serialized data. true means "portable". false means "croaring".
The callback to execute when the operation completes.
RoaringBitmap32
Static
ensureEnsures that the given buffer is aligned to the given alignment. If alignment is not specified, the default alignment of 32 is used. If the buffer is already aligned, it is returned. If the buffer is not aligned, a new aligned buffer is created with bufferAlignedAllocUnsafe and the data is copied.
The buffer to align.
Optional
alignment: numberThe alignment to align to.
The aligned buffer. Can be the same as the input buffer if it was already aligned. Can be a new buffer if the input buffer was not aligned.
RoaringBitmap32
Static
fromCreates an instance of RoaringBitmap32 from the given Iterable.
Is faster to pass a Uint32Array instance instead of an array or an iterable.
Is optimized if the given argument is a RoaringBitmap32 (performs a fast copy).
The values to set.
A new RoaringBitmap32 instance filled with the given values.
RoaringBitmap32
Static
fromCreates an instance of RoaringBitmap32 from the given Iterable asynchronously in a parallel thread.
If a plain array or a plain iterable is passed, a temporary Uint32Array will be created synchronously.
NOTE: This method will throw a TypeError if a RoaringBitmap32 is passed as argument.
Returns a Promise that resolves to a new RoaringBitmap32 instance.
The values to set. Cannot be a RoaringBitmap32.
A promise that resolves to a new RoaringBitmap32 instance filled with all the given values.
RoaringBitmap32
Creates an instance of RoaringBitmap32 from the given Iterable asynchronously in a parallel thread.
If a plain array or a plain iterable is passed, a temporary Uint32Array will be created synchronously.
NOTE: This method will throw a TypeError if a RoaringBitmap32 is passed as argument.
When deserialization is completed or failed, the given callback will be executed.
The values to set. Cannot be a RoaringBitmap32.
The callback to execute when the operation completes.
RoaringBitmap32
Static
fromCreates a new bitmap that contains all the values in the interval: [rangeStart, rangeEnd). Is possible to specify the step parameter to have a non contiguous range.
The start index. Trimmed to 0.
Optional
rangeEnd: numberThe end index. Trimmed to 4294967297.
Optional
step: numberThe increment step, defaults to 1.
A new RoaringBitmap32 instance.
RoaringBitmap32
Static
getStatic
getStatic
isChecks if the given buffer is memory aligned. If alignment is not specified, the default alignment of 32 is used.
The buffer to check.
Optional
alignment: numberThe alignment to check.
Static
ofThe RoaringBitmap32.of() static method creates a new Array instance from a variable number of arguments, regardless of number or type of the arguments. Note that is faster to pass a Uint32Array instance instead of an array or an iterable.
Rest
...values: (undefined | null | string | number)[]A set of values to add to the new RoaringBitmap32 instance.
A new RoaringBitmap32 instance.
Static
orReturns a new RoaringBitmap32 with the union (or) of the two given bitmaps.
The provided bitmaps are not modified.
The first RoaringBitmap32 instance to or.
The second RoaringBitmap32 instance to or.
RoaringBitmap32 A new RoaringBitmap32 that contains the union a OR b
Static
orPerforms a union between all the given array of RoaringBitmap32 instances.
This function is faster than calling or multiple times.
An array of RoaringBitmap32 instances to or together.
A new RoaringBitmap32 that contains the union of all the given bitmaps.
RoaringBitmap32
Performs a union between all the given RoaringBitmap32 instances.
This function is faster than calling or multiple times.
Rest
...bitmaps: readonly ReadonlyRoaringBitmap32[]The RoaringBitmap32 instances to or together.
A new RoaringBitmap32 that contains the union of all the given bitmaps.
RoaringBitmap32
Static
swapSwaps the content of two RoaringBitmap32 instances.
First RoaringBitmap32 instance to swap
Second RoaringBitmap32 instance to swap
RoaringBitmap32
Static
unsafeThis is an unsafe method that builds a frozen roaring bitmap over a buffer. This removes the overhead of a deserialization of a large bitmap. The buffer will be kept alive by the bitmap. This function is endian sensitive, it supports only little endian and cannot load frozen bitmaps saved on big endian machines.
This function is considered unsafe because if the buffer gets modified, the bitmap will be corrupted and the application can crash. There is a risk for buffer overrun or arbitrary code execution here. Be careful and do not allow the buffer to be modified while or after the bitmap is in use.
The content of buffer should not be modified until the bitmap is destroyed! Is responsibility of the caller to ensure that the buffer is not modified while the bitmap is in use.
Using "unsafe_frozen_croaring" the buffer data must be aligned to 32 bytes. The roaring library provides the functions bufferAlignedAlloc, bufferAlignedAllocUnsafe, isBufferAligned, ensureBufferAligned that helps allocating and managing aligned buffers. If you read a file, or read from database, be careful to use an aligned buffer or copy to an aligned buffer before calling this function with "unsafe_frozen_croaring" format.
Is considered unsafe and unstable because the format might change at any new version. Can be useful for temporary storage or for sending data over the network between similar machines. If the content is corrupted when loaded or the buffer is modified when a frozen view is create, the behavior is undefined! The application may crash, buffer overrun, could be a vector of attack!
A Buffer that contains the serialized data.
The format of the serialized data. true means "portable". false means "croaring".
A new RoaringBitmap32 instance.
RoaringBitmap32
Static
xorReturns a new RoaringBitmap32 with the symmetric union (xor) between the two given bitmaps.
The provided bitmaps are not modified.
The first RoaringBitmap32 instance to xor.
The second RoaringBitmap32 instance to xor.
RoaringBitmap32 A new RoaringBitmap32 that contains a XOR b
Static
xorPerforms a xor between all the given array of RoaringBitmap32 instances.
This function is faster than calling xor multiple times.
An array of RoaringBitmap32 instances to or together.
A new RoaringBitmap32 that contains the xor of all the given bitmaps.
RoaringBitmap32
Performs a xor between all the given RoaringBitmap32 instances.
This function is faster than calling xor multiple times.
Rest
...bitmaps: readonly ReadonlyRoaringBitmap32[]The RoaringBitmap32 instances to or together.
A new RoaringBitmap32 that contains the xor of all the given bitmaps.
RoaringBitmap32
Generated using TypeDoc
Roaring bitmap that supports 32 bit unsigned integers.
Export
RoaringBitmap32
Implements
Author
Salvatore Previti