Tools.h++ Manual
22-14 104011 Tandem Computers Incorporated
22
Example
Program Output:
zero
one
two
Public constructors
RWTIsvSlist();
Constructs an empty list.
RWTIsvSlist(T* a);
Constructs a list with the single item pointed to by
a
in it.
Public member functions
void append(T* a);
Appends the item pointed to by
a
to the end of the list.
#include <rw/tislist.h>
#include <rw/rstream.h>
#include <string.h>
struct Symbol : public RWIsvSlink {
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(){
RWTIsvSlist<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;
}