Grafalgo
Library of useful data structures and algorithms
grafalgo::ClistSet Class Reference

This class represents a collection of lists defined on a set of unique integers 1..n. More...

#include <ClistSet.h>

Inheritance diagram for grafalgo::ClistSet:
Collaboration diagram for grafalgo::ClistSet:

List of all members.

Classes

struct  lnode

Public Member Functions

 ClistSet (int)
 Constructor for ClistSet.
 ~ClistSet ()
 Destructor for ClistSet.
void clear ()
 Clear the data structure, moving all index values into single node lists.
void resize (int)
 Resize a ClistSet object.
void expand (int)
 Expand the space available for this ClistSet.
void copyFrom (const ClistSet &)
 Copy into ClistSet from source.
int suc (index) const
 Get the successor of a list item.
int pred (index) const
 Get the predecessor of a list item.
void join (index, index)
 Join two lists together.
void remove (index)
 Remove an index from its list.
string & toString (string &) const
 Produce a string representation of the object.

Private Member Functions

void makeSpace (int)
 Allocate and initialize space for ClistSet.
void freeSpace ()
 Free dynamic storage used by ClistSet.

Private Attributes

struct grafalgo::ClistSet::lnodenode

Detailed Description

This class represents a collection of lists defined on a set of unique integers 1..n.

Each integer appears in exactly one set at all times. The lists are doubly linked, enabling fast traversal in either direction.

Definition at line 22 of file ClistSet.h.


Constructor & Destructor Documentation

grafalgo::ClistSet::ClistSet ( int  n1)

Constructor for ClistSet.

Parameters:
n1defines the set of integers 1..n on which this object is defined

Definition at line 15 of file ClistSet.cpp.

Here is the call graph for this function:


Member Function Documentation

void grafalgo::ClistSet::copyFrom ( const ClistSet source)

Copy into ClistSet from source.

Definition at line 68 of file ClistSet.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void grafalgo::ClistSet::expand ( int  size) [virtual]

Expand the space available for this ClistSet.

Rebuilds old value in new space.

Parameters:
sizeis the size of the resized object.

Implements grafalgo::Adt.

Definition at line 53 of file ClistSet.cpp.

Here is the call graph for this function:

void grafalgo::ClistSet::freeSpace ( ) [private]

Free dynamic storage used by ClistSet.

Definition at line 35 of file ClistSet.cpp.

Here is the caller graph for this function:

void grafalgo::ClistSet::join ( index  i,
index  j 
)

Join two lists together.

Parameters:
iis an index on some list
jis an index on some other list Note: the method will corrupt the data structure if i and j already belong to the same list; it's the caller's responsiblity to ensure this doesn't happen

Definition at line 97 of file ClistSet.cpp.

Here is the caller graph for this function:

void grafalgo::ClistSet::makeSpace ( int  size) [private]

Allocate and initialize space for ClistSet.

Parameters:
sizeis number of index values to provide space for

Definition at line 23 of file ClistSet.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

index grafalgo::ClistSet::pred ( index  i) const [inline]

Get the predecessor of a list item.

Parameters:
iis an index
Returns:
the index that precedes i in its list

Definition at line 63 of file ClistSet.h.

Here is the caller graph for this function:

void grafalgo::ClistSet::remove ( index  i)

Remove an index from its list.

This method turns the index into a singleton list.

Parameters:
iis an index

Definition at line 82 of file ClistSet.cpp.

Here is the caller graph for this function:

void grafalgo::ClistSet::resize ( int  size) [virtual]

Resize a ClistSet object.

The old value is discarded.

Parameters:
sizeis the size of the resized object.

Implements grafalgo::Adt.

Definition at line 41 of file ClistSet.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

index grafalgo::ClistSet::suc ( index  i) const [inline]

Get the successor of a list item.

Parameters:
iis an index
Returns:
the index that follows i in its list

Definition at line 55 of file ClistSet.h.

Here is the caller graph for this function:

string & grafalgo::ClistSet::toString ( string &  s) const [virtual]

Produce a string representation of the object.

Parameters:
sis a string in which the result will be returned
Returns:
a reference to s

Implements grafalgo::Adt.

Definition at line 109 of file ClistSet.cpp.


The documentation for this class was generated from the following files:
 All Classes Files Functions Variables Typedefs Friends