#include <intmultiset.h>
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. |
The class provides an efficient implementation of common operations like adding, removing, or element access.
Definition at line 55 of file intmultiset.h.
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.
[in] | _elems | Pointer to the vector of integer elements used for initialization. |
Definition at line 47 of file intmultiset.cpp.
References elems, RoleList::getInstance(), RoleList::getMaxRoleId(), and max.
IntMultiSet::~IntMultiSet | ( | ) | [virtual] |
void IntMultiSet::addElem | ( | unsigned | i | ) | [inline] |
Adds a single element to the multi set.
Adds a single elementto the current multi set object.
[in] | i | Value to be added. |
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.
[in] | _elems | Pointer to the element vector whose elements will be added. |
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.
[in] | set | The IntMultiSet object whose elements will be added. |
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.
[in] | i | The value to be checked for. |
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..
vector<unsigned> | The vector containing all multi set elements. |
Definition at line 90 of file intmultiset.cpp.
bool IntMultiSet::isEmpty | ( | ) |
Checks for the multiset being empty.
Checks for the multiset being empty.
bool | Returns true if the multiset is empty. |
Definition at line 102 of file intmultiset.cpp.
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.
[in] | dos | The debug output stream to be used. |
void |
Definition at line 77 of file intmultiset.cpp.
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.
[in] | i | Value to be removed. |
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().
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().