new BitSet(value)
Implements an array of bits that grows by itself. Each bit is a boolean, and its index is non-negative integer. Basically it's Javascript implementation of Java's BitSet.
Parameters:
Name | Type | Argument | Description |
---|---|---|---|
value |
<optional> |
Initial value for the BitSet. |
Methods
-
<private> _reallocate(bitSize)
-
Reallocates BitSet to expand to the requested bit size.
Parameters:
Name Type Description bitSize
Number the requested bit size.
-
and(set)
-
Performs AND logical operation on two BitSet. That means it will be set to 1 if both are 1, 0 otherwise. The result will be applied to this BitSet.
Parameters:
Name Type Description set
BitSet The other BitSet.
-
clear(pos)
-
Sets specified bit to false.
Parameters:
Name Type Description pos
Number The bit position to set to false.
- Source:
- See:
-
clearAll()
-
Sets all bits to false.
- Source:
- See:
-
clearRange(from, to)
-
Sets specified range of bits to false.
Parameters:
Name Type Description from
Number The start bit position.
to
Number The end bit position.
- Source:
- See:
-
contains(set) → {Boolean}
-
Checks if this BitSet contains all the bits from the other BitSet. This function will return true if , false otherwise.
Parameters:
Name Type Description set
The other BitSet.
Returns:
Whether if two BitSet intersects.
- Type
- Boolean
-
equals(set) → {Boolean}
-
Checks if two BitSet is same. This function will return true if they are same, false otherwise.
Parameters:
Name Type Description set
The other BitSet.
Returns:
Whether if two BitSet equals.
- Type
- Boolean
-
get(pos) → {Boolean}
-
Returns the value of specified bit.
Parameters:
Name Type Description pos
Number The bit position.
Returns:
Whether if the bit is set or not.
- Type
- Boolean
-
intersects(set) → {Boolean}
-
Checks if two BitSet has a same bit to set to 1. This function will return true if they have matching part, false otherwise.
Parameters:
Name Type Description set
The other BitSet.
Returns:
Whether if two BitSet intersects.
- Type
- Boolean
-
isEmpty() → {Boolean}
-
Checkes whether the BitSet is filled with 0. This function will return false if the BitSet has any bit that is set to 1.
Returns:
Whether if the BitSet is empty.
- Type
- Boolean
-
not()
-
Performs NOT logical operation on the BitSet. That means it will be set to 1 if bit is 0, 0 otherwise. The result will be applied to this BitSet.
-
or(set)
-
Performs OR logical operation on two BitSet. That means it will be set to 1 if one of them is 1, 0 if both are 0. The result will be applied to this BitSet.
Parameters:
Name Type Description set
BitSet The other BitSet.
-
set(pos, set)
-
Sets specified bit.
Parameters:
Name Type Description pos
Number The bit position to set.
set
Boolean The value to set.
-
setAll(set)
-
Sets all bits.
Parameters:
Name Type Description set
Boolean The value to set.
-
setRange(from, to, set)
-
Sets specified range of bits.
Parameters:
Name Type Description from
Number The start bit position.
to
Number The end bit position.
set
Boolean The value to set.
-
size() → {Number}
-
Returns BitSet's allocated size in bits.
Returns:
allocated size in bits.
- Type
- Number
-
toString(redix) → {String}
-
Changes the BitSet to String form.
Parameters:
Name Type Argument Default Description redix
Number <optional>
2 The redix to use.
Returns:
The stringified BitSet.
- Type
- String
-
xor(set)
-
Performs XOR logical operation on two BitSet. That means it will be set to 1 if the bits are different, 0 if they're same. The result will be applied to this BitSet.
Parameters:
Name Type Description set
BitSet The other BitSet.