General information:Author: klaasje Version: 1.0 Date: Wed Oct 20 9:03:04 MET 1999 |
Header files:
|
Code files:
|
template class DL_StackIter
class for stack iterator on DL_List
template stack iterator for any list/node type
This class is the base class to attach/instantiate a stack iterator on a double linked list DL_List. The stack iterator is used to push and pop objects to and from the beginning of a list. class
Dtype
Object for traversing a DL_List of the same Dtype
| scope: public | purpose: normal | inline?: no | function property: standard | type: basic | typename: NONE |
Declaration:
DL_StackIter(DL_List<Dtype> *)
Description:
Constructor of stack iterator for given list
| scope: public | purpose: normal | inline?: no | function property: standard | type: basic | typename: NONE |
Declaration:
DL_StackIter()
Description:
Constructor of stack iterator no list attached
| scope: public | purpose: normal | inline?: no | function property: standard | type: basic | typename: NONE |
Declaration:
~DL_StackIter()
Description:
Destructor of stack iterator
| scope: public | purpose: normal | inline?: no | function property: standard | type: basic | typename: void |
Declaration:
void remove_all()
Description:
Remove all items from the stack
| scope: public | purpose: normal | inline?: no | function property: standard | type: basic | typename: void |
Declaration:
void push(Dtype n)
Description:
push given item on the stack
| scope: public | purpose: normal | inline?: no | function property: standard | type: basic | typename: Dtype |
Declaration:
Dtype pop()
Description:
get last inserted item from stack
| scope: public | purpose: normal | inline?: no | function property: standard | type: basic | typename: G_BOOL |
Declaration:
G_BOOL empty()
Description:
is stack empty?
| scope: public | purpose: normal | inline?: no | function property: standard | type: basic | typename: int |
Declaration:
int count()
Description:
number of items on the stack
How to work with a stack iterator for a list of type integer| to push a and b, pop a into list and remove_all directly using a stack iterator
DL_List<int>* a_list = new DL_List<int>();# declaration and allocation
int a=123;
int b=345;
{
DL_StackIter<int>* a_listiter=new DL_StackIter<int>(a_list);
a_listiter->push(a)
a_listiter->push(b)
a_listiter->pop()
a_listiter->remove_all()
} //to destruct the iterator before the list is deleted
delete a_list; #delete it (must have no iterators attached to it)