decaf::util::BitSet Class Reference
This class implements a vector of bits that grows as needed.
More...
#include <src/main/decaf/util/BitSet.h>
Public Member Functions |
| | BitSet () |
| | Creates a new BitSet whose bits are all false.
|
| | BitSet (int bitCount) |
| | Creates a bit set whose initial size is large enough to explicitly represent bits with indices in the range 0 through bitCount-1.
|
| | BitSet (const BitSet &set) |
| | Copy Constructor.
|
| BitSet & | operator= (const BitSet &set) |
| | Assignment.
|
| virtual | ~BitSet () |
| bool | operator== (const BitSet &other) const |
| | Boolean comparison operator ==.
|
| bool | operator!= (const BitSet &other) const |
| | Boolean comparison operator !=.
|
| void | AND (const BitSet &set) |
| | Performs a logical AND of this target bit set with the argument bit set.
|
| void | OR (const BitSet &set) |
| | Performs a logical OR of this bit set with the bit set argument.
|
| void | andNot (const BitSet &set) |
| | Clears all of the bits in this BitSet whose corresponding bit is set in the specified BitSet.
|
| int | cardinality () |
| | Returns the number of bits set to true in this BitSet.
|
| void | clear () |
| | Sets all of the bits in this BitSet to false.
|
| void | clear (int index) |
| | Sets the bit specified by the index to false.
|
| void | clear (int fromIndex, int toIndex) |
| | Sets the bits from the specified fromIndex (inclusive) to the specified toIndex (exclusive) to false.
|
| bool | equals (const BitSet &set) const |
| | Compares this object against the specified object.
|
| void | flip (int index) |
| | Sets the bit at the specified index to the complement of its current value.
|
| void | flip (int fromIndex, int toIndex) |
| | Sets each bit from the specified fromIndex (inclusive) to the specified toIndex (exclusive) to the complement of its current value.
|
| bool | get (int index) const |
| | Returns the value of the bit with the specified index.
|
| BitSet | get (int fromIndex, int toIndex) const |
| | Returns a new BitSet composed of bits from this BitSet from fromIndex (inclusive) to toIndex (exclusive).
|
| bool | intersects (const BitSet &set) const |
| | Returns true if the specified BitSet has any bits set to true that are also set to true in this BitSet.
|
| bool | isEmpty () const |
| | Returns true if this BitSet contains no bits that are set to true.
|
| int | length () const |
| | Returns the "logical size" of this BitSet: the index of the highest set bit in the BitSet plus one.
|
| int | nextClearBit (int index) const |
| | Returns the index of the first bit that is set to false that occurs on or after the specified starting index.
|
| int | nextSetBit (int index) const |
| | Returns the index of the first bit that is set to true that occurs on or after the specified starting index.
|
| void | set (int index) |
| | Sets the bit at the specified index to true.
|
| void | set (int index, bool value) |
| | Sets the bit at the specified index to the specified value.
|
| void | set (int fromIndex, int toIndex) |
| | Sets the bits from the specified fromIndex (inclusive) to the specified toIndex (exclusive) to true.
|
| void | set (int fromIndex, int toIndex, bool value) |
| | Sets the bits from the specified fromIndex (inclusive) to the specified toIndex (exclusive) to the value given.
|
| int | size () const |
| | Returns the number of bits of space actually in use by this BitSet to represent bit values.
|
| std::string | toString () const |
| | Returns a string representation of this bit set.
|
| void | XOR (const BitSet &set) |
| | Performs a logical XOR of this bit set with the bit set argument.
|
Detailed Description
This class implements a vector of bits that grows as needed.
Each component of the bit set has a boolean value. The bits of a BitSet are indexed by nonnegative integers. Individual indexed bits can be examined, set, or cleared. One BitSet may be used to modify the contents of another BitSet through logical AND, logical inclusive OR, and logical exclusive OR operations.
By default, all bits in the set initially have the value false.
Every bit set has a current size, which is the number of bits of space currently in use by the bit set. Note that the size is related to the implementation of a bit set, so it may change with implementation. The length of a bit set relates to logical length of a bit set and is defined independently of implementation.
A BitSet is not safe for multi-threaded use without external synchronization.
- Since:
- 1.0
Constructor & Destructor Documentation
| decaf::util::BitSet::BitSet |
( |
|
) |
|
Creates a new BitSet whose bits are all false.
| decaf::util::BitSet::BitSet |
( |
int |
bitCount |
) |
|
Creates a bit set whose initial size is large enough to explicitly represent bits with indices in the range 0 through bitCount-1.
All bits are initially false. If the bitCount is not a multiple of 64 then the count is rounded to the next closest multiple of 64.
- Parameters:
-
| bitCount | The number of bits this BitSet should hold. |
- Exceptions:
-
| NegativeArraySizeException | if bitCount is negative. |
| decaf::util::BitSet::BitSet |
( |
const BitSet & |
set |
) |
|
| virtual decaf::util::BitSet::~BitSet |
( |
|
) |
[virtual] |
Member Function Documentation
| void decaf::util::BitSet::AND |
( |
const BitSet & |
set |
) |
|
Performs a logical AND of this target bit set with the argument bit set.
This bit set is modified so that each bit in it has the value true if and only if it both initially had the value true and the corresponding bit in the bit set argument also had the value true.
- Parameters:
-
| set | The BitSet to perform this action against. |
| void decaf::util::BitSet::andNot |
( |
const BitSet & |
set |
) |
|
Clears all of the bits in this BitSet whose corresponding bit is set in the specified BitSet.
- Parameters:
-
| set | The BitSet to perform this action against. |
| int decaf::util::BitSet::cardinality |
( |
|
) |
|
Returns the number of bits set to true in this BitSet.
- Returns:
- the number of bits set to true in this BitSet.
| void decaf::util::BitSet::clear |
( |
int |
fromIndex, |
|
|
int |
toIndex | |
|
) |
| | |
Sets the bits from the specified fromIndex (inclusive) to the specified toIndex (exclusive) to false.
- Parameters:
-
| fromIndex | The index (inclusive) to start setting bits to false. |
| toIndex | The index (exclusive) to stop setting bits to false. |
- Exceptions:
-
| IndexOutOfBoundsException | if fromIndex is negative, or toIndex is negative, or fromIndex is larger than toIndex. |
| void decaf::util::BitSet::clear |
( |
int |
index |
) |
|
Sets the bit specified by the index to false.
- Parameters:
-
| index | The index of the bit whose value is to be set to false |
- Exceptions:
-
| IndexOutOfBoundsException | if the index value is negative. |
| void decaf::util::BitSet::clear |
( |
|
) |
|
Sets all of the bits in this BitSet to false.
| bool decaf::util::BitSet::equals |
( |
const BitSet & |
set |
) |
const |
Compares this object against the specified object.
The result is true if and only if is a Bitset object that has exactly the same set of bits set to true as this bit set. That is, for every nonnegative int index k,
set.get(k) == this->get(k)
must be true. The current sizes of the two bit sets are not compared.
- Returns:
- true if the sets are the same, false otherwise.
| void decaf::util::BitSet::flip |
( |
int |
fromIndex, |
|
|
int |
toIndex | |
|
) |
| | |
Sets each bit from the specified fromIndex (inclusive) to the specified toIndex (exclusive) to the complement of its current value.
- Parameters:
-
| fromIndex | The index (inclusive) to start setting bits to its compliment. |
| toIndex | The index (exclusive) to stop setting bits to its compliment. |
- Exceptions:
-
| IndexOutOfBoundsException | if fromIndex is negative, or toIndex is negative, or fromIndex is larger than toIndex. |
| void decaf::util::BitSet::flip |
( |
int |
index |
) |
|
Sets the bit at the specified index to the complement of its current value.
- Parameters:
-
| index | The index of the bit whose value is to be set to its compliment. |
- Exceptions:
-
| IndexOutOfBoundsException | if the index value is negative. |
| BitSet decaf::util::BitSet::get |
( |
int |
fromIndex, |
|
|
int |
toIndex | |
|
) |
| | const |
Returns a new BitSet composed of bits from this BitSet from fromIndex (inclusive) to toIndex (exclusive).
- Parameters:
-
| fromIndex | The index (inclusive) to start at. |
| toIndex | The index (exclusive) to stop at. |
- Returns:
- a new BitSet containing the specified values.
- Exceptions:
-
| IndexOutOfBoundsException | if fromIndex is negative, or toIndex is negative, or fromIndex is larger than toIndex. |
| bool decaf::util::BitSet::get |
( |
int |
index |
) |
const |
Returns the value of the bit with the specified index.
The value is true if the bit with the given index is currently set in this BitSet; otherwise, the result is false.
- Parameters:
-
| index | The index of the bit in question. |
- Returns:
- the value of the bit with the specified index.
- Exceptions:
-
| IndexOutOfBoundsException | if the index value is negative. |
| bool decaf::util::BitSet::intersects |
( |
const BitSet & |
set |
) |
const |
Returns true if the specified BitSet has any bits set to true that are also set to true in this BitSet.
- Parameters:
-
- Returns:
- boolean indicating whether this BitSet intersects the specified BitSet.
| bool decaf::util::BitSet::isEmpty |
( |
|
) |
const |
Returns true if this BitSet contains no bits that are set to true.
- Returns:
- true if the set is empty, false otherwise.
| int decaf::util::BitSet::length |
( |
|
) |
const |
Returns the "logical size" of this BitSet: the index of the highest set bit in the BitSet plus one.
Returns zero if the BitSet contains no set bits.
- Returns:
- the logical size of the BitSet.
| int decaf::util::BitSet::nextClearBit |
( |
int |
index |
) |
const |
Returns the index of the first bit that is set to false that occurs on or after the specified starting index.
- Parameters:
-
| index | The index to start the search from (inclusive). |
- Returns:
- the index of the next clear bit.
- Exceptions:
-
| IndexOutOfBoundsException | if the index value is negative. |
| int decaf::util::BitSet::nextSetBit |
( |
int |
index |
) |
const |
Returns the index of the first bit that is set to true that occurs on or after the specified starting index.
- Parameters:
-
| index | The index to start the search from (inclusive). |
- Returns:
- the index of the next set bit.
- Exceptions:
-
| IndexOutOfBoundsException | if the index value is negative. |
| bool decaf::util::BitSet::operator!= |
( |
const BitSet & |
other |
) |
const [inline] |
Boolean comparison operator !=.
- Parameters:
-
| other | The other BitSet to compare to this one. |
| BitSet& decaf::util::BitSet::operator= |
( |
const BitSet & |
set |
) |
|
| bool decaf::util::BitSet::operator== |
( |
const BitSet & |
other |
) |
const [inline] |
Boolean comparison operator ==.
- Parameters:
-
| other | The other BitSet to compare to this one. |
| void decaf::util::BitSet::OR |
( |
const BitSet & |
set |
) |
|
Performs a logical OR of this bit set with the bit set argument.
This bit set is modified so that a bit in it has the value true if and only if it either already had the value true or the corresponding bit in the bit set argument has the value true.
- Parameters:
-
| set | The BitSet to perform this action against. |
| void decaf::util::BitSet::set |
( |
int |
fromIndex, |
|
|
int |
toIndex, |
|
|
bool |
value | |
|
) |
| | |
Sets the bits from the specified fromIndex (inclusive) to the specified toIndex (exclusive) to the value given.
- Parameters:
-
| fromIndex | The index (inclusive) to start at. |
| toIndex | The index (exclusive) to stop at. |
| value | The boolean value to assign to the target bits. |
- Exceptions:
-
| IndexOutOfBoundsException | if fromIndex is negative, or toIndex is negative, or fromIndex is larger than toIndex. |
| void decaf::util::BitSet::set |
( |
int |
fromIndex, |
|
|
int |
toIndex | |
|
) |
| | |
Sets the bits from the specified fromIndex (inclusive) to the specified toIndex (exclusive) to true.
- Parameters:
-
| fromIndex | The index (inclusive) to start at. |
| toIndex | The index (exclusive) to stop at. |
- Exceptions:
-
| IndexOutOfBoundsException | if fromIndex is negative, or toIndex is negative, or fromIndex is larger than toIndex. |
| void decaf::util::BitSet::set |
( |
int |
index, |
|
|
bool |
value | |
|
) |
| | |
Sets the bit at the specified index to the specified value.
- Parameters:
-
| index | The index to set. |
| value | The value to assign to the given bit. |
- Exceptions:
-
| IndexOutOfBoundsException | if the index value is negative. |
| void decaf::util::BitSet::set |
( |
int |
index |
) |
|
Sets the bit at the specified index to true.
- Parameters:
-
| index | The index to set to true. |
- Exceptions:
-
| IndexOutOfBoundsException | if the index value is negative. |
| int decaf::util::BitSet::size |
( |
|
) |
const |
Returns the number of bits of space actually in use by this BitSet to represent bit values.
The maximum element in the set is the size - 1st element.
- Returns:
- the number of bits currently in this bit set.
| std::string decaf::util::BitSet::toString |
( |
|
) |
const |
Returns a string representation of this bit set.
For every index for which this BitSet contains a bit in the set state, the decimal representation of that index is included in the result. Such indices are listed in order from lowest to highest, separated by ", " (a comma and a space) and surrounded by braces, resulting in the usual mathematical notation for a set of integers.
- Returns:
- string representation of the BitSet.
| void decaf::util::BitSet::XOR |
( |
const BitSet & |
set |
) |
|
Performs a logical XOR of this bit set with the bit set argument.
This bit set is modified so that a bit in it has the value true if and only if one of the following statements holds:
* The bit initially has the value true, and the corresponding bit in the argument has the value false. * The bit initially has the value false, and the corresponding bit in the argument has the value true.
- Parameters:
-
The documentation for this class was generated from the following file: