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

atlas::bitset::BitSet< n > Class Template Reference

Set of n bits. More...

#include <bitset.h>

Inheritance diagram for atlas::bitset::BitSet< n >:

Inheritance graph
[legend]
Collaboration diagram for atlas::bitset::BitSet< n >:

Collaboration graph
[legend]
List of all members.

Public Types

typedef Base::iterator iterator
typedef iterator const_iterator

Public Member Functions

 BitSet ()
 BitSet (unsigned long b)
 ~BitSet ()
template<size_t m>
 BitSet (const BitSet< m > &b)
template<size_t m>
BitSetoperator= (const BitSet< m > &b)
bool operator== (const BitSet &b) const
bool operator!= (const BitSet &b) const
bool operator< (const BitSet &b) const
bool operator[] (size_t j) const
BitSet operator & (const BitSet &b) const
BitSet operator| (const BitSet &b) const
BitSet operator^ (const BitSet &b) const
bool any () const
 Tests whether BitSet is nonempty.
bool any (const BitSet &b) const
 Tests whether BitSet and b have non-empty intersection.
iterator begin () const
bool contains (const BitSet &b) const
 Tests whether BitSet contains b.
size_t count () const
 Number of set bits in BitSet.
size_t firstBit () const
 Position of the first set bit in BitSet.
size_t lastBit () const
 position of the last set bit in BitSet.
bool none () const
 Tests whether the corresponding set is empty.
size_t position (size_t j) const
 Number of set bits in position < j.
bool scalarProduct (const BitSet &b) const
size_t size () const
bool test (size_t j) const
 Tests bit j of BitSet.
unsigned long to_ulong () const
 The first wordlength bits of BitSet, interpreted as an unsigned long integer.
unsigned long to_ulong1 () const
 The second wordlength bits of BitSet, interpreted as an unsigned long integer.
BitSetoperator^= (const BitSet &b)
BitSetoperator|= (const BitSet &b)
BitSetoperator &= (const BitSet &b)
BitSetoperator<<= (size_t c)
BitSetoperator>>= (size_t c)
BitSetandnot (const BitSet &b)
BitSetflip ()
BitSetflip (size_t j)
BitSetpermute (const setutils::Permutation &a)
 Applies the permutation a to the BitSet.
BitSetreset ()
 Sets every bit of BitSet to zero. (Empties the set.).
BitSetreset (size_t j)
BitSetset ()
 Sets the first n bits of BitSet to one. (Fills the set.).
BitSetset (size_t j)
BitSetset (size_t j, bool b)
BitSetslice (const BitSet &c)
 Replaces the bitset by the "defragmented" intersection with c (i.e., the bits of that intersection are written consecutively.).
void swap (BitSet &source)
BitSettruncate (size_t m)
 Sets all bits after m to zero.

Private Types

typedef BitSetBase< BaseSize<
n >::value
Base
 Class from which BitSet<n> is derived.

Detailed Description

template<size_t n>
class atlas::bitset::BitSet< n >

Set of n bits.

The software formally allows for n between 0 and four times the machine word length; now up to two times the machine word length is implemented.

The BitSet class has essentially the functionality of the bitset class from the STL, but I have redone it because I needed some things that bitset doesn't seem to provide. This is a very important data type for the program, and it is crucial that it should be efficiently implemented.

The main difference is that _all_ my BitSets are fixed size; they are provided for up to 128 bits on 32-bit machines, 256 bits on 64-bit machines. So the intention is to use them for small bitmaps. This allows for optimal speed, at the cost of some code duplication (but almost all the functions in the class are easily inlined.) [In fact BitSets of size more than twice the word length are not fully implemented in the present software. The gap is that BitSet<n> calls on BitSetBase<m>, where m is the smallest integer greater than or equal to n/longBits. (The size m is computed from n by the function BaseSize::value.) The class BitSetBase<m> is actually implemented only for m = 1, 2. DV]

Just as for the implementation of bitset in the STL that I took as a model, the size is rounded of to multiples of the number of bits in an unsigned long, so that in effect there are only four instances of the BitSetBase to provide (or five, counting the 0-size BitSet.)

The main difference with the STL is the to_ulong() method; mine will truncate the bitset when the number of bits is too long, instead of throwing an exception.

Although I had implemented bit-references, and even though it is an interesting C++ trick that shows to what extent you can twist the notation to do what you want, I dismissed it now as syntactic sugar. Use b.set(i,value) instead of b[i] = value. Operator[] is now defined only as an access operator, equivalent to test().

The output operator is in io/ioutils.h.

The first typedef defines Base to be BitSetBase<m>. Consequently function references of the form Base::contains refer to BitSetBase<m>::contains. [DV doesn't know whether this could have been avoided by replacing ":private BitSetBase" by ":public BitSetBase" in the template for BitSet, and just invoking the (public) member functions of the base class directly. MvL thinks that that would be possible; this depends on the fact (also used in the actual implementation below) that the argument of 'contains' is implicitly converted to its base class BitSetBase<m> because the method of the base class requires this. However, this would expose _all_ public methods of BitSetBase to users of BitSet, which is not desired. This could however be remedied by making protected rather than public the methods of BitSetBase that are only for internal use by BitSet implementations.]

Definition at line 826 of file bitset.h.


Member Typedef Documentation

template<size_t n>
typedef BitSetBase<BaseSize<n>::value> atlas::bitset::BitSet< n >::Base [private]
 

Class from which BitSet<n> is derived.

Definition at line 833 of file bitset.h.

template<size_t n>
typedef iterator atlas::bitset::BitSet< n >::const_iterator
 

Definition at line 839 of file bitset.h.

template<size_t n>
typedef Base::iterator atlas::bitset::BitSet< n >::iterator
 

Definition at line 838 of file bitset.h.


Constructor & Destructor Documentation

template<size_t n>
atlas::bitset::BitSet< n >::BitSet  )  [inline]
 

Definition at line 842 of file bitset.h.

template<size_t n>
atlas::bitset::BitSet< n >::BitSet unsigned long  b  )  [inline, explicit]
 

Definition at line 844 of file bitset.h.

template<size_t n>
atlas::bitset::BitSet< n >::~BitSet  )  [inline]
 

Definition at line 846 of file bitset.h.

template<size_t n>
template<size_t m>
atlas::bitset::BitSet< n >::BitSet const BitSet< m > &  b  )  [inline]
 

Copy from other size BitSets is by truncation or extension by zero.

Definition at line 851 of file bitset.h.


Member Function Documentation

template<size_t n>
BitSet& atlas::bitset::BitSet< n >::andnot const BitSet< n > &  b  )  [inline]
 

Performs a bitwise "and not" of this BitSet with the argument BitSet b (which remains unchanged).

Definition at line 1032 of file bitset.h.

Referenced by atlas::dynkin::DynkinDiagram::component(), atlas::kl::helper::Helper::lengthOneMu(), and atlas::cartanclass::CartanClass::makeSimpleComplex().

template<size_t n>
bool atlas::bitset::BitSet< n >::any const BitSet< n > &  b  )  const [inline]
 

Tests whether BitSet and b have non-empty intersection.

Returns whether any bit is 1 in both BitSet and b.

Definition at line 906 of file bitset.h.

template<size_t n>
bool atlas::bitset::BitSet< n >::any  )  const [inline]
 

Tests whether BitSet is nonempty.

Returns whether any bit of the BitSet is 1

Definition at line 897 of file bitset.h.

Referenced by atlas::dynkin::DynkinDiagram::component(), atlas::cartanclass::CartanClass::isMostSplit(), atlas::kl::helper::Helper::lengthOneMu(), and atlas::bitvector::BitVector< dim >::nonZero().

template<size_t n>
iterator atlas::bitset::BitSet< n >::begin  )  const [inline]
 

Iterator pointing to the first set bit of BitSet.

Seems not yet to be implemented for BitSetBase<2>.

Definition at line 915 of file bitset.h.

Referenced by atlas::rootdata::RootDatum::beginCoradical(), atlas::rootdata::RootDatum::beginCoroot(), atlas::rootdata::RootDatum::beginRadical(), atlas::rootdata::RootDatum::beginRoot(), atlas::cartanset::CartanClassSet::canonicalize(), atlas::dynkin::DynkinDiagram::DynkinDiagram(), atlas::bitvector::BitMatrix< dim >::kernel(), atlas::cartanclass::Fiber::makeFiberMap(), atlas::cartanclass::Fiber::makeGradingShifts(), atlas::cartanclass::CartanClass::makeSimpleComplex(), atlas::typeDNormalize(), and atlas::bitvector::BitVector< dim >::unslice().

template<size_t n>
bool atlas::bitset::BitSet< n >::contains const BitSet< n > &  b  )  const [inline]
 

Tests whether BitSet contains b.

Definition at line 922 of file bitset.h.

Referenced by atlas::wgraph::wGraph().

template<size_t n>
size_t atlas::bitset::BitSet< n >::count  )  const [inline]
 

Number of set bits in BitSet.

This is the cardinality of the corresponding set.

Definition at line 931 of file bitset.h.

Referenced by atlas::bitvector::BitVector< dim >::count(), atlas::dynkin::DynkinDiagram::DynkinDiagram(), atlas::gradings::GradingCompare::operator()(), and atlas::printSimpleType().

template<size_t n>
size_t atlas::bitset::BitSet< n >::firstBit  )  const [inline]
 

Position of the first set bit in BitSet.

Returns the capacity of the BitSet if there is no such bit.

Definition at line 940 of file bitset.h.

Referenced by atlas::interpreter::check_involution(), atlas::bitvector::BitVector< dim >::firstBit(), atlas::kl::helper::Helper::lengthOneMu(), atlas::kgb::makeHasse(), atlas::klsupport::KLSupport::primitivize(), and atlas::printSimpleType().

template<size_t n>
BitSet& atlas::bitset::BitSet< n >::flip size_t  j  )  [inline]
 

Definition at line 1043 of file bitset.h.

template<size_t n>
BitSet& atlas::bitset::BitSet< n >::flip  )  [inline]
 

Definition at line 1037 of file bitset.h.

Referenced by atlas::compactEquations(), atlas::bitvector::BitVector< dim >::flip(), atlas::bitset::operator~(), and atlas::cartanset::transformGrading().

template<size_t n>
size_t atlas::bitset::BitSet< n >::lastBit  )  const [inline]
 

position of the last set bit in BitSet.

Returns 0 if there is no such bit.

Definition at line 949 of file bitset.h.

template<size_t n>
bool atlas::bitset::BitSet< n >::none  )  const [inline]
 

Tests whether the corresponding set is empty.

Returns 1 if no bit of BitSet is set, and 0 otherwise.

Definition at line 958 of file bitset.h.

Referenced by atlas::cartanclass::CartanClass::isMostSplit(), atlas::bitvector::BitVector< dim >::isZero(), and atlas::kgb::makeHasse().

template<size_t n>
BitSet atlas::bitset::BitSet< n >::operator & const BitSet< n > &  b  )  const [inline]
 

Definition at line 884 of file bitset.h.

template<size_t n>
BitSet& atlas::bitset::BitSet< n >::operator &= const BitSet< n > &  b  )  [inline]
 

Definition at line 1014 of file bitset.h.

template<size_t n>
bool atlas::bitset::BitSet< n >::operator!= const BitSet< n > &  b  )  const [inline]
 

Definition at line 871 of file bitset.h.

template<size_t n>
bool atlas::bitset::BitSet< n >::operator< const BitSet< n > &  b  )  const [inline]
 

Definition at line 875 of file bitset.h.

template<size_t n>
BitSet& atlas::bitset::BitSet< n >::operator<<= size_t  c  )  [inline]
 

Definition at line 1019 of file bitset.h.

template<size_t n>
template<size_t m>
BitSet& atlas::bitset::BitSet< n >::operator= const BitSet< m > &  b  )  [inline]
 

Assignment from other size BitSets is by truncation or extension by zero.

Definition at line 859 of file bitset.h.

template<size_t n>
bool atlas::bitset::BitSet< n >::operator== const BitSet< n > &  b  )  const [inline]
 

Definition at line 867 of file bitset.h.

template<size_t n>
BitSet& atlas::bitset::BitSet< n >::operator>>= size_t  c  )  [inline]
 

Definition at line 1024 of file bitset.h.

template<size_t n>
bool atlas::bitset::BitSet< n >::operator[] size_t  j  )  const [inline]
 

Definition at line 879 of file bitset.h.

template<size_t n>
BitSet atlas::bitset::BitSet< n >::operator^ const BitSet< n > &  b  )  const [inline]
 

Definition at line 888 of file bitset.h.

template<size_t n>
BitSet& atlas::bitset::BitSet< n >::operator^= const BitSet< n > &  b  )  [inline]
 

Definition at line 1004 of file bitset.h.

template<size_t n>
BitSet atlas::bitset::BitSet< n >::operator| const BitSet< n > &  b  )  const [inline]
 

Definition at line 886 of file bitset.h.

template<size_t n>
BitSet& atlas::bitset::BitSet< n >::operator|= const BitSet< n > &  b  )  [inline]
 

Definition at line 1009 of file bitset.h.

template<size_t n>
BitSet& atlas::bitset::BitSet< n >::permute const setutils::Permutation a  )  [inline]
 

Applies the permutation a to the BitSet.

Definition at line 1051 of file bitset.h.

Referenced by atlas::interpreter::print_gradings_wrapper(), and atlas::cartan_io::printGradings().

template<size_t n>
size_t atlas::bitset::BitSet< n >::position size_t  j  )  const [inline]
 

Number of set bits in position < j.

If j is set, this is the position of j in the set of set bits.

Definition at line 967 of file bitset.h.

Referenced by atlas::dynkin::DynkinDiagram::DynkinDiagram().

template<size_t n>
BitSet& atlas::bitset::BitSet< n >::reset size_t  j  )  [inline]
 

Definition at line 1064 of file bitset.h.

template<size_t n>
BitSet& atlas::bitset::BitSet< n >::reset  )  [inline]
 

Sets every bit of BitSet to zero. (Empties the set.).

Definition at line 1059 of file bitset.h.

Referenced by atlas::cartanset::CartanClassSet::canonicalize(), atlas::rootdata::RootDatum::fillStatus(), atlas::bitvector::firstSolution(), atlas::cartanclass::CartanClass::makeSimpleComplex(), atlas::bitvector::normalize(), atlas::bitvector::BitMatrix< constants::RANK_MAX >::reset(), and atlas::bitvector::BitVector< dim >::reset().

template<size_t n>
bool atlas::bitset::BitSet< n >::scalarProduct const BitSet< n > &  b  )  const [inline]
 

Definition at line 971 of file bitset.h.

Referenced by atlas::FiberAction::grading().

template<size_t n>
BitSet& atlas::bitset::BitSet< n >::set size_t  j,
bool  b
[inline]
 

Definition at line 1083 of file bitset.h.

template<size_t n>
BitSet& atlas::bitset::BitSet< n >::set size_t  j  )  [inline]
 

Definition at line 1078 of file bitset.h.

template<size_t n>
BitSet& atlas::bitset::BitSet< n >::set  )  [inline]
 

Sets the first n bits of BitSet to one. (Fills the set.).

Definition at line 1072 of file bitset.h.

Referenced by atlas::bitvector::BitVector< dim >::BitVector(), atlas::blocks::Block::Block(), atlas::cartanset::CartanClassSet::canonicalize(), atlas::cartanset::CartanClassSet::correlateDualForms(), atlas::cartanset::CartanClassSet::correlateForms(), atlas::dynkin::DynkinDiagram::extremities(), atlas::FiberAction::FiberAction(), atlas::klsupport::KLSupport::fill(), atlas::kl::KLContext::fill(), atlas::kgb::KGB::fillBruhat(), atlas::blocks::Block::fillBruhat(), atlas::klsupport::KLSupport::fillDownsets(), atlas::rootdata::RootDatum::fillStatus(), atlas::bitvector::firstSolution(), atlas::kgb::KGBHelp::grading_seed(), atlas::cartanclass::Fiber::makeGradingShifts(), atlas::bitvector::normalize(), atlas::bitvector::BitVector< dim >::pushBack(), atlas::realredgp::RealReductiveGroup::RealReductiveGroup(), atlas::cartanclass::restrictGrading(), atlas::bitset::set(), atlas::bitvector::BitMatrix< constants::RANK_MAX >::set(), atlas::bitvector::BitVector< dim >::set(), atlas::bitvector::BitVector< dim >::slice(), atlas::bitvector::BitVector< dim >::unslice(), and atlas::filekl::write_block_file().

template<size_t n>
size_t atlas::bitset::BitSet< n >::size  )  const [inline]
 

Definition at line 975 of file bitset.h.

Referenced by atlas::interpreter::check_involution(), atlas::bitvector::firstSolution(), atlas::cartanset::makeRepresentative(), atlas::interpreter::print_gradings_wrapper(), and atlas::bitvector::BitMatrix< constants::RANK_MAX >::setColumn().

template<size_t n>
BitSet& atlas::bitset::BitSet< n >::slice const BitSet< n > &  c  )  [inline]
 

Replaces the bitset by the "defragmented" intersection with c (i.e., the bits of that intersection are written consecutively.).

More precisely: if c has m set bits, then the BitSet is replaced by putting in its first m bits the values previously found in the positions flagged by c. The remaining bits are made 0.

This is used for linear algebra, as follows. Suppose a subspace of (Z/2Z)^n is given its unique basis in row-reduced form, and that the leading bits of the basis vectors are flagged by c. (This is how subspaces are represented in the NormalSubspace class.) If the BitVector belongs to this subspace, then applying slice(c) puts in the BitVector its coordinates with respect to the row-reduced basis.

Definition at line 1104 of file bitset.h.

Referenced by atlas::subquotient::Subquotient< dim >::apply(), atlas::dynkin::DynkinDiagram::DynkinDiagram(), and atlas::subquotient::Subquotient< dim >::Subquotient().

template<size_t n>
void atlas::bitset::BitSet< n >::swap BitSet< n > &  source  )  [inline]
 

Definition at line 1109 of file bitset.h.

Referenced by atlas::bitvector::normalize(), atlas::filekl::block_info::prims_for_descents_of(), atlas::subquotient::Subquotient< dim >::swap(), atlas::subquotient::Subspace< dim >::swap(), atlas::rootdata::RootDatum::swap(), atlas::cartanclass::Fiber::swap(), atlas::realform_io::Interface::swap(), atlas::klsupport::KLSupport::swap(), and atlas::kl::KLContext::swap().

template<size_t n>
bool atlas::bitset::BitSet< n >::test size_t  j  )  const [inline]
 

Tests bit j of BitSet.

Definition at line 982 of file bitset.h.

Referenced by atlas::dynkin::DynkinDiagram::DynkinDiagram(), atlas::klsupport::KLSupport::extremalize(), atlas::klsupport::KLSupport::fill(), atlas::kl::KLContext::fill(), atlas::kgb::KGB::fillBruhat(), atlas::blocks::Block::fillBruhat(), atlas::klsupport::KLSupport::fillDownsets(), atlas::GradingAction::operator()(), atlas::prettyprint::prettyPrint(), atlas::klsupport::KLSupport::primitivize(), atlas::block_io::printBlockU(), atlas::block_io::printDescent(), atlas::prettyprint::printDescentSet(), and atlas::subquotient::subquotientMap().

template<size_t n>
unsigned long atlas::bitset::BitSet< n >::to_ulong  )  const [inline]
 

The first wordlength bits of BitSet, interpreted as an unsigned long integer.

Definition at line 990 of file bitset.h.

Referenced by atlas::cartanclass::Fiber::gradingRep(), atlas::tits::TE_Entry::hashCode(), atlas::cartanset::makeRepresentative(), atlas::GradingAction::operator()(), atlas::FiberAction::operator()(), atlas::bitset::BitSetBase< 2 >::operator=(), atlas::bitset::BitSetBase< 1 >::operator=(), atlas::gradings::Status::operator[](), atlas::filekl::block_info::prims_for_descents_of(), atlas::cartanclass::Fiber::toAdjoint(), and atlas::filekl::write_block_file().

template<size_t n>
unsigned long atlas::bitset::BitSet< n >::to_ulong1  )  const [inline]
 

The second wordlength bits of BitSet, interpreted as an unsigned long integer.

Definition at line 998 of file bitset.h.

Referenced by atlas::bitset::BitSetBase< 2 >::operator=().

template<size_t n>
BitSet& atlas::bitset::BitSet< n >::truncate size_t  m  )  [inline]
 

Sets all bits after m to zero.

Definition at line 1116 of file bitset.h.

Referenced by atlas::printType(), and atlas::bitset::set().


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