Tools.h++ Manual
22-6 104011 Tandem Computers Incorporated
22
Example
Program Output:
zero
one
two
Public constructors
RWTIsvDlist();
Constructs an empty list.
RWTIsvDlist(T* a);
Constructs a list with the single item pointed to by
a
in it.
Public Members Functions
void append(T* a);
Appends the item pointed to by
a
to the end of the list.
#include <rw/tidlist.h>
#include <rw/rstream.h>
#include <string.h>
struct Symbol : public RWIsvDlink {
char name[10];
Symbol( const char* cs)
{ strncpy(name, cs, sizeof(name)); name[9] = '\0'; }
};
void printem(Symbol* s, void*) { cout << s->name << endl; }
main(){
RWTIsvDlist<Symbol> list;
list.insert( new Symbol("one") );
list.insert( new Symbol("two") );
list.prepend( new Symbol("zero") );
list.apply(printem, 0);
list.clearAndDestroy(); // Deletes the items inserted into the
list
return 0;
}