Rosetta Utilities  2015.09
Classes | Namespaces | Functions
BitVector.hh File Reference

Simple bit vector. More...

#include <utility/BitVector.fwd.hh>
#include <utility/utility.functions.hh>
#include <vector>

Classes

class  utility::BitVector< B >
 Simple bit vector. More...
 

Namespaces

 utility
 unresizable vector whose size is known at compile time, which may be allocated on the stack, and which indexes from 1.
 

Functions

template<typename B >
BitVector< B > utility::operator+ (BitVector< B > const &a, BitVector< B > const &b)
 BitVector + BitVector: Union. More...
 
template<typename B >
BitVector< B > utility::operator| (BitVector< B > const &a, BitVector< B > const &b)
 BitVector | BitVector: Union. More...
 
template<typename B >
BitVector< B > utility::operator- (BitVector< B > const &a, BitVector< B > const &b)
 BitVector - BitVector: Difference. More...
 
template<typename B >
void utility::swap (BitVector< B > &a, BitVector< B > &b)
 swap( BitVector, BitVector ) More...
 
template<typename B >
bool utility::operator== (BitVector< B > const &a, BitVector< B > const &b)
 BitVector == BitVector. More...
 
template<typename B >
bool utility::operator!= (BitVector< B > const &a, BitVector< B > const &b)
 BitVector != BitVector. More...
 

Detailed Description

Simple bit vector.

Author
Stuart G. Mentzer (Stuar.nosp@m.t_Me.nosp@m.ntzer.nosp@m.@obj.nosp@m.exx.c.nosp@m.om)
Note
  • Wraps std::vector<bool> with a more convenient interface for bit fields
  • Bits not in vector are considered false
  • Bit type must be convertible to vector::size_type: making this a template arg allows the use of classes with private conversion to an integral type that make BitVector a friend
  • Stores a vector<bool> of the bits
  • Faster but less space efficient than BitSet for sparse sets (mostly false bits)
  • Bits are the index of the bits in the vector
  • There must be a way to generate a BitVector from 2 Bits to construct a BitVector with more than 5 Bits, such as: inline utility::BitVector< Bit > operator |( Bit const & i, Bit const & j ) { return utility::BitVector< Bit >( i, j ); }
  • Construction with more than 5 Bits can be done most efficiently as BitVector< Bit >( i | j |= k |= l ) assuming an operator| is defined as above: the use of |= instead of | after the first | avoids generating additional BitVector temporaries