Rosetta  2019.12
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | Private Attributes | Friends | List of all members
utility::BitSet< B > Class Template Reference

Simple bit set. More...

#include <BitSet.hh>

Public Types

typedef std::set< BBits
 
typedef B value_type
 
typedef Breference
 
typedef B const & const_reference
 
typedef Bpointer
 
typedef B const * const_pointer
 
typedef Bits::iterator iterator
 
typedef Bits::const_iterator const_iterator
 
typedef Bits::size_type size_type
 
typedef B Bit
 
typedef BReference
 
typedef B const & ConstReference
 
typedef BPointer
 
typedef B const * ConstPointer
 
typedef Bits::iterator Iterator
 
typedef Bits::const_iterator ConstIterator
 
typedef Bits::size_type Size
 

Public Member Functions

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

Private Attributes

Bits bits_
 Bit set. More...
 

Friends

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

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 Bits::const_iterator utility::BitSet< B >::const_iterator
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)

References utility::BitSet< B >::bits_.

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

2 Bit constructor

References utility::BitSet< B >::bits_.

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

3 Bit constructor

References utility::BitSet< B >::bits_.

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

4 Bit constructor

References utility::BitSet< B >::bits_.

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

References utility::BitSet< B >::bits_.

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

Destructor.

Member Function Documentation

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

Begin iterator.

References utility::BitSet< B >::bits_.

template<typename B >
Iterator utility::BitSet< B >::begin ( )
inline

Begin iterator.

References utility::BitSet< B >::bits_.

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

Empty?

References utility::BitSet< B >::bits_.

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

End iterator.

References utility::BitSet< B >::bits_.

template<typename B >
Iterator utility::BitSet< B >::end ( )
inline

End iterator.

References utility::BitSet< B >::bits_.

template<typename B >
BitSet& utility::BitSet< B >::operator+= ( BitSet< B > const &  s)
inline

+= BitSet: Union

References utility::BitSet< B >::bits_.

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

+= Bit

References utility::BitSet< B >::bits_.

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

References utility::BitSet< B >::bits_.

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

BitSet[ i ] const.

References utility::BitSet< B >::bits_.

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

|= BitSet: Union

References utility::BitSet< B >::bits_.

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

|= Bit

References utility::BitSet< B >::bits_.

template<typename B >
Size utility::BitSet< B >::size ( ) const
inline

Size.

References utility::BitSet< B >::bits_.

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

swap( BitSet )

References utility::BitSet< B >::bits_.

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 )

Member Data Documentation

template<typename B >
Bits utility::BitSet< B >::bits_
private

The documentation for this class was generated from the following files: