Rosetta 3.3
Classes | Namespaces | Functions
src/utility/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

namespace  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.
template<typename B >
BitVector< B > utility::operator| (BitVector< B > const &a, BitVector< B > const &b)
 BitVector | BitVector: Union.
template<typename B >
BitVector< B > utility::operator- (BitVector< B > const &a, BitVector< B > const &b)
 BitVector - BitVector: Difference.
template<typename B >
void utility::swap (BitVector< B > &a, BitVector< B > &b)
 swap( BitVector, BitVector )
template<typename B >
bool utility::operator== (BitVector< B > const &a, BitVector< B > const &b)
 BitVector == BitVector.
template<typename B >
bool utility::operator!= (BitVector< B > const &a, BitVector< B > const &b)
 BitVector != BitVector.

Detailed Description

Simple bit vector.

Author:
Stuart G. Mentzer (Stuart_Mentzer@objexx.com)
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
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines