API / geotoolkit / util / FixedBitArray / 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).
Constructors
Constructors
• new FixedBitArray(size)
Constructor for FixedBitArray.
| Name | Type | Description |
|---|---|---|
size | number | number of bits/booleans in array. |
Methods
▸ fill(value): FixedBitArray
Fill the bit array with a single value
| Name | Type |
|---|---|
value | boolean |
▸ getBit(position): boolean
Get bit from bit array
| Name | Type | Description |
|---|---|---|
position | number | position of bit |
boolean
boolean true if 1, false if 0 or out of bounds
▸ setBit(position, value?): FixedBitArray
Set bit to bit array Note: do nothing, if position is out of bounds
| Name | Type | Description |
|---|---|---|
position | number | position of bit |
Optional value | boolean | bit value, default is true. |