PVData C++  8.0.6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Types | Public Member Functions | Static Public Member Functions | List of all members
epics::pvData::BitSet Class Reference

A vector of bits. More...

#include <misc/pv/bitSet.h>

Inheritance diagram for epics::pvData::BitSet:
Inheritance graph
[legend]
Collaboration diagram for epics::pvData::BitSet:
Collaboration graph
[legend]

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 ()
 
BitSetflip (uint32 bitIndex)
 
BitSetset (uint32 bitIndex)
 
BitSetclear (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.
 
BitSetoperator&= (const BitSet &set)
 
BitSetoperator|= (const BitSet &set)
 
BitSetoperator^= (const BitSet &set)
 
BitSetoperator= (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)
 

Detailed Description

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.

Since
7.0.0 Many methods return BitSet& to facilite method chaining.

Definition at line 56 of file bitSet.h.

Constructor & Destructor Documentation

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.

Parameters
nbitsthe initial size of the bit set
virtual epics::pvData::BitSet::~BitSet ( )
virtual

Destructor.

Member Function Documentation

uint32 epics::pvData::BitSet::cardinality ( ) const

Returns the number of bits set to true in this BitSet.

Returns
the number of bits set to true in this BitSet
BitSet& epics::pvData::BitSet::clear ( uint32  bitIndex)

Sets the bit specified by the index to false.

Parameters
bitIndexthe index of the bit to be cleared
void epics::pvData::BitSet::clear ( )

Sets all of the bits in this BitSet to false.

virtual void epics::pvData::BitSet::deserialize ( ByteBuffer buffer,
DeserializableControl flusher 
)
virtual

Deserialize buffer.

Parameters
bufferserialization buffer.
flusherdeserialization control.

Implements epics::pvData::Serializable.

BitSet& epics::pvData::BitSet::flip ( uint32  bitIndex)

Sets the bit at the specified index to the complement of its current value.

Parameters
bitIndexthe 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.

Parameters
bitIndexthe bit index
Returns
the value of the bit with the specified index
bool epics::pvData::BitSet::isEmpty ( ) const

Returns true if this BitSet contains no bits that are set to true.

Returns
indicating whether this BitSet is empty
int32 epics::pvData::BitSet::nextClearBit ( uint32  fromIndex) const

Returns the index of the first bit that is set to false that occurs on or after the specified starting index.

Parameters
fromIndexthe index to start checking from (inclusive)
Returns
the index of the next clear bit
int32 epics::pvData::BitSet::nextSetBit ( uint32  fromIndex) const

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:

for (int32 i = bs.nextSetBit(0); i >= 0; i = bs.nextSetBit(i+1)) {
// operate on index i here
}
Parameters
fromIndexthe index to start checking from (inclusive)
Returns
the index of the next set bit, or -1 if there is no such bit
BitSet& epics::pvData::BitSet::operator&= ( const BitSet set)

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.

Parameters
seta bit set
BitSet& epics::pvData::BitSet::operator= ( const BitSet set)

Assignment operator.

bool epics::pvData::BitSet::operator== ( const BitSet set) const

Comparison operator.

BitSet& epics::pvData::BitSet::operator^= ( const BitSet set)

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:

  • 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
seta bit set
BitSet& epics::pvData::BitSet::operator|= ( const BitSet 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.

Parameters
seta bit set
void epics::pvData::BitSet::or_and ( const BitSet set1,
const BitSet set2 
)

Perform AND operation on set1 and set2, and OR on result and this instance.

Parameters
set1
set2
virtual void epics::pvData::BitSet::serialize ( ByteBuffer buffer,
SerializableControl flusher 
) const
virtual

Serialize field into given buffer.

Parameters
bufferserialization buffer.
flusherflush interface.

Implements epics::pvData::Serializable.

BitSet& epics::pvData::BitSet::set ( uint32  bitIndex)

Sets the bit at the specified index to true.

Parameters
bitIndexa bit index
void epics::pvData::BitSet::set ( uint32  bitIndex,
bool  value 
)

Sets the bit at the specified index to the specified value.

Parameters
bitIndexa bit index
valuea 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.

Returns
the number of bits currently in this bit set

The documentation for this class was generated from the following file: