StringList
class is privately derived from the
SequentialList
class, an extremely useful class used throughout Ptolemy. This class implements a linked list with a running count of the number of elements. It uses the
generic pointer technique, with
StringList
, this generic pointer is converted to a specific type of pointer, like const char*
. The methods are summarized in table
An important point to keep in mind when using a
SequentialList
is that its destructor does not delete the elements in the list. It would not be possible to do so, since it has only a generic pointer. Also, note that random access (by element number, or any other method) can be very inefficient, since it would require sequentially chaining down the list.SequentialList
has an iterator class called
ListIter
. The ++
operator (or next
member function) returns a Pointer
.SequentialList
,
Queue
and
Stack
. The first of these can implement either a
first-in, first-out (FIFO) queue, or a
last-in, first-out (LIFO) queue. The second implements a stack, which is also a LIFO queue.