A compact container for storing single bits. More...
#include <BitSet.h>
Classes | |
class | Iterator |
Iterates over all set bits of a BitSet. More... | |
class | Manipulator |
Opaque structure for transparent write access to individual bits. More... | |
Public Types | |
typedef std::size_t | size_t |
Public Member Functions | |
size_t | bits () const |
returns the number of set bits in the container | |
BitSet () | |
BitSet (const BitSet &orig) | |
BitSet (size_t bits) | |
construct BitSet with a fixed size of bits bits | |
Iterator | iter () const |
create iterator over all set bits | |
BitSet & | operator= (const BitSet &orig) |
const Manipulator | operator[] (size_t bit) const |
provide read access to bit with index bit via reference | |
Manipulator | operator[] (size_t bit) |
provide read/write access to bit with index bit via reference | |
size_t | size () const |
returns the number of all bits in the container | |
~BitSet () | |
Protected Types | |
typedef unsigned int | Word_t |
Static Private Member Functions | |
static size_t | bitsToWords (std::size_t bits) |
Private Attributes | |
size_t | bits_ |
Word_t * | store |
Static Private Attributes | |
static const unsigned int | wordSize = sizeof(Word_t) * 8 |
A compact container for storing single bits.
BitSet provides a container of boolean values, similar to a std::vector<bool> which only consumes one actual bit for each value. Also an iterator is provided that can iterate over all set bits.
typedef std::size_t PhysicsTools::BitSet::size_t |
typedef unsigned int PhysicsTools::BitSet::Word_t [protected] |
PhysicsTools::BitSet::BitSet | ( | ) | [inline] |
PhysicsTools::BitSet::BitSet | ( | const BitSet & | orig | ) | [inline] |
PhysicsTools::BitSet::BitSet | ( | size_t | bits | ) | [inline] |
PhysicsTools::BitSet::~BitSet | ( | ) | [inline] |
BitSet::size_t PhysicsTools::BitSet::bits | ( | ) | const |
returns the number of set bits in the container
Definition at line 6 of file BitSet.cc.
References begin, bits_, bitsToWords(), end, L1TEmulatorMonitor_cff::p, and store.
{ static unsigned char byteBits[256] = { 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8 }; unsigned char *begin = (unsigned char*)store; unsigned char *end = (unsigned char*)(store + bitsToWords(bits_)); size_t bits = 0; for(unsigned char *p = begin; p < end; p++) bits += byteBits[*p]; return bits; }
static size_t PhysicsTools::BitSet::bitsToWords | ( | std::size_t | bits | ) | [inline, static, private] |
Iterator PhysicsTools::BitSet::iter | ( | ) | const [inline] |
create iterator over all set bits
Definition at line 180 of file BitSet.h.
References bits_, bitsToWords(), and store.
Referenced by PhysicsTools::VarProcessor::configure(), PhysicsTools::VarProcessor::deriv(), and PhysicsTools::VarProcessor::eval().
{ return Iterator(store, store + bitsToWords(bits_)); }
Manipulator PhysicsTools::BitSet::operator[] | ( | size_t | bit | ) | [inline] |
const Manipulator PhysicsTools::BitSet::operator[] | ( | size_t | bit | ) | const [inline] |
size_t PhysicsTools::BitSet::size | ( | void | ) | const [inline] |
returns the number of all bits in the container
Definition at line 174 of file BitSet.h.
References bits_.
Referenced by PhysicsTools::VarProcessor::configure(), and PhysicsTools::Calibration::convert().
{ return bits_; }
size_t PhysicsTools::BitSet::bits_ [private] |
Word_t* PhysicsTools::BitSet::store [private] |
Definition at line 189 of file BitSet.h.
Referenced by bits(), BitSet(), iter(), operator=(), operator[](), and ~BitSet().
const unsigned int PhysicsTools::BitSet::wordSize = sizeof(Word_t) * 8 [static, private] |
Definition at line 187 of file BitSet.h.
Referenced by bitsToWords(), PhysicsTools::BitSet::Iterator::operator()(), PhysicsTools::BitSet::Iterator::operator++(), and operator[]().