// generictable.h // // Generic Data Structures // Tables (dictionaries) // Written by Tim Budd // Oregon State University // June 1991 // // // copyrighted but can be freely redistributed as long as notice // of authorship is retained. # ifndef generictable # define generictable // ********************************************************* // Associations // ********************************************************* class genericAssociation { private: void * k; void * v; public: genericAssociation(void * ky) : k(ky) { v = 0; } void * key() { return k; } void * & value() { return v; } virtual int match (void *); }; // ********************************************************* // Tables // ********************************************************* class genericAssociationList; // forward declaration class genericTable { public: genericTable (int sz = 17); // constructor: size of table ~genericTable(); void first(); void next(); protected: const int tablesize; genericAssociationList * elements; int index; virtual unsigned int hash(void *); virtual genericAssociation * makeAssociation(void *); void * & operator [] (void *); void * current(); int includesKey(void *); void removeKey(void *); }; # endif