Bitset Struct Reference

Dynamic bitset class. More...

List of all members.

Public Member Functions

 Bitset (size_type max)
 Default constructor.
 Bitset (size_type max, const data_type *data)
 Constructor with user-provided bit field.
 Bitset (const Bitset &bs)
 Copy constructor.
template<class InputIterator>
 Bitset (InputIterator first, InputIterator last)
 Constructor from Input Iterators.
 ~Bitset ()
 Standard destructor.
Bitsetoperator= (const Bitset &rhs)
 Affectation.
void swap (Bitset &other)
 Swap with another Bitset.
void clear ()
 Clear the set.
iterator find (const key_type &x) const
 Find an element in the set.
size_type count (const key_type &x) const
 Used for compatibility with std::set. Returns 0 or 1.
bool operator[] (const key_type &x) const
 Returns the xth bit.
Bitset project (const Bitset &b) const
 Project the set onto another bitset. The result is space-optimized.
Bitset unproject (const Bitset &b) const
 Inverse function of project.
unsigned to_unsigned () const
 Reinterpret bits as unsigned int.
template<typename Type>
const Type cast () const
 Reinterpret bits as another type.
std::ostream & print (std::ostream &ostr) const
 Print the set.
iterator begin ()
 Iterators.
const_iterator begin () const
 Iterators.
iterator end ()
 Iterators.
const_iterator end () const
 Iterators.
reverse_iterator rbegin ()
 Reverse iterators.
const_reverse_iterator rbegin () const
 Reverse iterators.
reverse_iterator rend ()
 Reverse iterators.
const_reverse_iterator rend () const
 Reverse iterators.
std::pair< iterator, bool > insert (const value_type &x)
 Insert an element into the set.
iterator insert (iterator position, const value_type &x)
 Insert an element into the set.
template<class InputIterator>
void insert (InputIterator first, InputIterator last)
 Insert an element into the set.
void erase (iterator position)
 Erase an element from the set.
size_type erase (const key_type &x)
 Erase an element from the set.
void erase (iterator first, iterator last)
 Erase an element from the set.

Protected Member Functions

bool get_bit (size_type index, size_type bit) const
 Get a bit inside data_.
size_type compute_size () const
 Recalculate the set's size when invalid.
bool get_bit (const bit_iterator &it) const
 Get a bit inside data_ given an iterator.
template<class BitAction>
bool do_on_bit (BitAction &action, const key_type &x)
 Perform an action onto the bit corresponding to an element.
template<class BitAction>
bool do_on_bit (BitAction &action, const bit_iterator &it)
 Perform an action onto the bit corresponding to an element.
template<class ConstBitAction>
bool do_on_bit (ConstBitAction &action, const key_type &x) const
 Perform an action onto the bit corresponding to an element, const.
template<class ConstBitAction>
bool do_on_bit (ConstBitAction &action, const bit_iterator &it) const
 Perform an action onto the bit corresponding to an element, const.

Static Protected Member Functions

static size_type get_data_size (size_type max)
 Calculates the number of data_type needed for the set.
static size_type get_index (const key_type &x)
 Get the index of x in the data_ attribute.
static size_type get_bitnum (const key_type &x)
 Get the bit number of x inside the data_[i] attribute.


Detailed Description

Dynamic bitset class.

This is a dynamic bitset implementation which behave almost like a std::set<int>.

Author:
Thomas Claveirole <thomas@lrde.epita.fr>

Definition at line 45 of file bitset.hh.


Constructor & Destructor Documentation

Bitset ( size_type  max  )  [inline]

Default constructor.

Parameters:
max The highest integer which could be inserted into the set.

Definition at line 43 of file bitset.hxx.


Member Function Documentation

Bitset::iterator begin (  )  [inline]

Iterators.

Definition at line 130 of file bitset.hxx.

Referenced by Bitset::rend().

Bitset::const_iterator begin (  )  const [inline]

Iterators.

Definition at line 137 of file bitset.hxx.

Bitset::iterator end (  )  [inline]

Iterators.

Definition at line 145 of file bitset.hxx.

Referenced by Bitset::insert(), and Bitset::rbegin().

Bitset::const_iterator end (  )  const [inline]

Iterators.

Definition at line 152 of file bitset.hxx.

Bitset::reverse_iterator rbegin (  )  [inline]

Reverse iterators.

Definition at line 164 of file bitset.hxx.

References Bitset::end().

Bitset::const_reverse_iterator rbegin (  )  const [inline]

Reverse iterators.

Definition at line 171 of file bitset.hxx.

References Bitset::end().

Bitset::reverse_iterator rend (  )  [inline]

Reverse iterators.

Definition at line 179 of file bitset.hxx.

References Bitset::begin().

Bitset::const_reverse_iterator rend (  )  const [inline]

Reverse iterators.

Definition at line 186 of file bitset.hxx.

References Bitset::begin().

std::pair< Bitset::iterator, bool > insert ( const value_type &  x  )  [inline]

Insert an element into the set.

Definition at line 225 of file bitset.hxx.

References Bitset::end(), Bitset::get_bit(), Bitset::get_bitnum(), and Bitset::get_index().

Referenced by Bitset::Bitset(), Bitset::insert(), and Bitset::project().

Bitset::iterator insert ( iterator  position,
const value_type &  x 
) [inline]

Insert an element into the set.

Definition at line 245 of file bitset.hxx.

References Bitset::insert().

void insert ( InputIterator  first,
InputIterator  last 
) [inline]

Insert an element into the set.

Definition at line 252 of file bitset.hxx.

References Bitset::insert().

void erase ( iterator  position  )  [inline]

Erase an element from the set.

Definition at line 267 of file bitset.hxx.

Referenced by Bitset::erase().

Bitset::size_type erase ( const key_type &  x  )  [inline]

Erase an element from the set.

Definition at line 276 of file bitset.hxx.

References Bitset::get_bit(), Bitset::get_bitnum(), and Bitset::get_index().

void erase ( iterator  first,
iterator  last 
) [inline]

Erase an element from the set.

Definition at line 296 of file bitset.hxx.

References Bitset::erase().

Bitset unproject ( const Bitset b  )  const [inline]

Inverse function of project.

S.project (T).unproject (T) == S cap T

See also:
project ()

Definition at line 558 of file bitset.hxx.

References Bitset::bit_begin(), Bitset::bit_end(), Bitset::do_on_bit(), Bitset::get_bit(), and Bitset::max_size().

bool do_on_bit ( BitAction &  action,
const key_type &  x 
) [inline, protected]

Perform an action onto the bit corresponding to an element.

Definition at line 796 of file bitset.hxx.

References Bitset::get_bit(), Bitset::get_bitnum(), and Bitset::get_index().

Referenced by Bitset::compute_size(), Bitset::project(), and Bitset::unproject().

bool do_on_bit ( BitAction &  action,
const bit_iterator &  it 
) [inline, protected]

Perform an action onto the bit corresponding to an element.

Definition at line 808 of file bitset.hxx.

References Bitset::get_bit().

bool do_on_bit ( ConstBitAction &  action,
const key_type &  x 
) const [inline, protected]

Perform an action onto the bit corresponding to an element, const.

Definition at line 816 of file bitset.hxx.

References Bitset::get_bit(), Bitset::get_bitnum(), and Bitset::get_index().

bool do_on_bit ( ConstBitAction &  action,
const bit_iterator &  it 
) const [inline, protected]

Perform an action onto the bit corresponding to an element, const.

Definition at line 828 of file bitset.hxx.

References Bitset::get_bit().


Generated on Thu Jan 22 17:37:16 2009 for Vaucanson by  doxygen 1.5.6