Rosetta 3.3
Public Types | Public Member Functions | Friends
utility::BitSet< B > Class Template Reference

Simple bit set. More...

#include <BitSet.hh>

Collaboration diagram for utility::BitSet< B >:
Collaboration graph
[legend]

List of all members.

Public Types

typedef std::set< B > Bits
typedefvalue_type
typedef B & reference
typedef B const & const_reference
typedef B * pointer
typedef B const * const_pointer
typedef Bits::iterator iterator
typedef Bits::const_iterator const_iterator
typedef Bits::size_type size_type
typedefBit
typedef B & Reference
typedef B const & ConstReference
typedef B * Pointer
typedef B const * ConstPointer
typedef Bits::iterator Iterator
typedef Bits::const_iterator ConstIterator
typedef Bits::size_type Size

Public Member Functions

 BitSet ()
 Default constructor.
 BitSet (Bit const &i)
 Bit constructor (implicit)
 BitSet (Bit const &i, Bit const &j)
 2 Bit constructor
 BitSet (Bit const &i, Bit const &j, Bit const &k)
 3 Bit constructor
 BitSet (Bit const &i, Bit const &j, Bit const &k, Bit const &l)
 4 Bit constructor
 BitSet (Bit const &i, Bit const &j, Bit const &k, Bit const &l, Bit const &m)
 5 Bit constructor
 ~BitSet ()
 Destructor.
BitSetoperator+= (BitSet const &s)
 += BitSet: Union
BitSetoperator|= (BitSet const &s)
 |= BitSet: Union
BitSetoperator-= (BitSet const &s)
 -= BitSet: Difference
BitSetoperator+= (Bit const &i)
 += Bit
BitSetoperator|= (Bit const &i)
 |= Bit
BitSetoperator-= (Bit const &i)
 -= Bit
void swap (BitSet &s)
 swap( BitSet )
Size size () const
 Size.
bool empty () const
 Empty?
bool operator[] (Bit const &i) const
 BitSet[ i ] const.
ConstIterator begin () const
 Begin iterator.
Iterator begin ()
 Begin iterator.
ConstIterator end () const
 End iterator.
Iterator end ()
 End iterator.

Friends

BitSet operator+ (BitSet const &a, BitSet const &b)
 BitSet + BitSet: Union.
BitSet operator| (BitSet const &a, BitSet const &b)
 BitSet | BitSet: Union.
BitSet operator- (BitSet const &a, BitSet const &b)
 BitSet - BitSet: Difference.
void swap (BitSet &a, BitSet &b)
 swap( BitSet, BitSet )
bool operator== (BitSet const &a, BitSet const &b)
 BitSet == BitSet.
bool operator!= (BitSet const &a, BitSet const &b)
 BitSet != BitSet.

Detailed Description

template<typename B>
class utility::BitSet< B >

Simple bit set.

Note:
  • Bit set with a convenient interface for bit fields
  • Stores a set of the bit numbers that are on (present) so space efficient for sparse sets but could have slower lookup for large sets than std::bitset, vector<bool>, or BitVector
  • Bits not in set are considered false
  • Bits are the index of the stored (true) bits
  • There must be a way to generate a BitSet from 2 Bits to construct a BitSet with more than 5 Bits, such as: inline utility::BitSet< Bit > operator |( Bit const & i, Bit const & j ) { return utility::BitSet< Bit >( i, j ); }
  • Construction with more than 5 Bits can be done most efficiently as BitSet< Bit >( i | j |= k |= l ) assuming an operator| is defined as above: the use of |= instead of | after the first | avoids generating additional BitSet temporaries

Member Typedef Documentation

template<typename B >
typedef B utility::BitSet< B >::Bit
template<typename B >
typedef std::set< B > utility::BitSet< B >::Bits
template<typename B >
typedef B const* utility::BitSet< B >::const_pointer
template<typename B >
typedef B const& utility::BitSet< B >::const_reference
template<typename B >
typedef B const* utility::BitSet< B >::ConstPointer
template<typename B >
typedef B const& utility::BitSet< B >::ConstReference
template<typename B >
typedef Bits::iterator utility::BitSet< B >::iterator
template<typename B >
typedef Bits::iterator utility::BitSet< B >::Iterator
template<typename B >
typedef B* utility::BitSet< B >::Pointer
template<typename B >
typedef B* utility::BitSet< B >::pointer
template<typename B >
typedef B& utility::BitSet< B >::Reference
template<typename B >
typedef B& utility::BitSet< B >::reference
template<typename B >
typedef Bits::size_type utility::BitSet< B >::Size
template<typename B >
typedef Bits::size_type utility::BitSet< B >::size_type
template<typename B >
typedef B utility::BitSet< B >::value_type

Constructor & Destructor Documentation

template<typename B >
utility::BitSet< B >::BitSet ( ) [inline]

Default constructor.

template<typename B >
utility::BitSet< B >::BitSet ( Bit const &  i) [inline]

Bit constructor (implicit)

template<typename B >
utility::BitSet< B >::BitSet ( Bit const &  i,
Bit const &  j 
) [inline]

2 Bit constructor

template<typename B >
utility::BitSet< B >::BitSet ( Bit const &  i,
Bit const &  j,
Bit const &  k 
) [inline]

3 Bit constructor

template<typename B >
utility::BitSet< B >::BitSet ( Bit const &  i,
Bit const &  j,
Bit const &  k,
Bit const &  l 
) [inline]

4 Bit constructor

template<typename B >
utility::BitSet< B >::BitSet ( Bit const &  i,
Bit const &  j,
Bit const &  k,
Bit const &  l,
Bit const &  m 
) [inline]

5 Bit constructor

template<typename B >
utility::BitSet< B >::~BitSet ( ) [inline]

Destructor.


Member Function Documentation

template<typename B >
ConstIterator utility::BitSet< B >::begin ( ) const [inline]
template<typename B >
Iterator utility::BitSet< B >::begin ( ) [inline]

Begin iterator.

template<typename B >
bool utility::BitSet< B >::empty ( ) const [inline]

Empty?

template<typename B >
ConstIterator utility::BitSet< B >::end ( ) const [inline]
template<typename B >
Iterator utility::BitSet< B >::end ( ) [inline]

End iterator.

template<typename B >
BitSet& utility::BitSet< B >::operator+= ( Bit const &  i) [inline]

+= Bit

template<typename B >
BitSet& utility::BitSet< B >::operator+= ( BitSet< B > const &  s) [inline]
template<typename B >
BitSet& utility::BitSet< B >::operator-= ( BitSet< B > const &  s) [inline]
template<typename B >
BitSet& utility::BitSet< B >::operator-= ( Bit const &  i) [inline]

-= Bit

template<typename B >
bool utility::BitSet< B >::operator[] ( Bit const &  i) const [inline]

BitSet[ i ] const.

template<typename B >
BitSet& utility::BitSet< B >::operator|= ( Bit const &  i) [inline]

|= Bit

template<typename B >
BitSet& utility::BitSet< B >::operator|= ( BitSet< B > const &  s) [inline]
template<typename B >
Size utility::BitSet< B >::size ( ) const [inline]

Size.

template<typename B >
void utility::BitSet< B >::swap ( BitSet< B > &  s) [inline]

swap( BitSet )


Friends And Related Function Documentation

template<typename B >
bool operator!= ( BitSet< B > const &  a,
BitSet< B > const &  b 
) [friend]
template<typename B >
BitSet operator+ ( BitSet< B > const &  a,
BitSet< B > const &  b 
) [friend]

BitSet + BitSet: Union.

template<typename B >
BitSet operator- ( BitSet< B > const &  a,
BitSet< B > const &  b 
) [friend]

BitSet - BitSet: Difference.

template<typename B >
bool operator== ( BitSet< B > const &  a,
BitSet< B > const &  b 
) [friend]
template<typename B >
BitSet operator| ( BitSet< B > const &  a,
BitSet< B > const &  b 
) [friend]

BitSet | BitSet: Union.

template<typename B >
void swap ( BitSet< B > &  a,
BitSet< B > &  b 
) [friend]

swap( BitSet, BitSet )


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines