Dv::Util::Bitmap Class Reference

A simple Bitmap class. More...

#include <bitmap.h>

List of all members.

Public Types

typedef size_t Chunk

Public Member Functions

 Bitmap (size_t n_bits, bool initial_value)
 Constructor.
 ~Bitmap ()
 Destructor.
bool get (size_t i) const
 Retrieve the i'th bit of a map.
void set (size_t i) throw (std::range_error)
 Set the i'th bit of a map.
void clear (size_t i) throw (std::range_error)
 Clear the i'th bit of a map.
bool operator[] (size_t i) const throw (std::range_error)
 Retrieve the i'th bit of a map.
size_t size () const
size_t n_chunks () const
std::ostream & print (std::ostream &os) const
 Print the map on a stream, as a string of 0's and 1's.

Private Attributes

size_t size_
Chunkdata_

Detailed Description

A simple Bitmap class.

Warning:
This code relies on '1' being represented by a Chunk containing exactly one non-zero rightmost bit and '0' being represented by a Chunk containing only zero bits.

Definition at line 16 of file bitmap.h.


Member Typedef Documentation

typedef size_t Dv::Util::Bitmap::Chunk

Definition at line 18 of file bitmap.h.


Constructor & Destructor Documentation

Dv::Util::Bitmap::Bitmap ( size_t  n_bits,
bool  initial_value 
) [inline]

Constructor.

Parameters:
n_bits size of the map in bits
initial_value that will be used to initialize all the bits

Definition at line 24 of file bitmap.h.

References data_, and n_chunks().

Dv::Util::Bitmap::~Bitmap (  )  [inline]

Destructor.

Definition at line 30 of file bitmap.h.

References data_.


Member Function Documentation

bool Dv::Util::Bitmap::get ( size_t  i  )  const [inline]

Retrieve the i'th bit of a map.

Parameters:
i index of bit to retrieve.
Returns:
value of i'th bit in map.
Warning:
no checking of the index

Definition at line 39 of file bitmap.h.

References data_.

void Dv::Util::Bitmap::set ( size_t  i  )  throw (std::range_error) [inline]

Set the i'th bit of a map.

Parameters:
i index of bit to retrieve.
Exceptions:
std::range_error if index is out of range

Definition at line 49 of file bitmap.h.

References data_, and size().

void Dv::Util::Bitmap::clear ( size_t  i  )  throw (std::range_error) [inline]

Clear the i'th bit of a map.

Parameters:
i index of bit to clear.
Exceptions:
std::range_error if index is out of range

Definition at line 61 of file bitmap.h.

References data_, and size().

bool Dv::Util::Bitmap::operator[] ( size_t  i  )  const throw (std::range_error) [inline]

Retrieve the i'th bit of a map.

Parameters:
i index of bit to retrieve.
Returns:
value of i'th bit in map.
Exceptions:
std::range_error if index is out of range

Definition at line 74 of file bitmap.h.

References size().

size_t Dv::Util::Bitmap::size (  )  const [inline]
Returns:
the size (in bits) of the map.

Definition at line 81 of file bitmap.h.

References size_.

Referenced by clear(), n_chunks(), operator[](), print(), and set().

size_t Dv::Util::Bitmap::n_chunks (  )  const [inline]
Returns:
the size (in chunks) of the map.

Definition at line 83 of file bitmap.h.

References size().

Referenced by Bitmap().

std::ostream& Dv::Util::Bitmap::print ( std::ostream &  os  )  const [inline]

Print the map on a stream, as a string of 0's and 1's.

Parameters:
os stream to print on
Returns:
os Example output:
 0100111

Definition at line 93 of file bitmap.h.

References size().

Referenced by Dv::Util::operator<<().


Member Data Documentation

size_t Dv::Util::Bitmap::size_ [private]

Definition at line 99 of file bitmap.h.

Referenced by size().

Definition at line 100 of file bitmap.h.

Referenced by Bitmap(), clear(), get(), set(), and ~Bitmap().


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

dvutil-1.0.10 [ 5 December, 2009]