GPL_HashTable

GPL_HashTable

gpl

1998 12-05


CLASS

GPL_HashTable - non-intrusive hash table


SYNOPSIS

GPL_HashTable:

class user_defined_hashtable 
    : public GPL_HashTable<node_type, compare_type>
{
    public:
    user_defined_hashtable(long a_table_size) 
         : GPL_HashTable<node_type, compare_type>(a_table_size) {}
    long HashFunction(void *element);
    long Compare(void *node, void *element);
};

user_defined_hashtable htable(table_size);


GPL_IHashTable:


class node_type : public GPL_DoubleNode { };

class user_defined_ihashtable 
    : public GPL_IHashTable<node_type, compare_type>
{
    public:
    user_defined_hashtable(long a_table_size) 
         : GPL_HashTable<node_type, compare_type>(a_table_size) {}
    long HashFunction(void *element);
    long Compare(GPL_DoubleNode *node, void *element);
};

user_defined_ihashtable ihtable(table_size);


Both GPL_HashTable and GPL_IHashTable are hash table templates. Both are hash tables implemented with a linked list at each table location to handle multiple objects with the same hash value. Nodes are inserted and found in the table based on the Compare() function and some compare_type. Note that the compare_type handed to the hash table functions does not necessarily have to be a member data of node_type. However, a compare_type should not change for a node once it has been added to a hash table.


Class GPL_HashTable is implemented with non-intrusive linked lists (see GPL_DoubleList). Class GPL_IHashTable is implemented with intrusive linked lists (see GPL_IDoubleList). For an intrusive hash table, node_type must be derived from GPL_DoubleNode.


GPL_HashTable and GPL_IHashTable are intended to be base classes for user defined hash table classes. The virtual member functions HashFunction() and Compare() are to be defined in the user defined class.


CONSTRUCTOR


MEMBER FUNCTIONS