1 #ifndef STRING_HASHER_CLASS
2 #define STRING_HASHER_CLASS
4 /*****************************************************************************\
6 * Name : string_hasher *
7 * Author : Chris Koeritz *
9 *******************************************************************************
10 * Copyright (c) 2001-$now By Author. This program is free software; you can *
11 * redistribute it and/or modify it under the terms of the GNU General Public *
12 * License as published by the Free Software Foundation; either version 2 of *
13 * the License or (at your option) any later version. This is online at: *
14 * http://www.fsf.org/copyleft/gpl.html *
15 * Please send any updates to: fred@gruntose.com *
16 \*****************************************************************************/
18 #include "hash_table.h"
20 namespace structures {
22 //! Implements a simple hashing algorithm for strings.
23 /*! This uses a portion of the string's contents to create a hash value. */
25 class string_hasher : public virtual hashing_algorithm
28 virtual basis::un_int hash(const void *key_data, int key_length) const;
29 //!< returns a value that can be used to index into a hash table.
30 /*!< the returned value is loosely based on the "key_data" and the
31 "key_length" we are provided with. it is expected that the "key_data"
32 really is a 'char' pointer whose length is "key_length" (including the
33 zero terminator at the end). */
35 virtual hashing_algorithm *clone() const;
36 //!< implements cloning of the algorithm object.
41 class astring_hasher : public virtual hashing_algorithm
44 virtual basis::un_int hash(const void *key_data, int key_length) const;
45 //!< similar to string_hasher, but expects "key_data" as an astring pointer.
47 virtual hashing_algorithm *clone() const;
48 //!< implements cloning of the algorithm object.