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

Data structure representing a list of indexes. More...

#include <Dlist.h>

Inheritance diagram for grafalgo::Dlist:
Collaboration diagram for grafalgo::Dlist:

List of all members.

Public Member Functions

 Dlist (int=26)
 Constructor for a Dlist object.
 ~Dlist ()
 Destructor for Dlist.
void resize (int)
 Resize a Dlist object.
void expand (int)
 Expand the space available for this List.
index get (index) const
 Get an index based on its position in the list.
int prev (index) const
 Return the predecessor of an index in the list.
bool insert (index, index)
 Insert an index into the list, relative to another.
bool remove (index)
 Remove a specified index.
bool removeNext (index)
 Remove the index following a specified index.
bool removeLast ()
 Remove the last index on the list.

Protected Member Functions

void makeSpace (int)
 Allocate and initialize dynamic storage space.
void freeSpace ()
 Release dynamic storage used by this object.

Private Attributes

index * prv

Detailed Description

Data structure representing a list of indexes.

Used to represent a list of indexes from a defined range 1..n, where each index may appear on the list at most one time. Allows fast membership tests in addition to the usual list operations. This class extends List and adds support for reverse traversal and general remove operation.

Definition at line 25 of file Dlist.h.


Constructor & Destructor Documentation

grafalgo::Dlist::Dlist ( int  n1 = 26)

Constructor for a Dlist object.

Parameters:
nn1defines the set of integers 1..nn1 for which this object is defined.

Definition at line 17 of file Dlist.cpp.

Here is the call graph for this function:


Member Function Documentation

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

Expand the space available for this List.

Rebuilds old value in new space.

Parameters:
sizeis the size of the resized object.

Reimplemented from grafalgo::List.

Definition at line 55 of file Dlist.cpp.

Here is the call graph for this function:

void grafalgo::Dlist::freeSpace ( ) [protected]

Release dynamic storage used by this object.

Reimplemented from grafalgo::List.

Definition at line 41 of file Dlist.cpp.

Here is the caller graph for this function:

index grafalgo::Dlist::get ( index  i) const

Get an index based on its position in the list.

Parameters:
iis position of index to be returned; must be between 1 and n()
Returns:
index at position i, or 0 if no such index

Reimplemented from grafalgo::List.

Here is the caller graph for this function:

bool grafalgo::Dlist::insert ( index  i,
index  j 
) [virtual]

Insert an index into the list, relative to another.

Parameters:
iis index to insert; if i is 0 or already in the list, no change is made
jis index after which i is to be inserted; if j == 0, i is inserted at the front of the list
Returns:
true if list was modified, else false

Reimplemented from grafalgo::List.

Definition at line 80 of file Dlist.cpp.

Here is the call graph for this function:

void grafalgo::Dlist::makeSpace ( int  size) [protected]

Allocate and initialize dynamic storage space.

Parameters:
sizeis the number of elements for which space is to be allocated

Reimplemented from grafalgo::List.

Definition at line 27 of file Dlist.cpp.

Here is the caller graph for this function:

index grafalgo::Dlist::prev ( index  i) const [inline]

Return the predecessor of an index in the list.

Parameters:
iis index whose predecessor is to be returned
Returns:
the index that precedes i or 0, if none

Definition at line 56 of file Dlist.h.

Here is the call graph for this function:

Here is the caller graph for this function:

bool grafalgo::Dlist::remove ( index  i)

Remove a specified index.

Parameters:
iis an index to be removed
Returns:
true if the list was modified, else false

Definition at line 92 of file Dlist.cpp.

Here is the call graph for this function:

bool grafalgo::Dlist::removeLast ( ) [inline]

Remove the last index on the list.

Returns:
true if the list was modified, else false

Definition at line 72 of file Dlist.h.

Here is the call graph for this function:

bool grafalgo::Dlist::removeNext ( index  i) [inline, virtual]

Remove the index following a specified index.

Parameters:
iis index whose successor is to be removed; if zero, the first index is removed
Returns:
true if the list was modified, else false

Reimplemented from grafalgo::List.

Definition at line 65 of file Dlist.h.

Here is the call graph for this function:

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

Resize a Dlist object.

This discards the old object.

Parameters:
sizeis the number of elements in the re-sized list object

Reimplemented from grafalgo::List.

Definition at line 47 of file Dlist.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:


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