Grafalgo
Library of useful data structures and algorithms
|
Data structure representing a list of indexes. More...
#include <Dlist.h>
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 |
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.
grafalgo::Dlist::Dlist | ( | int | n1 = 26 | ) |
void grafalgo::Dlist::expand | ( | int | size | ) | [virtual] |
Expand the space available for this List.
Rebuilds old value in new space.
size | is the size of the resized object. |
Reimplemented from grafalgo::List.
Definition at line 55 of file Dlist.cpp.
void grafalgo::Dlist::freeSpace | ( | ) | [protected] |
Release dynamic storage used by this object.
Reimplemented from grafalgo::List.
Definition at line 41 of file Dlist.cpp.
index grafalgo::Dlist::get | ( | index | i | ) | const |
Get an index based on its position in the list.
i | is position of index to be returned; must be between 1 and n() |
Reimplemented from grafalgo::List.
bool grafalgo::Dlist::insert | ( | index | i, |
index | j | ||
) | [virtual] |
Insert an index into the list, relative to another.
i | is index to insert; if i is 0 or already in the list, no change is made |
j | is index after which i is to be inserted; if j == 0, i is inserted at the front of the list |
Reimplemented from grafalgo::List.
Definition at line 80 of file Dlist.cpp.
void grafalgo::Dlist::makeSpace | ( | int | size | ) | [protected] |
Allocate and initialize dynamic storage space.
size | is the number of elements for which space is to be allocated |
Reimplemented from grafalgo::List.
Definition at line 27 of file Dlist.cpp.
index grafalgo::Dlist::prev | ( | index | i | ) | const [inline] |
bool grafalgo::Dlist::remove | ( | index | i | ) |
bool grafalgo::Dlist::removeLast | ( | ) | [inline] |
bool grafalgo::Dlist::removeNext | ( | index | i | ) | [inline, virtual] |
Remove the index following a specified index.
i | is index whose successor is to be removed; if zero, the first index is removed |
Reimplemented from grafalgo::List.
Definition at line 65 of file Dlist.h.
void grafalgo::Dlist::resize | ( | int | size | ) | [virtual] |
Resize a Dlist object.
This discards the old object.
size | is the number of elements in the re-sized list object |
Reimplemented from grafalgo::List.
Definition at line 47 of file Dlist.cpp.