Class RoaringUint8Array

Array of bytes allocted directly in roaring library WASM memory. Note: to release memory as soon as possible, you are responsible to free the allocated memory calling "dispose" method.

Hierarchy

  • RoaringUint8Array

Implements

Constructors

  • Allocates an array in the roaring WASM heap.

    Note: Memory is not garbage collected, you are responsible to free the allocated memory calling "dispose" method.

    If the parameter is a number, it creates a new uninitialized array of the given length. If the parameter is an Iterable, it creates a copy of the given iterable.

    Parameters

    • Optional lengthOrArray: null | number | ArrayLike<number> | Iterable<number>

      Length of the array to allocate or the array to copy

    • Optional arenaAllocator: null | RoaringArenaAllocator

    Returns RoaringUint8Array

Properties

#private: any

Accessors

  • get _p(): number
  • Internal

    Internal property, do not use.

    Returns number

  • get byteLength(): number
  • The length in bytes of the array. For RoaringUint8Array it is equal to this.length

    Returns number

  • get isDisposed(): boolean
  • Returns true if this object was deallocated.

    Returns boolean

Methods

  • Gets a new JS typed array instance that shares the memory used by this buffer. Note that the buffer may point to an outdated WASM memory if the WASM allocated memory grows while using the returned buffer. Use the returned array for short periods of time.

    Returns Uint8Array

    A new typed array that shares the memory with this array.

  • 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 array. Follows the specification for array.at(). If the computed index is less than 0, or equal to length, undefined is returned.

    Parameters

    • index: number

      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.

    Returns undefined | number

    The element in the array matching the given index. Always returns undefined if index < -array.length or index >= array.length without attempting to access the corresponding property.

  • Frees the allocated memory. Is safe to call this method more than once.

    Returns boolean

    True if memory gets freed during this call, false if not.

  • Writes the given array at the specified position

    Parameters

    • array: ArrayLike<number> | Iterable<number>

      A typed or untyped array of values to set.

    • Optional offset: number

      The index in the current array at which the values are to be written.

    Returns RoaringUint8Array

  • Sets the value at the given index.

    Parameters

    • index: number

      Zero-based index of the array element to be set, converted to an integer. Negative index counts back from the end of the array — if index < 0, index + array.length is accessed.

    • value: number

      The value to set at the given index.

    Returns boolean

    True if the value was set, false if the index is out of bounds.

  • Decreases the size of the allocated memory. It does nothing if the new length is greater or equal to the current length. If the new length is less than 1, it disposes the allocated memory. NOTE: if the value is non zero, this does not reallocate the consumed memory, it just chances the reported size in byteLength and length properties.

    Parameters

    • newLength: number

      The new length in bytes.

    Returns boolean

    True if the memory was shrunk, false if not.

  • Throws an error if the memory was freed.

    Returns void

  • Returns a string representation of an array.

    Returns string

  • Copies the content of this buffer to a typed array and returns it

    Parameters

    • Optional output: Uint8Array

      The typed array to copy to. If not provided, a new typed array is created.

    Returns Uint8Array

    A typed array with the content of this buffer. It could be smaller than the buffer if the output array is smaller.

Generated using TypeDoc