Otawa  0.10
otawa::dfa::BitSet Class Reference

This class implements a set as a bit vector. More...

#include <otawa/dfa/BitSet.h>

Inheritance diagram for otawa::dfa::BitSet:
otawa::cat::CATDomain otawa::ccg::Domain

Classes

class  Iterator
 Iterator on the item contained in a bit set. More...
 

Public Member Functions

 BitSet (void)
 
 BitSet (int size)
 Build a bitset with the given size. More...
 
 BitSet (const BitSet &set)
 Build a bit set from by copying an existing one. More...
 
 ~BitSet (void)
 
bool isEmpty (void) const
 Test if the bit set is empty. More...
 
bool isFull (void) const
 Test if the bit set contains all existing items. More...
 
void fill (void)
 Fill the bit set with all items. More...
 
void empty (void)
 Remove all items from the bit set. More...
 
bool contains (int index) const
 Test if the bit set contains an item. More...
 
void add (int index)
 Add an item to the bit set. More...
 
void remove (int index)
 Remove an item from the bit set. More...
 
bool equals (const BitSet &set) const
 Test if two bit sets are equals. More...
 
bool includes (const BitSet &set) const
 Test if the current bit set contains the given one. More...
 
bool includesStrictly (const BitSet &set) const
 Test if the current bit set contains strictly the given one, that is, both bit sets are equals. More...
 
void complement (void)
 Complement the current bit set. More...
 
int size (void) const
 
void add (const BitSet &set)
 Add the items of the given bit set to the current one. More...
 
void remove (const BitSet &set)
 Remove the items contained in the given bit set from the current one. More...
 
void mask (const BitSet &set)
 Keep only in this set the items also containted in the given one (performs intersection operation). More...
 
int count (void) const
 
BitSet doComp (void) const
 Compute a bit set complement of the current one. More...
 
BitSet doUnion (const BitSet &set) const
 Build a new bit set as union between the current and the given one. More...
 
BitSet doInter (const BitSet &set) const
 Build a new bit set as intersection between the current and the given one. More...
 
BitSet doDiff (const BitSet &set) const
 Build a new bit set as difference between the current and the given one. More...
 
BitSetoperator= (const BitSet &set)
 Assignment with bit sets. More...
 
BitSetoperator+= (int index)
 Same as add(int). More...
 
BitSetoperator+= (const BitSet &set)
 Same as add(const BitSet&). More...
 
BitSetoperator-= (int index)
 Same as remove(int). More...
 
BitSetoperator-= (const BitSet &set)
 Same as remove(const BitSet&). More...
 
BitSet operator+ (const BitSet &set)
 Same as doUnion(). More...
 
BitSet operator- (const BitSet &set)
 Same as doDiff(). More...
 
BitSetoperator|= (const BitSet &set)
 Same as add(const BitSet&). More...
 
BitSetoperator&= (const BitSet &set)
 Same as remove(const BitSet&). More...
 
BitSet operator| (const BitSet &set)
 Same as doUnion(). More...
 
BitSet operator& (const BitSet &set)
 Same as doInter(). More...
 
bool operator== (const BitSet &set) const
 Same as equals(). More...
 
bool operator!= (const BitSet &set) const
 Same as !equals(). More...
 
bool operator>= (const BitSet &set) const
 Same as includes(). More...
 
bool operator<= (const BitSet &set) const
 Same as !includesStrictly(). More...
 
bool operator> (const BitSet &set) const
 Same as includesStrictly(). More...
 
bool operator< (const BitSet &set) const
 Same as !includes(). More...
 

Static Public Attributes

static int __used_size = 0
 
static int __max_size = 0
 
static int __total_size = 0
 

Private Types

typedef elm::BitVector vec_t
 

Private Member Functions

 BitSet (const vec_t &ivec)
 

Private Attributes

vec_t vec
 

Detailed Description

This class implements a set as a bit vector.

You must assign each object of the set to an index in the bit vector and use it to process sets containing it.

Member Typedef Documentation

Constructor & Destructor Documentation

otawa::dfa::BitSet::BitSet ( void  )
inline

References OTAWA_BITSET_ALLOC.

Referenced by doComp(), doDiff(), doInter(), and doUnion().

otawa::dfa::BitSet::BitSet ( int  size)
inline

Build a bitset with the given size.

Parameters
sizeMaximum set item count.

References OTAWA_BITSET_ALLOC.

otawa::dfa::BitSet::BitSet ( const BitSet set)
inline

Build a bit set from by copying an existing one.

Parameters
setSet to copy.

References OTAWA_BITSET_ALLOC.

otawa::dfa::BitSet::~BitSet ( void  )
inline

References OTAWA_BITSET_FREE.

otawa::dfa::BitSet::BitSet ( const vec_t ivec)
inlineprivate

Member Function Documentation

void otawa::dfa::BitSet::add ( const BitSet set)
inline

Add the items of the given bit set to the current one.

Parameters
setSet to add.

References elm::BitVector::applyOr(), OTAWA_BITSET_ALLOC, OTAWA_BITSET_FREE, and vec.

void otawa::dfa::BitSet::complement ( void  )
inline

Complement the current bit set.

References elm::BitVector::applyNot(), and vec.

Referenced by otawa::cat::CATProblem::preserve().

int otawa::dfa::BitSet::count ( void  ) const
inline
BitSet otawa::dfa::BitSet::doComp ( void  ) const
inline

Compute a bit set complement of the current one.

Returns
Complemented bit set.

References BitSet(), elm::BitVector::makeNot(), and vec.

BitSet otawa::dfa::BitSet::doDiff ( const BitSet set) const
inline

Build a new bit set as difference between the current and the given one.

Parameters
setSet to do difference with.
Returns
Difference of both sets.

References BitSet(), elm::BitVector::makeReset(), and vec.

Referenced by operator-().

BitSet otawa::dfa::BitSet::doInter ( const BitSet set) const
inline

Build a new bit set as intersection between the current and the given one.

Parameters
setSet to do intersection with.
Returns
Intersection of both sets.

References BitSet(), elm::BitVector::makeAnd(), and vec.

Referenced by operator&().

BitSet otawa::dfa::BitSet::doUnion ( const BitSet set) const
inline

Build a new bit set as union between the current and the given one.

Parameters
setSet to do union with.
Returns
Union of both sets.

References BitSet(), elm::BitVector::makeOr(), and vec.

Referenced by operator+(), and operator|().

bool otawa::dfa::BitSet::equals ( const BitSet set) const
inline

Test if two bit sets are equals.

Parameters
setBit set to compare the current one with.
Returns
True if they are equal, false else.

References elm::BitVector::equals(), and vec.

Referenced by otawa::ccg::Domain::equals(), otawa::dcache::DirtyManager::equals(), operator!=(), and operator==().

void otawa::dfa::BitSet::fill ( void  )
inline
bool otawa::dfa::BitSet::includes ( const BitSet set) const
inline

Test if the current bit set contains the given one.

Parameters
setSet to test for inclusion.
Returns
True if the current bit set contains the given one.

References elm::BitVector::includes(), and vec.

Referenced by operator<=(), and operator>=().

bool otawa::dfa::BitSet::includesStrictly ( const BitSet set) const
inline

Test if the current bit set contains strictly the given one, that is, both bit sets are equals.

Parameters
setSet to test for inclusion.
Returns
True if the current bit set contains the given one.

References elm::BitVector::includesStrictly(), and vec.

Referenced by operator<(), and operator>().

bool otawa::dfa::BitSet::isEmpty ( void  ) const
inline

Test if the bit set is empty.

Returns
True if it is empty, false else.

References elm::BitVector::isEmpty(), and vec.

bool otawa::dfa::BitSet::isFull ( void  ) const
inline

Test if the bit set contains all existing items.

Returns
True if it is full, false else.

References elm::BitVector::countBits(), elm::BitVector::size(), and vec.

void otawa::dfa::BitSet::mask ( const BitSet set)
inline

Keep only in this set the items also containted in the given one (performs intersection operation).

Parameters
setSet to intersect with.

References elm::BitVector::applyAnd(), OTAWA_BITSET_ALLOC, OTAWA_BITSET_FREE, and vec.

Referenced by otawa::ccg::Domain::meet(), otawa::cat::CATDomain::meet(), operator&=(), and otawa::cat::CATBuilder::worst().

bool otawa::dfa::BitSet::operator!= ( const BitSet set) const
inline

Same as !equals().

References equals().

BitSet otawa::dfa::BitSet::operator& ( const BitSet set)
inline

Same as doInter().

References doInter().

BitSet & otawa::dfa::BitSet::operator&= ( const BitSet set)
inline

Same as remove(const BitSet&).

References mask().

BitSet otawa::dfa::BitSet::operator+ ( const BitSet set)
inline

Same as doUnion().

References doUnion().

BitSet & otawa::dfa::BitSet::operator+= ( int  index)
inline

Same as add(int).

References add().

BitSet & otawa::dfa::BitSet::operator+= ( const BitSet set)
inline

Same as add(const BitSet&).

References add().

BitSet otawa::dfa::BitSet::operator- ( const BitSet set)
inline

Same as doDiff().

References doDiff().

BitSet & otawa::dfa::BitSet::operator-= ( int  index)
inline

Same as remove(int).

BitSet & otawa::dfa::BitSet::operator-= ( const BitSet set)
inline
bool otawa::dfa::BitSet::operator< ( const BitSet set) const
inline

Same as !includes().

References includesStrictly().

bool otawa::dfa::BitSet::operator<= ( const BitSet set) const
inline

Same as !includesStrictly().

References includes().

BitSet & otawa::dfa::BitSet::operator= ( const BitSet set)
inline

Assignment with bit sets.

Parameters
setSet to assign.

References OTAWA_BITSET_ALLOC, OTAWA_BITSET_FREE, and vec.

bool otawa::dfa::BitSet::operator== ( const BitSet set) const
inline

Same as equals().

References equals().

bool otawa::dfa::BitSet::operator> ( const BitSet set) const
inline

Same as includesStrictly().

References includesStrictly().

bool otawa::dfa::BitSet::operator>= ( const BitSet set) const
inline

Same as includes().

References includes().

BitSet otawa::dfa::BitSet::operator| ( const BitSet set)
inline

Same as doUnion().

References doUnion().

BitSet & otawa::dfa::BitSet::operator|= ( const BitSet set)
inline

Same as add(const BitSet&).

References add().

void otawa::dfa::BitSet::remove ( int  index)
inline

Remove an item from the bit set.

Parameters
indexIndex identifying the removed item.

References elm::BitVector::clear(), OTAWA_BITSET_ALLOC, OTAWA_BITSET_FREE, and vec.

Referenced by otawa::cat::CATProblem::preserve(), otawa::LoopReductor::reduce(), otawa::dcache::DirtyManager::update(), and otawa::cat::CATBuilder::worst().

void otawa::dfa::BitSet::remove ( const BitSet set)
inline

Remove the items contained in the given bit set from the current one.

Parameters
setSet containing items to remove.

References elm::BitVector::applyReset(), OTAWA_BITSET_ALLOC, OTAWA_BITSET_FREE, and vec.

Member Data Documentation

int otawa::dfa::BitSet::__max_size = 0
static
int otawa::dfa::BitSet::__total_size = 0
static
int otawa::dfa::BitSet::__used_size = 0
static

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