#include <PhysicsTools/MVAComputer/interface/BitSet.h>
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 (size_t bits) | |
construct BitSet with a fixed size of bits bits | |
BitSet (const BitSet &orig) | |
BitSet () | |
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 |
Classes | |
class | Iterator |
Iterates over all set bits of a BitSet. More... | |
class | Manipulator |
Opaque structure for transparent write access to individual bits. More... |
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.
Definition at line 30 of file BitSet.h.
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] |
Definition at line 129 of file BitSet.h.
References bits_, bitsToWords(), and store.
00129 : bits_(orig.bits_) 00130 { 00131 std::size_t words = bitsToWords(bits_); 00132 if (words) { 00133 store = new Word_t[words]; 00134 std::memcpy(store, orig.store, words * sizeof(Word_t)); 00135 } else 00136 store = 0; 00137 }
PhysicsTools::BitSet::BitSet | ( | size_t | bits | ) | [inline] |
construct BitSet with a fixed size of bits bits
Definition at line 140 of file BitSet.h.
References bitsToWords(), and store.
00140 : bits_(bits) 00141 { 00142 std::size_t words = bitsToWords(bits); 00143 if (words) { 00144 store = new Word_t[words]; 00145 std::memset(store, 0, sizeof(Word_t) * words); 00146 } else 00147 store = 0; 00148 }
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, p, and store.
00007 { 00008 static unsigned char byteBits[256] = { 00009 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 00010 4, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 00011 4, 5, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 00012 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 00013 4, 5, 5, 6, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 00014 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 00015 4, 5, 4, 5, 5, 6, 2, 3, 3, 4, 3, 4, 4, 5, 3, 00016 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 00017 4, 5, 5, 6, 5, 6, 6, 7, 1, 2, 2, 3, 2, 3, 3, 00018 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 00019 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 2, 3, 3, 4, 3, 00020 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 00021 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 2, 3, 3, 00022 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 00023 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 3, 00024 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 00025 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 00026 8 00027 }; 00028 unsigned char *begin = (unsigned char*)store; 00029 unsigned char *end = (unsigned char*)(store + bitsToWords(bits_)); 00030 00031 size_t bits = 0; 00032 for(unsigned char *p = begin; p < end; p++) 00033 bits += byteBits[*p]; 00034 00035 return bits; 00036 }
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(), and PhysicsTools::VarProcessor::eval().
00181 { return Iterator(store, store + bitsToWords(bits_)); }
Definition at line 152 of file BitSet.h.
References bits_, bitsToWords(), and store.
00153 { 00154 delete[] store; 00155 bits_ = orig.bits_; 00156 std::size_t words = bitsToWords(bits_); 00157 if (words) { 00158 store = new Word_t[words]; 00159 std::memcpy(store, orig.store, words * sizeof(Word_t)); 00160 } else 00161 store = 0; 00162 return *this; 00163 }
const Manipulator PhysicsTools::BitSet::operator[] | ( | size_t | bit | ) | const [inline] |
Manipulator PhysicsTools::BitSet::operator[] | ( | size_t | bit | ) | [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().
00174 { 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[]().