![]() |
This is Unofficial EPICS BASE Doxygen Site
|
A vector of bits. More...
#include "bitSet.h"
Public Member Functions | |
POINTER_DEFINITIONS (BitSet) | |
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. More... | |
bool | logical_or (const BitSet &other) const |
Returns true if any bit is set in both *this or other. More... | |
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. More... | |
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) |
![]() | |
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
.
Definition at line 51 of file bitSet.cpp.
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 |
Definition at line 53 of file bitSet.cpp.
|
virtual |
uint32 epics::pvData::BitSet::cardinality | ( | ) | const |
Returns the number of bits set to true
in this BitSet
.
true
in this BitSet
Definition at line 203 of file bitSet.cpp.
Sets the bit specified by the index to false
.
bitIndex | the index of the bit to be cleared |
Definition at line 112 of file bitSet.cpp.
void epics::pvData::BitSet::clear | ( | ) |
Sets all of the bits in this BitSet to false
.
Definition at line 136 of file bitSet.cpp.
|
static |
Definition at line 46 of file bitSet.cpp.
|
virtual |
Deserialize buffer.
buffer | serialization buffer. |
flusher | deserialization control. |
Implements epics::pvData::Serializable.
Definition at line 339 of file bitSet.cpp.
Sets the bit at the specified index to the complement of its current value.
bitIndex | the index of the bit to flip |
Definition at line 92 of file bitSet.cpp.
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 |
Definition at line 130 of file bitSet.cpp.
bool epics::pvData::BitSet::isEmpty | ( | ) | const |
Returns true if this BitSet
contains no bits that are set to true
.
BitSet
is empty Definition at line 199 of file bitSet.cpp.
bool epics::pvData::BitSet::logical_and | ( | const BitSet & | other | ) | const |
bool epics::pvData::BitSet::logical_or | ( | const BitSet & | other | ) | const |
Returns true if any bit is set in both *this or other.
Definition at line 223 of file bitSet.cpp.
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) |
Definition at line 181 of file bitSet.cpp.
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 Definition at line 164 of file bitSet.cpp.
bool epics::pvData::BitSet::operator!= | ( | const BitSet & | set | ) | const |
Definition at line 310 of file bitSet.cpp.
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 |
Definition at line 228 of file bitSet.cpp.
Assignment operator.
Definition at line 269 of file bitSet.cpp.
bool epics::pvData::BitSet::operator== | ( | const BitSet & | set | ) | const |
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 |
Definition at line 257 of file bitSet.cpp.
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 |
Definition at line 242 of file bitSet.cpp.
Perform AND operation on set1
and set2
, and OR on result and this instance.
set1 | |
set2 |
Definition at line 282 of file bitSet.cpp.
epics::pvData::BitSet::POINTER_DEFINITIONS | ( | BitSet | ) |
|
virtual |
Serialize field into given buffer.
buffer | serialization buffer. |
flusher | flush interface. |
Implements epics::pvData::Serializable.
Definition at line 315 of file bitSet.cpp.
Sets the bit at the specified index to true
.
bitIndex | a bit index |
Definition at line 103 of file bitSet.cpp.
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 |
Definition at line 123 of file bitSet.cpp.
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.
Definition at line 210 of file bitSet.cpp.
void epics::pvData::BitSet::swap | ( | BitSet & | set | ) |