Property. True if the bitmap is empty.
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.
Property. Gets the number of items in the set (cardinality).
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
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.
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.
Returns a new bitmap that is a copy of this bitmap, same as new RoaringBitmap32(copy)
A cloned RoaringBitmap32 instance
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...]"
Warning: this method is just for compatibility with Set and returns a Set, so it can be very slow for big bitmaps. Yoo should use this.andNot(bitmap).
a new Set containing all the elements in this Set which are not also in the argument.
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
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.
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.
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.
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.
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.
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.
Warning: this method is just for compatibility with Set and returns a Set, so it can be very slow for big bitmaps. Yoo should use this.and(bitmap).
a new Set containing all the elements which are both in this Set and in the argument.
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.
a boolean indicating whether this Set has no elements in common with the argument.
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.
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.
Checks wether this set is a strict superset 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 superset of the given ReadonlyRoaringBitmap32. False if not.
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.
a boolean indicating whether all the elements in this Set are also in the argument.
Checks wether this set is a superset 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 superset of the given ReadonlyRoaringBitmap32. False if not.
a boolean indicating whether all the elements in the argument are also in this Set.
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
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.
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
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
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.
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.
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.
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.
toUint32Array array with pagination
A new Uint32Array instance containing paginated items in the set in order.
toUint32Array array with pagination
The output array.
The output array. Limited to the resulting size.
toUint32Array array with pagination
The output array.
The output array. Limited to the resulting size.
Same as toUint32Array
The output array.
The output array. Limited to the resulting size.
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.
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.
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
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.
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.
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.
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.
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.
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.
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.
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.
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.
Warning: this method is just for compatibility with Set and returns a Set, so it can be very slow for big bitmaps. Yoo should use this.xor(bitmap) instead.
a new Set containing all the elements which are in either this Set or in the argument, but not in both.
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.
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.
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.
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.
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: number, b: number) => 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.
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.
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.
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.
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.
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.
Warning: this method is just for compatibility with Set and returns a Set, so it can be very slow for big bitmaps. Yoo should use this.or(bitmap).
a new Set containing all the elements in this Set and also all the elements in the argument.
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
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.
Returns always "ReadonlyRoaringBitmap32".
To have a standard string representation of the content as a string, call contentToString() instead.