list.h
and astlist.h
.)
Throughout starlib
, there are many places where
a linked list is used. In every one of those cases, the
following primitive methods can be used on that list. There
are really two different classes that use lists. There is
the List<>
class and the
ASTlist<>
class. ASTlist
is a
class derived from the base class List
. Both
classes are template classes.
The main difference between ASTlist
and
List
are are so minor that as a user of this
library, you can ignore the differences. The ASTlist
was developed to keep track of some extra information that is
needed when handling lists of nodes in a the STAR tree, but the
differences do not show on the surface, and you can behave as
if the two classes act the same way:
A list has a concept of its "current" position. Each list can only have one such "current" position.
(Throughout the following list, "T" refers to the type that the
instantiation of List<>
or
ASTlist<>
was created to hold.)
constructors
List
creates an empty list. There is
also a copy constructor that copies the contents of one
List
into a new one.
void AddToEnd(T addme)
void AddToEnd(const List &addme)
List
as the parameter - this copies the entire
contents of the passed list onto the end of this list.
Currently there is no provision for adding things to the middle of the list, only at the end.
void FreeList()
void RemoveCurrent()
void AlterCurrent(T setToMe)
void MemorizeCurrent()
List
can only remember one such value at a time.
void RestoreCurrent()
MemorizeCurrent()
was called. (see above).
int Length() const
bool Lookup(T findMe)
true
is returned.
bool SeekTo(T findMe)
Lookup()
, but
it also moves the current pointer to the location
given.
void Reset()
void Next()
void Prev()
bool AtEnd()
bool AtStart()
true
if the current has
passed the end of the list for AtEnd()
, or
is at the start of the list for AtStart()
T Current() const
T Last() const
operator ==