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

Header file for data structure representing a collection of lists defined over index values 1,2,... More...

#include <ListSet.h>

Inheritance diagram for grafalgo::ListSet:
Collaboration diagram for grafalgo::ListSet:

List of all members.

Classes

struct  listhdr

Public Member Functions

 ListSet (int=26, int=5)
 Constructor for ListSet.
 ~ListSet ()
 Destructor for ListSet class.
void clear ()
 Remove all items from all lists.
void resize (int siz)
void resize (int, int)
 Resize a ListSet object.
void expand (int siz)
void expand (int, int)
 Expand the space available for this ListSet.
void copyFrom (const ListSet &)
 Copy into list from source.
index next (index) const
 Get the successor of an index.
index first (alist) const
 Get the first index in a list.
index last (alist) const
 Get the last index in a list.
bool member (index) const
 Determine if an index is on some list.
bool empty (alist) const
 Determine if a list is empty.
void addLast (index, alist)
 Add an index to a list.
void addFirst (index, alist)
 Add an index to the front of a list.
index removeFirst (alist)
 Remove the first index from a list.
string & toString (string &) const
 Build a string representation of a set of lists.
string & list2string (alist, string &) const
 Build a string representation of a list.

Private Member Functions

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

Private Attributes

int nlst
listhdrlh
index * nxt

Detailed Description

Header file for data structure representing a collection of lists defined over index values 1,2,...

Each index can be stored in at most one list. Lists are also numbered 1,2,...

Definition at line 22 of file ListSet.h.


Constructor & Destructor Documentation

grafalgo::ListSet::ListSet ( int  nitems = 26,
int  nlists = 5 
)

Constructor for ListSet.

Parameters:
nitemsdefines the set of integers 1..nn1 on which the lists are defined; each integer can be on at most one list
nlistsspecifies the number of lists in the set

Definition at line 18 of file ListSet.cpp.

Here is the call graph for this function:

grafalgo::ListSet::~ListSet ( )

Destructor for ListSet class.

Definition at line 23 of file ListSet.cpp.

Here is the call graph for this function:


Member Function Documentation

void grafalgo::ListSet::addFirst ( index  i,
alist  j 
)

Add an index to the front of a list.

Parameters:
iis an index, which is currently not in any list
jis a list number; the index i is added to the front of list j

Definition at line 114 of file ListSet.cpp.

void grafalgo::ListSet::addLast ( index  i,
alist  j 
)

Add an index to a list.

Parameters:
iis a list index, which is currently not in any list
jis a list number; the index i is added to the end of list j

Definition at line 92 of file ListSet.cpp.

Here is the caller graph for this function:

void grafalgo::ListSet::clear ( ) [virtual]

Remove all items from all lists.

Implements grafalgo::Adt.

Definition at line 48 of file ListSet.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void grafalgo::ListSet::copyFrom ( const ListSet src)

Copy into list from source.

Definition at line 78 of file ListSet.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

bool grafalgo::ListSet::empty ( alist  lst) const [inline]

Determine if a list is empty.

Parameters:
lstis a list in the collection
Returns:
true if the list is empty, else false

Definition at line 79 of file ListSet.h.

Here is the caller graph for this function:

void grafalgo::ListSet::expand ( int  nitems,
int  nlists 
)

Expand the space available for this ListSet.

Rebuilds old value in new space.

Parameters:
nitemsis the size of the resized object.

Definition at line 71 of file ListSet.cpp.

Here is the call graph for this function:

index grafalgo::ListSet::first ( alist  lst) const [inline]

Get the first index in a list.

Parameters:
lstis a list in the collection
Returns:
the first index on lst, or 0 if the list is empty

Definition at line 67 of file ListSet.h.

Here is the caller graph for this function:

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

Free dynamic storage used by list.

Definition at line 45 of file ListSet.cpp.

Here is the caller graph for this function:

index grafalgo::ListSet::last ( alist  lst) const [inline]

Get the last index in a list.

Parameters:
lstis a list in the collection
Returns:
the last index on lst, or 0 if the list is empty

Definition at line 73 of file ListSet.h.

string & grafalgo::ListSet::list2string ( alist  j,
string &  s 
) const

Build a string representation of a list.

Parameters:
jis a list number
sis a string in which the result is returned
Returns:
a reference to s

Definition at line 126 of file ListSet.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void grafalgo::ListSet::makeSpace ( int  nitems,
int  nlists 
) [private]

Allocate and initialize space for list.

Parameters:
nitemsis number of index values to provide space for
nlistsis the number of lists to provide space for

Definition at line 29 of file ListSet.cpp.

Here is the caller graph for this function:

bool grafalgo::ListSet::member ( index  i) const [inline]

Determine if an index is on some list.

Parameters:
iis an index
Returns:
true if the some list contains i, else false

Definition at line 85 of file ListSet.h.

index grafalgo::ListSet::next ( index  i) const [inline]

Get the successor of an index.

Parameters:
iis an index on some list
Returns:
the successor of i

Definition at line 91 of file ListSet.h.

Here is the caller graph for this function:

int grafalgo::ListSet::removeFirst ( alist  j)

Remove the first index from a list.

Parameters:
jis a list number
Returns:
the first index on list j or 0, if it is empty

Definition at line 103 of file ListSet.cpp.

Here is the caller graph for this function:

void grafalgo::ListSet::resize ( int  nitems,
int  nlists 
)

Resize a ListSet object.

The old value is discarded.

Parameters:
nitemsis the number of items in the resized object.
nlistsis the number of lists in the resized object.

Definition at line 59 of file ListSet.cpp.

Here is the call graph for this function:

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

Build a string representation of a set of lists.

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

Implements grafalgo::Adt.

Definition at line 142 of file ListSet.cpp.

Here is the call graph for this function:


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