Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

atlas::bitmap::BitMap Class Reference

Container of a large (more than twice the machine word size) set of bits. More...

#include <bitmap.h>

List of all members.

Public Types

typedef unsigned long value_type
typedef value_typereference
typedef const value_typeconst_reference
typedef value_typepointer
typedef const value_typeconst_pointer
typedef ptrdiff_t difference_type
typedef unsigned long size_type
typedef iterator const_iterator

Public Member Functions

iterator begin () const
iterator end () const
 returns the past-the-end iterator for the bitmap.
iterator pos (unsigned long) const
 BitMap ()
 BitMap (unsigned long n)
 Constructs a zero-initialized bitmap with a capacity of n bits.
 BitMap (const BitMap &b)
template<typename I, typename J>
 BitMap (const I &, const I &, const J &, const J &)
 ~BitMap ()
BitMapoperator= (const BitMap &)
bool operator< (const BitMap &b) const
bool operator== (const BitMap &b) const
bool back_up (unsigned long &n) const
unsigned long capacity () const
bool contains (const BitMap &b) const
bool empty () const
unsigned long front () const
bool full () const
bool isMember (unsigned long n) const
unsigned long n_th (unsigned long) const
unsigned long position (unsigned long) const
unsigned long range (unsigned long first, unsigned long number) const
size_type size () const
BitMapoperator~ ()
bool operator &= (const BitMap &)
BitMapoperator|= (const BitMap &)
BitMapoperator^= (const BitMap &)
bool andnot (const BitMap &)
void fill ()
void fill (unsigned long)
void flip (unsigned long n)
void insert (unsigned long n)
void remove (unsigned long n)
void set_to (unsigned long n, bool b)
void set_mod2 (unsigned long n, unsigned long v)
template<typename I>
void insert (const I &, const I &)
iterator insert (iterator, unsigned long n)
void reset ()
void set_capacity (unsigned long n)
void resize (unsigned long n)
void setRange (unsigned long, unsigned long, unsigned long)
void swap (BitMap &)

Private Attributes

std::vector< unsigned long > d_map
unsigned long d_capacity

Static Private Attributes

unsigned long posBits = constants::posBits
unsigned long baseBits = constants::baseBits
unsigned long baseShift = constants::baseShift


Detailed Description

Container of a large (more than twice the machine word size) set of bits.

From the point of view of a user of the class, a BitMap should be seen as a container of _unsigned long_, not bits: these unsigned longs are the addresses of the set bits. When the class is used for example to flag the noncompact roots in a set of roots, it is most convenient to think of it as containing the numbers of the noncompact roots (on a fixed list of all roots). The class obeys the semantics of a Forward Container (from the C++ standard library). Its "size" as a container is the number of unsigned long that it "contains"; that is, the number of set bits in the bitmap.

The basic data is in d_map, a vector of unsigned long integers. Each of these integers is a "chunk" (of size longBits, presumably the machine word length) of the bit map. The capacity (in bits) of the BitMap is d_capacity; the size of the vector d_map is d_capacity/longBits (plus one if there is a remainder in the division).

We wish to provide bit-address access to this map; for this purpose we use the reference trick from vector<bool>. Also we wish to define an iterator class, which traverses the _set_ bits of the bitmap; so that for instance, b.begin() would be a reference to the first set bit. Dereferencing the iterator yields its bit-address.

Definition at line 51 of file bitmap.h.


Member Typedef Documentation

typedef iterator atlas::bitmap::BitMap::const_iterator
 

Definition at line 78 of file bitmap.h.

Referenced by atlas::bitmap::BitMap::iterator::iterator(), n_th(), and size().

typedef const value_type* atlas::bitmap::BitMap::const_pointer
 

Definition at line 72 of file bitmap.h.

typedef const value_type& atlas::bitmap::BitMap::const_reference
 

Definition at line 70 of file bitmap.h.

typedef ptrdiff_t atlas::bitmap::BitMap::difference_type
 

Definition at line 73 of file bitmap.h.

typedef value_type* atlas::bitmap::BitMap::pointer
 

Definition at line 71 of file bitmap.h.

typedef value_type& atlas::bitmap::BitMap::reference
 

Definition at line 69 of file bitmap.h.

typedef unsigned long atlas::bitmap::BitMap::size_type
 

Definition at line 74 of file bitmap.h.

typedef unsigned long atlas::bitmap::BitMap::value_type
 

type for a component of the vector d_map holding the BitMap

Definition at line 68 of file bitmap.h.


Constructor & Destructor Documentation

atlas::bitmap::BitMap::BitMap  )  [inline]
 

Definition at line 84 of file bitmap.h.

atlas::bitmap::BitMap::BitMap unsigned long  n  )  [inline, explicit]
 

Constructs a zero-initialized bitmap with a capacity of n bits.

Notice that the size of the vector |d_map| exceeds |n >> baseShift| by one unless |longBits| exactly divides |n|.

Definition at line 92 of file bitmap.h.

References atlas::constants::baseShift, and atlas::constants::posBits.

atlas::bitmap::BitMap::BitMap const BitMap b  )  [inline]
 

Definition at line 96 of file bitmap.h.

template<typename I, typename J>
atlas::bitmap::BitMap::BitMap const I &  first,
const I &  last,
const J &  fsub,
const J &  lsub
 

In this constructor template we assume that I and J are iterator types with the same value_type. The idea is that [first,last[ is an ordered range, for which we can call lower_bound. Then we construct the bitmap which flags the elements from [fsub,lsub[ (not necessarily assumed ordered or in range; I should be random-access, but J can basically be any input iterator.) It is assumed of course that the elements from [fsub,lsub[ will be found in [first,last[.

Definition at line 24 of file bitmap_def.h.

References insert(), and resize().

atlas::bitmap::BitMap::~BitMap  )  [inline]
 

Definition at line 101 of file bitmap.h.


Member Function Documentation

bool atlas::bitmap::BitMap::andnot const BitMap b  ) 
 

Synopsis: takes the current bitmap into its set-difference with |b|, i.e., removes from our bitmap any elements appearing in |b|. Return whether any bits remain in the result.

Definition at line 403 of file bitmap.cpp.

References capacity(), and d_map.

Referenced by atlas::cartanclass::Fiber::compactRoots(), atlas::cartanset::CartanClassSet::extend(), atlas::poset::Poset::findMaximals(), atlas::quotGenerator(), atlas::abelian::quotReps(), atlas::setCycGenerator(), and atlas::updateCycGenerator().

bool atlas::bitmap::BitMap::back_up unsigned long &  n  )  const
 

Synopsis: decrements |n| until it points to a member of the bitset, or if none is found returns |false| (in which case |n| is unchanged)

Definition at line 133 of file bitmap.cpp.

References d_map, and atlas::bits::lastBit().

Referenced by atlas::poset::Poset::findMaximals().

BitMap::iterator atlas::bitmap::BitMap::begin  )  const
 

Returns an iterator pointing to the first set bit in the bitmap.

If the bitset is empty, this is will be equal to |end()|.

Definition at line 100 of file bitmap.cpp.

References front(), and pos().

Referenced by atlas::graph::OrientedGraph::addLinks(), atlas::interactive::bitMapPrompt(), atlas::cartanset::CartanClassSet::block_size(), atlas::abelian::coset(), atlas::testrun::CoveringIterator::CoveringIterator(), atlas::abelian::cycGenerators(), atlas::cartanset::CartanClassSet::extend(), atlas::kgb::FiberData::FiberData(), atlas::abelian::generators(), atlas::poset::Poset::hasseDiagram(), atlas::cartanset::CartanClassSet::KGB_size(), atlas::kl::KLContext::makeExtremalRow(), atlas::kl::KLContext::makePrimitiveRow(), atlas::poset::Poset::minima(), atlas::cartanset::CartanClassSet::numInvolutions(), atlas::orthogonalMAlpha(), atlas::prettyprint::prettyPrint(), atlas::kl::KLContext::primMap(), atlas::realredgp_io::printCartanClasses(), atlas::prettyprint::printInRootBasis(), atlas::quotGenerator(), atlas::abelian::quotReps(), atlas::testrun::TorusPartIterator::reset(), atlas::testrun::SubgroupIterator::resetGenerator(), atlas::rootdata::rootBasis(), atlas::rootdata::RootDatum::simpleBasis(), atlas::small_dual_kgb_f(), atlas::small_kgb_f(), atlas::cartanclass::toMostSplit(), and atlas::rootdata::RootDatum::twoRho().

unsigned long atlas::bitmap::BitMap::capacity  )  const [inline]
 

Number of bits in use in the bitmap. This is the capacity of the BitMap as a standard library container, not d_map.size(), which is approximately longBits times smaller.

Definition at line 124 of file bitmap.h.

Referenced by andnot(), atlas::poset::Poset::findMaximals(), operator &=(), operator^=(), operator|=(), atlas::prettyprint::prettyPrint(), and atlas::filekl::write_KL_row().

bool atlas::bitmap::BitMap::contains const BitMap b  )  const
 

Tells whether the current bitmap contains |b|. It is assumed that |b.capacity()<=capacity()|.

This would amount to |b.andnot(*this).empty()| if |b| were by-value rather than reference, and if capacities were equal.

Definition at line 147 of file bitmap.cpp.

bool atlas::bitmap::BitMap::empty  )  const
 

Tells whether the bitmap is empty. Thanks to our convention of zeroing unused bits, it is enough to check whether all the components of d_map are zero.

Definition at line 173 of file bitmap.cpp.

References d_map.

Referenced by atlas::setCycGenerator(), and atlas::cartanclass::toMostSplit().

BitMap::iterator atlas::bitmap::BitMap::end  )  const
 

returns the past-the-end iterator for the bitmap.

Note that only the middle argument |d_capacity| is of any importance, since the only thing one can meaningfully do with end() is test for (in)equality. The operator |++| below does not in fact advance to |d_chunk==d_map.end()|!

Definition at line 112 of file bitmap.cpp.

References d_map.

Referenced by atlas::graph::OrientedGraph::addLinks(), atlas::interactive::bitMapPrompt(), atlas::abelian::coset(), atlas::testrun::CoveringIterator::CoveringIterator(), atlas::abelian::cycGenerators(), atlas::abelian::generators(), atlas::testrun::SubgroupIterator::incrementGenerator(), atlas::kl::KLContext::makeExtremalRow(), atlas::kl::KLContext::makePrimitiveRow(), atlas::testrun::SubgroupIterator::operator++(), atlas::orthogonalMAlpha(), atlas::poset::Poset::Poset(), atlas::prettyprint::prettyPrint(), atlas::quotGenerator(), atlas::abelian::quotReps(), atlas::testrun::TorusPartIterator::reset(), atlas::setCycGenerator(), atlas::small_dual_kgb_f(), and atlas::small_kgb_f().

void atlas::bitmap::BitMap::fill unsigned long  n  ) 
 

Synopsis: sets all the bits in position < n, AND clears all later bits

Equivalent to |fill()| if |n >= d_capacity|, and to |reset()| if |n=0|.

Definition at line 431 of file bitmap.cpp.

References baseShift, d_map, resize(), and size().

void atlas::bitmap::BitMap::fill  ) 
 

Synopsis: sets all the bits in the bitmap.

As usual we have to be careful to leave the unused bits at the end to zero.

Definition at line 418 of file bitmap.cpp.

References d_capacity, and d_map.

Referenced by atlas::abelian::cycGenerators(), atlas::kgb::KGB::KGB(), atlas::kl::KLContext::makeExtremalRow(), atlas::kl::KLContext::makePrimitiveRow(), atlas::kl::KLContext::primMap(), and atlas::abelian::quotReps().

void atlas::bitmap::BitMap::flip unsigned long  n  )  [inline]
 

Definition at line 172 of file bitmap.h.

Referenced by atlas::gradings::gradingType(), and atlas::cartanclass::toMostSplit().

unsigned long atlas::bitmap::BitMap::front  )  const
 

Synopsis: returns the address of the first member (set bit) of the bitmap, or past-the-end indicator |d_capacity| if there is no such.

Definition at line 187 of file bitmap.cpp.

References d_map, and atlas::bits::firstBit().

Referenced by begin(), atlas::gradings::gradingType(), and atlas::cartanclass::toMostSplit().

bool atlas::bitmap::BitMap::full  )  const
 

Tells whether the bitmap is full. This means that all blocks are full, except maybe for the last one where we have to look only at the significant part.

Definition at line 204 of file bitmap.cpp.

References d_capacity, and d_map.

BitMap::iterator atlas::bitmap::BitMap::insert iterator  ,
unsigned long  n
 

Definition at line 441 of file bitmap.cpp.

References d_map.

template<typename I>
void atlas::bitmap::BitMap::insert const I &  first,
const I &  last
 

Here we assume that I is an iterator whose value_type is unsigned long, and we do the sequence of insertions from the range [first,last[.

Definition at line 43 of file bitmap_def.h.

References insert().

void atlas::bitmap::BitMap::insert unsigned long  n  )  [inline]
 

Puts a 1 in position n of the bitmap (that is, inserts an element of the set).

Definition at line 179 of file bitmap.h.

Referenced by atlas::graph::OrientedGraph::addLinks(), BitMap(), atlas::abelian::coset(), atlas::poset::Poset::extend(), atlas::gradings::findGrading(), atlas::gradings::gradingType(), atlas::poset::Poset::hasseDiagram(), atlas::testrun::SubgroupIterator::incrementGenerator(), insert(), atlas::cartanclass::InvolutionData::InvolutionData(), atlas::kl::KLContext::makeExtremalRow(), atlas::kl::KLContext::makePrimitiveRow(), atlas::poset::n_comparable_from_Hasse(), atlas::kl::helper::ThicketIterator::operator++(), atlas::poset::Poset::Poset(), atlas::kl::KLContext::primMap(), atlas::rootdata::RootDatum::RootDatum(), atlas::setCycGenerator(), atlas::rootdata::RootDatum::simpleBasis(), atlas::poset::SymmetricPoset::SymmetricPoset(), atlas::kl::helper::ThicketIterator::ThicketIterator(), atlas::cartanset::CartanClassSet::updateStatus(), and atlas::cartanset::CartanClassSet::updateSupports().

bool atlas::bitmap::BitMap::isMember unsigned long  n  )  const [inline]
 

Tests whether bit n in the bitmap is set; that is, whether element n is a member of the set.

Definition at line 140 of file bitmap.h.

Referenced by atlas::cartanset::CartanClassSet::correlateDualForms(), atlas::cartanset::CartanClassSet::correlateForms(), atlas::interpreter::dual_occurrence_matrix_wrapper(), atlas::cartanset::CartanClassSet::extend(), atlas::kgb::KGBHelp::is_compact(), atlas::rootdata::RootDatum::isPosRoot(), atlas::rootdata::RootDatum::isSimpleRoot(), atlas::interpreter::occurrence_matrix_wrapper(), atlas::kl::helper::ThicketIterator::operator++(), atlas::prettyprint::prettyPrint(), atlas::poset_io::printSymmetricPoset(), and atlas::cartanclass::restrictGrading().

unsigned long atlas::bitmap::BitMap::n_th unsigned long  i  )  const
 

Synopsis: returns the index of set bit number i in the bitset; in other words, viewing a bitset b as a container of unsigned long, b.n_th(i) is the value of the element i of b, and the syntax b[i] would have been logical (as usual, the first element is number 0). This returns d_capacity if there is no such element, in other words if at most i bits are set in the bitmap. The condition b.position(b.n_th(i))==i holds whenever 0<=i<=size().

Definition at line 222 of file bitmap.cpp.

References atlas::bits::bitCount(), const_iterator, and atlas::bits::firstBit().

Referenced by atlas::interpreter::Cartan_class_wrapper().

bool atlas::bitmap::BitMap::operator &= const BitMap b  ) 
 

Synopsis: intersects the current bitmap with |b|, return value tells whether the result is non-empty.

Definition at line 360 of file bitmap.cpp.

References capacity(), d_map, and size().

bool atlas::bitmap::BitMap::operator< const BitMap b  )  const [inline]
 

Definition at line 107 of file bitmap.h.

References d_map.

BitMap & atlas::bitmap::BitMap::operator= const BitMap  ) 
 

Definition at line 84 of file bitmap.cpp.

References d_capacity, and d_map.

bool atlas::bitmap::BitMap::operator== const BitMap b  )  const [inline]
 

Definition at line 111 of file bitmap.h.

References d_map.

BitMap & atlas::bitmap::BitMap::operator^= const BitMap b  ) 
 

Synopsis: xor's |b| into the current bitmap.

Definition at line 389 of file bitmap.cpp.

References capacity(), d_map, and size().

BitMap & atlas::bitmap::BitMap::operator|= const BitMap b  ) 
 

Synopsis: unites |b| into the current bitmap.

Definition at line 377 of file bitmap.cpp.

References capacity(), d_map, and size().

BitMap & atlas::bitmap::BitMap::operator~  ) 
 

Synopsis: transforms the bitmap into its bitwise complement at returns itself

NOTE: one has to be careful about the last chunk, resetting the unused bits to zero.

NOTE: the naming of this manipulator is dangerous, as the user might write something like |a &= ~b| and be surprised by the fact that |b| changes value. Incidentally, for that special case there is |a.andnot(b)|.

Definition at line 344 of file bitmap.cpp.

References d_capacity, and d_map.

BitMap::iterator atlas::bitmap::BitMap::pos unsigned long  n  )  const
 

Synopsis: returns an iterator with bit-address n.

Definition at line 120 of file bitmap.cpp.

References d_map.

Referenced by begin(), atlas::testrun::CoveringIterator::CoveringIterator(), and atlas::testrun::SubgroupIterator::operator=().

unsigned long atlas::bitmap::BitMap::position unsigned long  n  )  const
 

Synopsis: returns the number of set bits in positions < n; viewing a bitset b as a container of unsigned long, this is the number of values < n that b contains. If n itself is a member of b, then n==b.n_th(b.position(n)).

Definition at line 275 of file bitmap.cpp.

References atlas::bits::bitCount(), d_map, and posBits.

unsigned long atlas::bitmap::BitMap::range unsigned long  n,
unsigned long  r
const
 

Synopsis: returns r bits from position n.

Precondition: r divides longBits, and n is a multiple of r.

Thus the bits extracted are found in single element of d_map, and such elements define an integral number of disjoint ranges

It is required that |n<capacity()|, but not that |n+r<=capacity()|; if the latter fails, the return value is padded out with (leading) zero bits.

Definition at line 301 of file bitmap.cpp.

References d_map, and atlas::constants::lMask.

Referenced by atlas::filekl::write_KL_row().

void atlas::bitmap::BitMap::remove unsigned long  n  )  [inline]
 

Puts a 0 in position n of the bitmap (that is, removes an element of the set).

Definition at line 187 of file bitmap.h.

Referenced by atlas::graph::OrientedGraph::addLinks(), atlas::abelian::cycGenerators(), atlas::gradings::gradingType(), and atlas::cartanclass::toMostSplit().

void atlas::bitmap::BitMap::reset  )  [inline]
 

Definition at line 207 of file bitmap.h.

Referenced by atlas::abelian::coset().

void atlas::bitmap::BitMap::resize unsigned long  n  )  [inline]
 

Definition at line 213 of file bitmap.h.

Referenced by BitMap(), fill(), atlas::firstType(), set_capacity(), and atlas::shape().

void atlas::bitmap::BitMap::set_capacity unsigned long  n  ) 
 

Synopsis: sets the capacity of the bitmap to n.

Does not modify the contents up to the previous size, at least if n is larger. The new elements are initialized to zero.

Definition at line 455 of file bitmap.cpp.

References baseShift, d_capacity, d_map, atlas::constants::posBits, posBits, and resize().

Referenced by atlas::testrun::CoveringIterator::CoveringIterator(), atlas::abelian::cycGenerators(), atlas::poset::n_comparable_from_Hasse(), atlas::poset::Poset::Poset(), atlas::rootdata::RootDatum::RootDatum(), atlas::kl::helper::ThicketIterator::ThicketIterator(), and atlas::cartanset::CartanClassSet::updateSupports().

void atlas::bitmap::BitMap::set_mod2 unsigned long  n,
unsigned long  v
[inline]
 

Definition at line 195 of file bitmap.h.

void atlas::bitmap::BitMap::set_to unsigned long  n,
bool  b
[inline]
 

Definition at line 191 of file bitmap.h.

void atlas::bitmap::BitMap::setRange unsigned long  n,
unsigned long  r,
unsigned long  a
 

Synopsis: sets r bits from position n to the first r bits in a.

Precondition: r divides longBits, and n is aligned (i.e., n is a multiple of r).

In this way, we are sure that things happen inside a single word in d_map.

Definition at line 472 of file bitmap.cpp.

References d_map, and atlas::constants::lMask.

Referenced by combine_rows().

unsigned long atlas::bitmap::BitMap::size  )  const
 

Returns the number of set bits in the bitmap (this is its size as a container of unsigned long.)

NOTE: correctness depends on unused bits in the final word being cleared.

Definition at line 319 of file bitmap.cpp.

References atlas::bits::bitCount(), const_iterator, and d_map.

Referenced by atlas::graph::OrientedGraph::addLinks(), combine_rows(), fill(), atlas::rootdata::RootDatum::isRoot(), atlas::kgb::KGB::KGB(), atlas::kl::KLContext::makeExtremalRow(), atlas::kl::KLContext::makePrimitiveRow(), atlas::poset::n_comparable_from_Hasse(), atlas::nextInShape(), atlas::nextShape(), atlas::realredgp::RealReductiveGroup::numCartan(), atlas::cartanset::CartanClassSet::numCartan(), atlas::rootdata::RootDatum::numPosRoots(), atlas::rootdata::RootDatum::numRoots(), operator &=(), operator^=(), operator|=(), atlas::kl::KLContext::primMap(), atlas::rGenerators(), atlas::blocks::Block::size(), and atlas::filekl::write_KL_row().

void atlas::bitmap::BitMap::swap BitMap  ) 
 

Definition at line 482 of file bitmap.cpp.

References d_capacity, and d_map.

Referenced by atlas::cartanset::CartanClassSet::extend(), atlas::abelian::generateSubgroup(), atlas::gradings::gradingType(), atlas::rootdata::RootDatum::swap(), atlas::cartanclass::Fiber::swap(), atlas::cartanclass::InvolutionData::swap(), and atlas::cartanset::CartanClassSet::updateTwistedInvolutions().


Member Data Documentation

unsigned long atlas::bitmap::BitMap::baseBits = constants::baseBits [static, private]
 

Constant used to pick a bit-address apart: this is the logical complement of posBits, and masks the word-address within a BitMap index (which still must be shifted right by baseShift to be interpreted correctly, whence this constant is actually little used).

It is assumed that the number of bits in an unsigned long is a power of two.

Definition at line 59 of file bitmap.cpp.

unsigned long atlas::bitmap::BitMap::baseShift = constants::baseShift [static, private]
 

Constant saying how much we have to shift the BitMap index n of a bit (that is, the power of two by which it much be divided) to get the index of the d_map element that contains this bit (it is the number of set bits in posBits, typically 5 or 6).

Definition at line 67 of file bitmap.cpp.

Referenced by fill(), and set_capacity().

unsigned long atlas::bitmap::BitMap::d_capacity [private]
 

Definition at line 56 of file bitmap.h.

Referenced by fill(), full(), operator=(), operator~(), set_capacity(), and swap().

std::vector<unsigned long> atlas::bitmap::BitMap::d_map [private]
 

Definition at line 55 of file bitmap.h.

Referenced by andnot(), back_up(), empty(), end(), fill(), front(), full(), insert(), operator &=(), operator<(), operator=(), operator==(), operator^=(), operator|=(), operator~(), pos(), position(), range(), set_capacity(), setRange(), size(), and swap().

unsigned long atlas::bitmap::BitMap::posBits = constants::posBits [static, private]
 

Definition at line 49 of file bitmap.cpp.

Referenced by position(), and set_capacity().


The documentation for this class was generated from the following files:
Generated on Wed Mar 26 16:52:18 2008 for atlas by  doxygen 1.3.9.1