Last updated

API / geotoolkit / util / FixedBitArray / FixedBitArray

Class: FixedBitArray

util.FixedBitArray.FixedBitArray

Memory optimized boolean array.
Internally uses an Uint8Array and encode boolean values on each bit.
This lead to a memory size reduction of 32x to 64x over Javascript's native booleans stored in regular Array.
(Regular array optimizations are browser-dependant, but this solution will have a guaranteed fixed size).

Table of contents

Constructors
Methods

Contents

Constructors

new FixedBitArray(size)

new FixedBitArray(size)

Constructor for FixedBitArray.

Parameters

Name Type Description
sizenumbernumber of bits/booleans in array.
Methods

fill

fill(value): FixedBitArray

Fill the bit array with a single value

Parameters

Name Type
valueboolean

Returns

FixedBitArray


getBit

getBit(position): boolean

Get bit from bit array

Parameters

Name Type Description
positionnumberposition of bit

Returns

boolean

boolean true if 1, false if 0 or out of bounds


setBit

setBit(position, value?): FixedBitArray

Set bit to bit array Note: do nothing, if position is out of bounds

Parameters

Name Type Description
positionnumberposition of bit
Optional valuebooleanbit value, default is true.

Returns

FixedBitArray