Skip to content

API / geotoolkit / util / FixedBitArray / FixedBitArray

Class: FixedBitArray

util.FixedBitArray.FixedBitArray

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

Table of contents

Constructors
  • [new FixedBitArray(size)](/solutions/geotoolkit/GeoToolkit_JS/apis/classes/geotoolkit.util.fixedbitarray.fixedbitarray.md#new fixedbitarray(size))
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