// // Basic Summary: hash table // // Include file for table definition // // Copyright: // // Copyright 1993 Ron Burback // Copyright 1993 Objects Plus // All rights reserved // // Description: // open hash table, we have a fixed number of hash locations // each location is represented by a dynamic array (a list) // // // Data elemnents: // an array of the dynamic arrays // // // Methods: // // The methods are // table(); - standard constructor // ~table(); - standard disctructor // void * peak(void * key); - lookup an element, do not remove // void * get(void * key); - look up an element and remove // void set(void * key, void * data ); - add an element, if already exists ignore // natural hash(void * key) ; - the hash function // Boolean compare(key1, key2) ; are the two keys equal? // // static Boolean test(); = quality assurance test // // Macro definitions: // the size of the hash table array // // // Class definition: // // table // #ifndef _OP_TABLE #define _OP_TABLE #include "standard.h" #include "circular_buffer.h" #include "linked_chunk.h" #include "dynamic_array.h" #include "pool.h" #define HASH_BASE 16 #define RE_HASH_THRESHOLD 5*CHUNK_SIZE class table { private: dynamic_array * storage ; natural water_mark ; natural hash_base ; public: static char * version ; static pool ThePool ; table(); ~table(); void * peak(void * key); void * get(void * key); void set(void * key, void * data); virtual natural hash(void * key) ; virtual Boolean compare (void * key1, void * key2) ; natural location (void * key); void expand () ; static Boolean test(); void * operator new(size_t) { return ThePool.alloc(); }; void operator delete(void * p) { ThePool.free(p); }; }; #endif