PVData C++
8.0.6
|
A vector of bits. More...
#include <misc/pv/bitSet.h>
Public Types | |
typedef std::tr1::shared_ptr < BitSet > | shared_pointer |
typedef std::tr1::shared_ptr < const BitSet > | const_shared_pointer |
typedef std::tr1::weak_ptr < BitSet > | weak_pointer |
typedef std::tr1::weak_ptr < const BitSet > | const_weak_pointer |
Public Member Functions | |
BitSet () | |
BitSet (uint32 nbits) | |
virtual | ~BitSet () |
BitSet & | flip (uint32 bitIndex) |
BitSet & | set (uint32 bitIndex) |
BitSet & | clear (uint32 bitIndex) |
void | set (uint32 bitIndex, bool value) |
bool | get (uint32 bitIndex) const |
void | clear () |
int32 | nextSetBit (uint32 fromIndex) const |
int32 | nextClearBit (uint32 fromIndex) const |
bool | isEmpty () const |
uint32 | cardinality () const |
uint32 | size () const |
bool | logical_and (const BitSet &other) const |
Returns true if any bit is set in both *this and other. | |
bool | logical_or (const BitSet &other) const |
Returns true if any bit is set in both *this or other. | |
BitSet & | operator&= (const BitSet &set) |
BitSet & | operator|= (const BitSet &set) |
BitSet & | operator^= (const BitSet &set) |
BitSet & | operator= (const BitSet &set) |
void | swap (BitSet &set) |
Swap contents. | |
void | or_and (const BitSet &set1, const BitSet &set2) |
bool | operator== (const BitSet &set) const |
bool | operator!= (const BitSet &set) const |
virtual void | serialize (ByteBuffer *buffer, SerializableControl *flusher) const |
virtual void | deserialize (ByteBuffer *buffer, DeserializableControl *flusher) |
Public Member Functions inherited from epics::pvData::Serializable | |
virtual | ~Serializable () |
Static Public Member Functions | |
static BitSetPtr | create (uint32 nbits) |
A vector of bits.
This class implements a vector of bits that grows as needed. Each component of the bit set has a bool
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 multithreaded use without external synchronization.
Based on Java implementation.
epics::pvData::BitSet::BitSet | ( | ) |
Creates a new bit set. All bits are initially false
.
epics::pvData::BitSet::BitSet | ( | uint32 | nbits | ) |
Creates a bit set whose initial size is large enough to explicitly represent bits with indices in the range 0
through nbits-1
. All bits are initially false
.
nbits | the initial size of the bit set |
|
virtual |
Destructor.
uint32 epics::pvData::BitSet::cardinality | ( | ) | const |
Sets the bit specified by the index to false
.
bitIndex | the index of the bit to be cleared |
void epics::pvData::BitSet::clear | ( | ) |
Sets all of the bits in this BitSet to false
.
|
virtual |
Deserialize buffer.
buffer | serialization buffer. |
flusher | deserialization control. |
Implements epics::pvData::Serializable.
Sets the bit at the specified index to the complement of its current value.
bitIndex | the index of the bit to flip |
bool epics::pvData::BitSet::get | ( | uint32 | bitIndex | ) | const |
Returns the value of the bit with the specified index. The value is true
if the bit with the index bitIndex
is currently set in this BitSet
; otherwise, the result is false
.
bitIndex | the bit index |
bool epics::pvData::BitSet::isEmpty | ( | ) | const |
Returns the index of the first bit that is set to false
that occurs on or after the specified starting index.
fromIndex | the index to start checking from (inclusive) |
Returns the index of the first bit that is set to true
that occurs on or after the specified starting index. If no such bit exists then -1
is returned.
To iterate over the true
bits in a BitSet
, use the following loop:
fromIndex | the index to start checking from (inclusive) |
-1
if there is no such bit Performs a bitwise 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 | a bit set |
bool epics::pvData::BitSet::operator== | ( | const BitSet & | set | ) | const |
Comparison operator.
Performs a bitwise 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:
true
, and the corresponding bit in the argument has the value false
. false
, and the corresponding bit in the argument has the value true
. set | a bit set |
Performs a bitwise 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 | a bit set |
Perform AND operation on set1
and set2
, and OR on result and this instance.
set1 | |
set2 |
|
virtual |
Serialize field into given buffer.
buffer | serialization buffer. |
flusher | flush interface. |
Implements epics::pvData::Serializable.
Sets the bit at the specified index to true
.
bitIndex | a bit index |
void epics::pvData::BitSet::set | ( | uint32 | bitIndex, |
bool | value | ||
) |
Sets the bit at the specified index to the specified value.
bitIndex | a bit index |
value | a boolean value to set |
uint32 epics::pvData::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.