partition  0.1.1
 All Classes Namespaces Functions Variables Pages
Classes | Public Types | Public Member Functions | Friends | List of all members
partition::Group< M, V > Class Template Reference

Maintains a doubly linked list of Entry objects from a single associated Domain and may also be assigned a user-defined value of type V. More...

#include <partition.hpp>

Classes

class  ConstIterator
 A bidirectional iterator for traversing the Entry objects of a const Group. More...
 
class  Iterator
 A bidirectional iterator for traversing the Entry objects of a Group. More...
 

Public Types

typedef Domain< M, V >::Entry Entry
 

Public Member Functions

 Group ()
 Constructs an empty Group with no Domain association and a default value. More...
 
 Group (Domain< M, V > &d)
 Constructs an empty Group associated with Domain d and a default value. More...
 
 Group (Domain< M, V > &d, const V &v)
 Constructs an empty Group associated with Domain d and sets the Group's value to v. More...
 
 Group (Domain< M, V > &d, const Group &g)
 Constructs a Group that is a copy of g with the exception that its associated with Domain d. More...
 
template<typename InputIterator >
 Group (Domain< M, V > &d, const InputIterator &first, const InputIterator &last)
 Constructs a Group loaded with the IDs listed from first to last. More...
 
virtual ~Group ()
 Destructs the Group, removing all Entry objects from the Group. More...
 
Domain< M, V > * getDomain ()
 Returns a pointer to the Domain associated with this Group (or NULL if this Group has no Domain association). More...
 
const Domain< M, V > * getDomain () const
 Returns a pointer to the const Domain associated with this Group (or NULL if this Group has no Domain association). More...
 
void setDomain (Domain< M, V > &d)
 Associates this Group with Domain d. More...
 
V & getValue ()
 Returns a reference to the user provided value associated with this Group. More...
 
const V & getValue () const
 Returns a const reference to the user provided value associated with this Group. More...
 
void setValue (const V &v)
 Sets v as this Group's value. More...
 
int size () const
 Returns the number of Entry objects in this Group's list. More...
 
bool contains (int id) const
 Returns true if this Group contains the Entry with the given id, and false otherwise. More...
 
EntrypeekFront ()
 Returns a reference to the Entry at the front of the Group list while leaving the list unmodified. More...
 
const EntrypeekFront () const
 Returns a const reference to the Entry at the front of the Group list while leaving the list unmodified. More...
 
EntrypeekBack ()
 Returns a reference to the Entry at the back of the Group list while leaving the list unmodified. More...
 
const EntrypeekBack () const
 Returns a const reference to the Entry at the back of the Group list while leaving the list unmodified. More...
 
void addFront (int id)
 Adds the Entry with the given id from the Group's associated Domain to the front of this Group's list. More...
 
void addBack (int id)
 Adds the Entry with the given id from the Group's associated Domain to the back of this Group's list. More...
 
void addFront (Group &g)
 Moves all Entry objects from Group g to the front of this Group's list. More...
 
void addBack (Group &g)
 Moves all Entry objects from Group g to the back of this Group's list. More...
 
void addAll ()
 Adds all Entry objects from this Group's Domain to this Group's list (simultaneously removing them from the Groups with which they were previously a member). More...
 
EntryremoveFront ()
 Removes the Entry at the front of this Group's list and returns a reference to it. More...
 
EntryremoveBack ()
 Removes the Entry at the back of this Group's list and returns a reference to it. More...
 
Entryremove (int id)
 Removes from this Group's list the Entry with the given id and returns reference to it. More...
 
void removeAll ()
 Removes all Entry objects from this Group's list. More...
 
Iterator front ()
 Returns an Iterator pointing to the first Entry of this Group's list. More...
 
ConstIterator front () const
 Returns a ConstIterator pointing to the first Entry of this Group's list. More...
 
Iterator back ()
 Returns an Iterator pointing to the last Entry of this Group's list. More...
 
ConstIterator back () const
 Returns a ConstIterator pointing to the last Entry of this Group's list. More...
 
Iterator beforeFront ()
 Returns an Iterator pointing to the position before the first Entry in this Group's list. More...
 
ConstIterator beforeFront () const
 Returns a ConstIterator pointing to the position before the first Entry in this Group's list. More...
 
Iterator afterBack ()
 Returns an Iterator pointing to the position after the last Entry in this Group's list. More...
 
ConstIterator afterBack () const
 Returns a ConstIterator pointing to the position after the last Entry in this Group's list. More...
 
Iterator find (int id)
 Returns an Iterator pointing to the Entry from this list with the given id, or pointing to the afterBack position if this Group does not contain the Entry with the given id. More...
 
ConstIterator find (int id) const
 Returns an ConstIterator pointing to the Entry from this list with the given id, or pointing to the afterBack position if this Group does not contain the Entry with the given id. More...
 
Iterator begin ()
 Equivalent to front(). More...
 
ConstIterator begin () const
 Equivalent to front() const. More...
 
Iterator end ()
 Equivalent to afterBack(). More...
 
ConstIterator end () const
 Equivalent to afterBack() const. More...
 

Friends

class Domain< M, V >
 

Detailed Description

template<typename M, typename V>
class partition::Group< M, V >

Maintains a doubly linked list of Entry objects from a single associated Domain and may also be assigned a user-defined value of type V.

Read the package summary for introductory information about Group and its related classes.

An Entry may be added to a Group via add operations typical of linked lists, but each such add has the atypical side-affect of simultaneously removing the Entry from its previous Group membership (if any) all with constant computational complexity.

The following four terms are used consistently throughout to refer to key list posistions:

Parameters
MThe Entry member type.
VThe Group value type.

Constructor & Destructor Documentation

template<typename M , typename V >
partition::Group< M, V >::Group ( )
inline

Constructs an empty Group with no Domain association and a default value.

Few operations on a Group constructed in this way are permitted until a Domain object has been associated with the Group via the setDomain() method.

template<typename M , typename V >
partition::Group< M, V >::Group ( Domain< M, V > &  d)
inline

Constructs an empty Group associated with Domain d and a default value.

template<typename M , typename V >
partition::Group< M, V >::Group ( Domain< M, V > &  d,
const V &  v 
)
inline

Constructs an empty Group associated with Domain d and sets the Group's value to v.

template<typename M , typename V >
partition::Group< M, V >::Group ( Domain< M, V > &  d,
const Group< M, V > &  g 
)
inline

Constructs a Group that is a copy of g with the exception that its associated with Domain d.

Domain d must not be the same Domain as that associated with g.

Exceptions
PartitionExceptionif g is associated with Domain d, or
if an Entry of g has an ID not contained in d.

These validations are only included if the following preprocessor directive evaluates to true during compilation:
#if PARTITION_SL >= PARTITION_ST_GROUP_CONSTRUCTOR
template<typename M , typename V >
template<typename InputIterator >
partition::Group< M, V >::Group ( Domain< M, V > &  d,
const InputIterator &  first,
const InputIterator &  last 
)
inline

Constructs a Group loaded with the IDs listed from first to last.

The iterators first and last should point to the beginning and end of a sequence of integers that are each IDs found in Domain d.

Exceptions
PartitionExceptionif an id in the input sequence is not contained in d.

Thsi validation is only included if the following preprocessor directive evaluates to true during compilation:
#if PARTITION_SL >= PARTITION_ST_GROUP_ADD
template<typename M , typename V >
partition::Group< M, V >::~Group ( )
inlinevirtual

Destructs the Group, removing all Entry objects from the Group.

Member Function Documentation

template<typename M , typename V >
Domain< M, V > * partition::Group< M, V >::getDomain ( )
inline

Returns a pointer to the Domain associated with this Group (or NULL if this Group has no Domain association).

template<typename M , typename V >
const Domain< M, V > * partition::Group< M, V >::getDomain ( ) const
inline

Returns a pointer to the const Domain associated with this Group (or NULL if this Group has no Domain association).

template<typename M , typename V >
void partition::Group< M, V >::setDomain ( Domain< M, V > &  d)
inline

Associates this Group with Domain d.

If this Group was not previously associated with d, then the Group's list is first cleared of any Entry objects from its current Domain association (if any). If this Group was already associated with d, then there is no effect.

template<typename M , typename V >
V & partition::Group< M, V >::getValue ( )
inline

Returns a reference to the user provided value associated with this Group.

template<typename M , typename V >
const V & partition::Group< M, V >::getValue ( ) const
inline

Returns a const reference to the user provided value associated with this Group.

template<typename M , typename V >
void partition::Group< M, V >::setValue ( const V &  v)
inline

Sets v as this Group's value.

template<typename M , typename V >
int partition::Group< M, V >::size ( ) const
inline

Returns the number of Entry objects in this Group's list.

template<typename M , typename V >
bool partition::Group< M, V >::contains ( int  id) const
inline

Returns true if this Group contains the Entry with the given id, and false otherwise.

Computational Complexity: Constant.

Exceptions
PartitionExceptionif this Group has no Domain association; or
if id is not a member of the associated Domain.

These validations are only included if the following preprocessor directive evaluates to true during compilation:
#if PARTITION_SL >= PARTITION_ST_GROUP_ACCESSOR
template<typename M , typename V >
Domain< M, V >::Entry & partition::Group< M, V >::peekFront ( )
inline

Returns a reference to the Entry at the front of the Group list while leaving the list unmodified.

Exceptions
PartitionExceptionif the Group is empty.

This validation is only included if the following preprocessor directive evaluates to true during compilation:
#if PARTITION_SL >= PARTITION_ST_GROUP_ACCESSOR
template<typename M , typename V >
const Domain< M, V >::Entry & partition::Group< M, V >::peekFront ( ) const
inline

Returns a const reference to the Entry at the front of the Group list while leaving the list unmodified.

Exceptions
PartitionExceptionif the Group is empty.

This validation is only included if the following preprocessor directive evaluates to true during compilation:
#if PARTITION_SL >= PARTITION_ST_GROUP_ACCESSOR
template<typename M , typename V >
Domain< M, V >::Entry & partition::Group< M, V >::peekBack ( )
inline

Returns a reference to the Entry at the back of the Group list while leaving the list unmodified.

Exceptions
PartitionExceptionif the Group is empty.

This validation is only included if the following preprocessor directive evaluates to true during compilation:
#if PARTITION_SL >= PARTITION_ST_GROUP_ACCESSOR
template<typename M , typename V >
const Domain< M, V >::Entry & partition::Group< M, V >::peekBack ( ) const
inline

Returns a const reference to the Entry at the back of the Group list while leaving the list unmodified.

Exceptions
PartitionExceptionif the Group is empty.

This validation is only included if the following preprocessor directive evaluates to true during compilation:
#if PARTITION_SL >= PARTITION_ST_GROUP_ACCESSOR
template<typename M , typename V >
void partition::Group< M, V >::addFront ( int  id)
inline

Adds the Entry with the given id from the Group's associated Domain to the front of this Group's list.

If the Entry was previously a member of a Group, it is first removed from that Group.

Computational Complexity: Constant.

Exceptions
PartitionExceptionif this Group has no Domain association; or
if id is not a member of the associated Domain.

These validations are only included if the following preprocessor directive evaluates to true during compilation:
#if PARTITION_SL >= PARTITION_ST_GROUP_ADD
template<typename M , typename V >
void partition::Group< M, V >::addBack ( int  id)
inline

Adds the Entry with the given id from the Group's associated Domain to the back of this Group's list.

If the Entry was previously a member of a Group, it is first removed from that Group.

Computational Complexity: Constant.

Exceptions
PartitionExceptionif this Group has no Domain association; or
if id is not a member of the associated Domain.

These validations are only included if the following preprocessor directive evaluates to true during compilation:
#if PARTITION_SL >= PARTITION_ST_GROUP_ADD
template<typename M , typename V >
void partition::Group< M, V >::addFront ( Group< M, V > &  g)
inline

Moves all Entry objects from Group g to the front of this Group's list.

Computational Complexity: Linear in the size of g.

Exceptions
PartitionExceptionif Group g is not associated with the same Domain as this Group.

This validation is only included if the following preprocessor directive evaluates to true during compilation:
#if PARTITION_SL >= PARTITION_ST_GROUP_ADD
template<typename M , typename V >
void partition::Group< M, V >::addBack ( Group< M, V > &  g)
inline

Moves all Entry objects from Group g to the back of this Group's list.

Computational Complexity: Linear in the size of g.

Exceptions
PartitionExceptionif Group g is not associated with the same Domain as this Group.

This validation is only included if the following preprocessor directive evaluates to true during compilation:
#if PARTITION_SL >= PARTITION_ST_GROUP_ADD
template<typename M , typename V >
void partition::Group< M, V >::addAll ( )
inline

Adds all Entry objects from this Group's Domain to this Group's list (simultaneously removing them from the Groups with which they were previously a member).

Entry objects are listed in ascending ID order.

Computational Complexity: Linear in the size of this Group's Domain.

Exceptions
PartitionExceptionif this Group has no Domain association

This validation is only included if the following preprocessor directive evaluates to true during compilation:
#if PARTITION_SL >= PARTITION_ST_GROUP_ADD
template<typename M , typename V >
Domain< M, V >::Entry & partition::Group< M, V >::removeFront ( )
inline

Removes the Entry at the front of this Group's list and returns a reference to it.

Computational Complexity: Constant.

Exceptions
PartitionExceptionif this Group is empty.

This validation is only included if the following preprocessor directive evaluates to true during compilation:
#if PARTITION_SL >= PARTITION_ST_GROUP_REMOVE
template<typename M , typename V >
Domain< M, V >::Entry & partition::Group< M, V >::removeBack ( )
inline

Removes the Entry at the back of this Group's list and returns a reference to it.

Computational Complexity: Constant.

Exceptions
PartitionExceptionif this Group is empty.

This validation is only included if the following preprocessor directive evaluates to true during compilation:
#if PARTITION_SL >= PARTITION_ST_GROUP_REMOVE
template<typename M , typename V >
Domain< M, V >::Entry & partition::Group< M, V >::remove ( int  id)
inline

Removes from this Group's list the Entry with the given id and returns reference to it.

Computational Complexity: Constant.

Exceptions
PartitionExceptionif this Group has no Domain association; or
if this Group does not contain the Entry with the given id.

These validations are only included if the following preprocessor directive evaluates to true during compilation:
#if PARTITION_SL >= PARTITION_ST_GROUP_REMOVE
template<typename M , typename V >
void partition::Group< M, V >::removeAll ( )
inline

Removes all Entry objects from this Group's list.

Computational Complexity: Linear in the size of this Group.

template<typename M , typename V >
Group< M, V >::Iterator partition::Group< M, V >::front ( )
inline

Returns an Iterator pointing to the first Entry of this Group's list.

If this Group is empty, the returned Iterator will point to the afterBack list position.

template<typename M , typename V >
Group< M, V >::ConstIterator partition::Group< M, V >::front ( ) const
inline

Returns a ConstIterator pointing to the first Entry of this Group's list.

If this Group is empty, the returned ConstIterator will point to the afterBack list position.

template<typename M , typename V >
Group< M, V >::Iterator partition::Group< M, V >::back ( )
inline

Returns an Iterator pointing to the last Entry of this Group's list.

If this Group is empty, the returned Iterator will point to the beforeFront list position.

template<typename M , typename V >
Group< M, V >::ConstIterator partition::Group< M, V >::back ( ) const
inline

Returns a ConstIterator pointing to the last Entry of this Group's list.

If this Group is empty, the returned ConstIterator will point to the beforeFront list position.

template<typename M , typename V >
Group< M, V >::Iterator partition::Group< M, V >::beforeFront ( )
inline

Returns an Iterator pointing to the position before the first Entry in this Group's list.

template<typename M , typename V >
Group< M, V >::ConstIterator partition::Group< M, V >::beforeFront ( ) const
inline

Returns a ConstIterator pointing to the position before the first Entry in this Group's list.

template<typename M , typename V >
Group< M, V >::Iterator partition::Group< M, V >::afterBack ( )
inline

Returns an Iterator pointing to the position after the last Entry in this Group's list.

template<typename M , typename V >
Group< M, V >::ConstIterator partition::Group< M, V >::afterBack ( ) const
inline

Returns a ConstIterator pointing to the position after the last Entry in this Group's list.

template<typename M , typename V >
Group< M, V >::Iterator partition::Group< M, V >::find ( int  id)
inline

Returns an Iterator pointing to the Entry from this list with the given id, or pointing to the afterBack position if this Group does not contain the Entry with the given id.

PLEASE NOTE THE EXCEPTIONAL CONDITION BELOW.

Exceptions
PartitionExceptionif this Group has no Domain association; or
if id is not a member of the associated Domain.

These validations are only included if the following preprocessor directive evaluates to true during compilation:
#if PARTITION_SL >= PARTITION_ST_GROUP_ACCESSOR
template<typename M , typename V >
Group< M, V >::ConstIterator partition::Group< M, V >::find ( int  id) const
inline

Returns an ConstIterator pointing to the Entry from this list with the given id, or pointing to the afterBack position if this Group does not contain the Entry with the given id.

PLEASE NOTE THE EXCEPTIONAL CONDITION BELOW.

Exceptions
PartitionExceptionif this Group has no Domain association; or
if id is not a member of the associated Domain.

These validations are only included if the following preprocessor directive evaluates to true during compilation:
#if PARTITION_SL >= PARTITION_ST_GROUP_ACCESSOR
template<typename M , typename V >
Group< M, V >::Iterator partition::Group< M, V >::begin ( )
inline

Equivalent to front().

template<typename M , typename V >
Group< M, V >::ConstIterator partition::Group< M, V >::begin ( ) const
inline

Equivalent to front() const.

template<typename M , typename V >
Group< M, V >::Iterator partition::Group< M, V >::end ( )
inline

Equivalent to afterBack().

template<typename M , typename V >
Group< M, V >::ConstIterator partition::Group< M, V >::end ( ) const
inline

Equivalent to afterBack() const.


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