home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The C Users' Group Library 1994 August
/
wc-cdrom-cusersgrouplibrary-1994-08.iso
/
listings
/
v_09_06
/
9n06058a
< prev
next >
Wrap
Text File
|
1991-02-25
|
958b
|
56 lines
// class ThingList -- a list of Things
//
// Version 1.0 -- 2/25/91
//
// Michael Kelly -- Author
//
// See class Thing ( Thing.hpp )
//
#if !defined(TH_LIST_HPP)
#define TH_LIST_HPP
#include "thing.hpp"
class ThingList {
struct thing_node {
thing_node *next;
Thing *this_thing;
};
thing_node *head,
*rover;
unsigned nodes;
public:
ThingList()
{
head = rover = NULL;
nodes = 0;
}
ThingList( Thing &some_thing )
{
if( head = new thing_node ) {
head->this_thing = &some_thing;
head->next = NULL;
nodes = 1;
}
else {
head = rover = NULL;
nodes = 0;
}
}
~ThingList();
int add( Thing &some_thing );
unsigned iterate( void ( Thing::*funcptr )() );
unsigned iterate( int ( Thing::*funcptr )() );
Thing *operator[]( unsigned index );
unsigned list_nodes() { return nodes; }
};
#endif