IntMultiSet Class Reference

Represents a multi set of integers, ranging from 0 to a fixed maximum. More...

#include <intmultiset.h>

List of all members.

Public Member Functions

 IntMultiSet ()
 Constructor.
 IntMultiSet (vector< unsigned > *_elems)
 Constructor.
virtual ~IntMultiSet ()
void addElems (IntMultiSet &set)
 Appends the content of the input IntMultiSet object.
void addElems (vector< unsigned > *_elems)
 Add the elements specified in the input vector to the multi set.
void addElem (unsigned i)
 Adds a single element to the multi set.
virtual void print (OutputStream &dos)
 Debug prints the int multi set.
vector< unsigned > getElemVec ()
 Returns a vector containing all elements in the multi set.
bool isEmpty ()
 Checks for the multiset being empty.
bool containsElem (unsigned i)
 Checks for an element being contained in the multi set.
bool removeElem (unsigned i)
 Removes a single element from the multi set.

Private Attributes

int max
 The maximum number of distinct elements in the set.
unsigned * elems
 The internal data structure that stores the multi set.


Detailed Description

Represents a multi set of integers, ranging from 0 to a fixed maximum.

The class provides an efficient implementation of common operations like adding, removing, or element access.

Note:
This class is only used when compiling GCX without option -DROLE_REFCOUNT.
Author:
Michael Schmidt

Gunnar Jehl

Version:
2.1
License:
Software License Agreement (BSD License)

Definition at line 55 of file intmultiset.h.


Constructor & Destructor Documentation

IntMultiSet::IntMultiSet (  ) 

Constructor.

Constructor - creating object for integers within the range 0..max-1.

Definition at line 38 of file intmultiset.cpp.

References elems, RoleList::getInstance(), RoleList::getMaxRoleId(), and max.

IntMultiSet::IntMultiSet ( vector< unsigned > *  _elems  ) 

Constructor.

Constructor - creating object for integers within the range 0..max-1, and inserts the elements specified in the vector argument into the multi set.

Parameters:
[in] _elems Pointer to the vector of integer elements used for initialization.
Note:
All elements in the input vector _elems Must be contained inbetween range 0-max-1.

Definition at line 47 of file intmultiset.cpp.

References elems, RoleList::getInstance(), RoleList::getMaxRoleId(), and max.

IntMultiSet::~IntMultiSet (  )  [virtual]

Destructor.

Definition at line 59 of file intmultiset.cpp.

References elems.


Member Function Documentation

void IntMultiSet::addElem ( unsigned  i  )  [inline]

Adds a single element to the multi set.

Adds a single elementto the current multi set object.

Note:
The value i must be less than max.
Parameters:
[in] i Value to be added.
Return values:
void 

Definition at line 108 of file intmultiset.h.

References elems.

Referenced by addElems().

void IntMultiSet::addElems ( vector< unsigned > *  _elems  ) 

Add the elements specified in the input vector to the multi set.

Appends the integer values specified in the passed vector to the current multi set object.

Note:
The elements in the input vector must be contained inbetween range 0..max-1.
Parameters:
[in] _elems Pointer to the element vector whose elements will be added.
Return values:
void 

Definition at line 71 of file intmultiset.cpp.

References addElem().

void IntMultiSet::addElems ( IntMultiSet set  ) 

Appends the content of the input IntMultiSet object.

Appends the content of the input IntMultiSet object to the current multi set object.

Note:
the max value of the input IntMultiSet object must be less or equal than this object's max value.
Parameters:
[in] set The IntMultiSet object whose elements will be added.
Return values:
void 

Definition at line 63 of file intmultiset.cpp.

References addElem().

bool IntMultiSet::containsElem ( unsigned  i  )  [inline]

Checks for an element being contained in the multi set.

Implements an efficient element check for the int multi set.

Note:
The value i must be less than max.
Parameters:
[in] i The value to be checked for.
Return values:
bool Returns true if the element is contained, false otherwise.

Definition at line 140 of file intmultiset.h.

References elems.

vector< unsigned > IntMultiSet::getElemVec (  ) 

Returns a vector containing all elements in the multi set.

The returned list is ordered (<) and may contain elements several time (according to the multi set), i.e. duplicates are not removed..

Return values:
vector<unsigned> The vector containing all multi set elements.

Definition at line 90 of file intmultiset.cpp.

References elems, and max.

bool IntMultiSet::isEmpty (  ) 

Checks for the multiset being empty.

Checks for the multiset being empty.

Return values:
bool Returns true if the multiset is empty.

Definition at line 102 of file intmultiset.cpp.

References elems, and max.

Referenced by BufferNode::isCumulativeMarked(), and BufferNode::isMarked().

void IntMultiSet::print ( OutputStream dos  )  [virtual]

Debug prints the int multi set.

Debug prints the int multi set to the specified debug output stream.

Parameters:
[in] dos The debug output stream to be used.
Return values:
void 

Definition at line 77 of file intmultiset.cpp.

References elems, and max.

Referenced by BufferNode::debugPrint().

bool IntMultiSet::removeElem ( unsigned  i  ) 

Removes a single element from the multi set.

Removes a single element from the multi set, if it is present at least once.

Note:
The value of i must be less than max. If the value is not contained in the multi set, nothing happens.
Parameters:
[in] i Value to be removed.
Return values:
bool Returns false if element i was not contained in the multi set.

Definition at line 111 of file intmultiset.cpp.

References elems.

Referenced by BufferNode::removeRoleFromNode().


Member Data Documentation

unsigned * IntMultiSet::elems [private]

The internal data structure that stores the multi set.

Each element i in 0..max-1 is represented by array position i, whereas the value in the array denotes the element's multiplicity in the multi set.

Definition at line 168 of file intmultiset.h.

Referenced by addElem(), containsElem(), getElemVec(), IntMultiSet(), isEmpty(), print(), removeElem(), and ~IntMultiSet().

int IntMultiSet::max [private]

The maximum number of distinct elements in the set.

Furthermore, all elements must be in the range 0..max-1.

Definition at line 160 of file intmultiset.h.

Referenced by getElemVec(), IntMultiSet(), isEmpty(), and print().


Generated on Sun May 24 20:20:25 2009 for G(arbage) C(ollected) X(Query) Engine by  doxygen 1.5.9