activemq-cpp-3.6.0
|
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 () |
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. |
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.
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.
bitCount | The number of bits this BitSet should hold. |
NegativeArraySizeException | if bitCount is negative. |
|
virtual |
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.
set | The BitSet to perform this action against. |
int decaf::util::BitSet::cardinality | ( | ) |
void decaf::util::BitSet::clear | ( | ) |
Sets all of the bits in this BitSet to false.
void decaf::util::BitSet::clear | ( | int | index | ) |
Sets the bit specified by the index to false.
index | The index of the bit whose value is to be set to false |
IndexOutOfBoundsException | if the index value is negative. |
void decaf::util::BitSet::clear | ( | int | fromIndex, |
int | toIndex | ||
) |
Sets the bits from the specified fromIndex (inclusive) to the specified toIndex (exclusive) to false.
fromIndex | The index (inclusive) to start setting bits to false. |
toIndex | The index (exclusive) to stop setting bits to false. |
IndexOutOfBoundsException | if fromIndex is negative, or toIndex is negative, or fromIndex is larger than toIndex. |
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.
void decaf::util::BitSet::flip | ( | int | index | ) |
Sets the bit at the specified index to the complement of its current value.
index | The index of the bit whose value is to be set to its compliment. |
IndexOutOfBoundsException | if the index value is negative. |
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.
fromIndex | The index (inclusive) to start setting bits to its compliment. |
toIndex | The index (exclusive) to stop setting bits to its compliment. |
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.
index | The index of the bit in question. |
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).
fromIndex | The index (inclusive) to start at. |
toIndex | The index (exclusive) to stop at. |
IndexOutOfBoundsException | if fromIndex is negative, or toIndex is negative, or fromIndex is larger than toIndex. |
bool decaf::util::BitSet::isEmpty | ( | ) | const |
Returns true if this BitSet contains no bits that are set to true.
int decaf::util::BitSet::length | ( | ) | const |
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.
index | The index to start the search from (inclusive). |
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.
index | The index to start the search from (inclusive). |
IndexOutOfBoundsException | if the index value is negative. |
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.
set | The BitSet to perform this action against. |
void decaf::util::BitSet::set | ( | int | index | ) |
Sets the bit at the specified index to true.
index | The index to set to true. |
IndexOutOfBoundsException | if the index value is negative. |
void decaf::util::BitSet::set | ( | int | index, |
bool | value | ||
) |
Sets the bit at the specified index to the specified value.
index | The index to set. |
value | The value to assign to the given bit. |
IndexOutOfBoundsException | if the index value is negative. |
void decaf::util::BitSet::set | ( | int | fromIndex, |
int | toIndex | ||
) |
Sets the bits from the specified fromIndex (inclusive) to the specified toIndex (exclusive) to true.
fromIndex | The index (inclusive) to start at. |
toIndex | The index (exclusive) to stop at. |
IndexOutOfBoundsException | if fromIndex is negative, or toIndex is negative, or fromIndex is larger than toIndex. |
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.
fromIndex | The index (inclusive) to start at. |
toIndex | The index (exclusive) to stop at. |
value | The boolean value to assign to the target bits. |
IndexOutOfBoundsException | if fromIndex is negative, or toIndex is negative, or fromIndex is larger than toIndex. |
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.
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.
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:
set | The BitSet to use. |