83 for ( bit_vector::const_iterator bitsBegin =
bits_.begin(),
84 bitsEnd =
bits_.end(), ibit = bitsBegin;
85 ibit != bitsEnd; ++ibit ) {
86 if ( *ibit ==
false ) b =
false;
93 return ! (
operator bool() );
103 *(
bits_.rbegin()) =
false;
105 std::cout <<
"Duplicate entry " << s <<
", not added to registry" << std::endl;
112 for( str_index_map::const_iterator mbegin =
map_.begin(),
115 mit != mend; ++mit ) {
117 sprintf(buff,
"%10s = %6i", mit->first.c_str(), (
int)(
bits_.at(mit->second)));
118 out << buff << std::endl;
145 for ( bit_vector::iterator ibegin =
bits_.begin(),
146 iend =
bits_.end(),
i = ibegin;
155 for ( bit_vector::iterator ibegin =
bits_.begin(),
156 iend =
bits_.end(),
i = ibegin;
177 (*this)[
s] = !( (*this)[
s] );
182 (*this)[
i] = !( (*this)[
i] );
189 for ( bit_vector::iterator ibegin = ret.
bits_.begin(),
190 iend = ret.
bits_.end(), i = ibegin;
199 if (
map_.size() != r.
map_.size() ) {
200 std::cout <<
"strbitset operator&= : bitsets not the same size" << std::endl;
202 str_index_map::iterator ibegin =
map_.begin(), iend =
map_.end(), i = ibegin;
203 for ( ; i != iend; ++
i ) {
205 str_index_map::const_iterator j = r.
map_.find( key );
206 if ( j == r.
map_.end() ) {
207 std::cout <<
"strbitset operator&= : cannot find key " << key << std::endl;
219 if (
map_.size() != r.
map_.size() ) {
220 std::cout <<
"strbitset operator&= : bitsets not the same size" << std::endl;
222 str_index_map::iterator ibegin =
map_.begin(), iend =
map_.end(), i = ibegin;
223 for ( ; i != iend; ++
i ) {
225 str_index_map::const_iterator j = r.
map_.find( key );
226 if ( j == r.
map_.end() ) {
227 std::cout <<
"strbitset operator&= : cannot find key " << key << std::endl;
240 if (
map_.size() != r.
map_.size() ) {
241 std::cout <<
"strbitset operator&= : bitsets not the same size" << std::endl;
243 str_index_map::iterator ibegin =
map_.begin(), iend =
map_.end(), i = ibegin;
244 for ( ; i != iend; ++
i ) {
246 str_index_map::const_iterator j = r.
map_.find( key );
247 if ( j == r.
map_.end() ) {
248 std::cout <<
"strbitset operator&= : cannot find key " << key << std::endl;
250 (*this)[
key] = ( (*this)[
key] || r[
key]) && ! ((*
this)[
key] && r[
key]);
263 if (
map_.size() != r.
map_.size() ) {
264 std::cout <<
"strbitset operator&= : bitsets not the same size" << std::endl;
266 str_index_map::const_iterator ibegin =
map_.begin(), iend =
map_.end(), i = ibegin;
267 for ( ; i != iend; ++
i ) {
269 str_index_map::const_iterator j = r.
map_.find( key );
270 if ( j == r.
map_.end() ) {
271 std::cout <<
"strbitset operator&= : cannot find key " << key << std::endl;
273 if ( (*
this)[
key] != r[
key] )
return false;
283 for ( bit_vector::const_iterator iBegin =
bits_.begin(),
284 iEnd =
bits_.end(), ibit = iBegin;
285 ibit != iEnd; ++ibit ) {
286 result &= ( *ibit ==
b );
305 for ( bit_vector::const_iterator ibegin =
bits_.begin(),
306 iend =
bits_.end(), i = ibegin;
317 for ( bit_vector::const_iterator ibegin =
bits_.begin(),
318 iend =
bits_.end(), i = ibegin;
320 if ( *i )
return true;
332 return (*
this)[
s] ==
true;
336 return (*
this)[
i] ==
true;
340 const bit_vector&
bits()
const {
346 const std::vector<std::string>
strings()
const {
347 std::vector<std::string>
strings;
348 strings.resize(
bits_.size());
349 for (str_index_map::const_iterator it =
map_.begin(),
351 strings[it->second] = it->first;
369 str_index_map::const_iterator
f =
map_.find(s);
370 if ( f ==
map_.end() ) {
371 std::cout <<
"Cannot find " << s <<
", returning size()" << std::endl;
379 for ( str_index_map::const_iterator
f =
map_.begin(),
382 if (
f->second == i )
return f->first;
384 std::cout <<
"Cannot find " << i <<
", returning dummy" << std::endl;
bool operator!() const
! Logical negation of bool()
bool operator<(index_type const &r) const
std::map< std::string, size_t > str_index_map
size_t count() const
returns number of bits set
friend strbitset operator^(const strbitset &l, const strbitset &r)
strbitset & flip()
flip method of all bits
strbitset & operator&=(const strbitset &r)
bitwise and
bool test(index_type const &i) const
friend strbitset operator|(const strbitset &l, const strbitset &r)
void print(std::ostream &out) const
print method
friend strbitset operator&(const strbitset &l, const strbitset &r)
std::string const & index(size_t i) const
bool operator==(const strbitset &r) const
equality operator
bool operator!=(const strbitset &r) const
inequality operator
strbitset operator~()
logical negation
strbitset & flip(std::string s)
flip method of one bit
strbitset()
constructor: just clears the bitset and map
index_type(strbitset const *b, std::string const &s)
bool operator>(index_type const &r) const
std::string const & str() const
const bit_vector & bits() const
give access to the ordered bits
bool operator==(bool b) const
equality operator to bool
strbitset const * bitset_
void clear()
clear the bitset and map
size_t none() const
returns true if none are set
bool operator>=(index_type const &r) const
size_t index(std::string s) const
strbitset & flip(index_type const &i)
bool test(std::string s) const
test
static const std::string dummy_
bit_vector bits_
the actual bits, indexed by the index in "map_"
const std::vector< std::string > strings() const
give access to the ordered strings
bit_vector::const_reference operator[](const std::string s) const
access method const
bool operator!=(bool b) const
inequality operator to bool
str_index_map map_
map that holds the string–>index map
size_t any() const
returns true if any are set
friend std::ostream & operator<<(std::ostream &out, const index_type &r)
strbitset & operator^=(const strbitset &r)
bitwise xor
bool operator==(index_type const &r) const
std::vector< bool > bit_vector
bool operator<=(index_type const &r) const
strbitset & operator|=(const strbitset &r)
bitwise or
void push_back(std::string s)