Set value for a bit on position
const gibbon = Gibbon.create(2);
gibbon.changePosition(1, true);
gibbon.isPosition(1); // returns true
unsigned integer value
Optional
on: boolean = falseOptional set true or false (default : false)
This method analyzes every bit value in this gibbon and creates the corresponding
position array where bits are logical true.
// Initialize a Gibbon (2 bytes)
const gibbon = Gibbon.create(2);
// Pre set some bit positions
gibbon.setPosition(1)
.setPosition(2)
.setPosition(3)
.setPosition(4)
.setPosition(5)
.setPosition(6)
.setPosition(7)
.setPosition(8)
.setPosition(10);
gibbon.getPositionsArray(); // returns: [1, 2, 3, 4, 5, 6, 7, 8, 10]
Which contains bit positions from this gibbon, which are logical set to true
Compares all given positions
When one wants to check on bit positions outside the memory bounds (dataViewBounds),
method wil return early with false
.
// Initialize a gibbon with 2 bytes
const gibbon = Gibbon.create(2);
// Set 2 bit positions to logical '1'
gibbon.setPosition(1).setPosition(2);
gibbon.hasAllFromPositions([1, 2]); // true
// Set 2 bit positions to logical '1' then the first bit position back to '0'
const gibbon = Gibbon.create(2);
gibbon.setPosition(1).setPosition(2).togglePosition(1);
gibbon.hasAllFromPositions([-1, 2]); // true
true when all positions correspondent to the given indexes
if positionArray is not an instance of array
containing signed integer values (representing bit positions)
Compares the given positions
When any of the positions conforms to logical '1' (true), we return true
early.
When one wants to check on bit positions outside the memory bounds (dataViewBounds),
method wil return early with false
.
// Initialize a gibbon with 2 bytes
const gibbon = Gibbon.create(2);
// Set 3 bit positions to logical '1'
gibbon.setPosition(1).setPosition(2).setPosition(10);
gibbon.hasAnyFromPositions([1, 9]); // true
// Set 2 bit positions to logical '1' then the first bit position back to '0'
const gibbon = Gibbon.create(2);
gibbon.setPosition(1).setPosition(2),togglePosition(1);
gibbon.hasAllFromPositions([-1, 100]); // true
true when one of these positions correspond
if positionArray is not an instance of array
containing signed integer values (representing bit positions)
Able to manipulate bits according to an array of signed integers
// Set 2 bit positions to logical '1'
const gibbon = Gibbon.create(2);
gibbon.setAllFromPositions([1, 2]);
gibbon.hasAllFromPositions([1, 2]); // returns true
// Set 1 bit positions to logical '1' and the second to '0'
const gibbon = Gibbon.create(2);
gibbon.setAllFromPositions([1, -2]);
gibbon.hasAllFromPositions([1]); // returns true
When out of bounds
Array with integer values starting from 1.
Able to manipulate bits according to an array of signed integers (opposite of setAllFromPositions)
// Set 2 bit positions to logical '0'
const gibbon = Gibbon.create(2);
gibbon.unsetAllFromPositions([1, 2]);
gibbon.hasAllFromPositions([1, 2]); // returns false
gibbon.hasAllFromPositions([-1, -2]); // returns true
// Set 1 bit positions to logical '0' and the second to '1'
const gibbon = Gibbon.create(2);
gibbon.setAllFromPositions([1, -2]);
gibbon.hasAllFromPositions([2]); // returns true
if positionArray is not an instance of array
Array with integer values starting from 1.
Static
createStatic
decodeStatic
fromStatic
fromGenerated using TypeDoc
A Gibbon
Param
allocate this Gibbon with some working memory