first check-in of feisty meow codebase. many things broken still due to recent
[feisty_meow.git] / core / library / structures / string_hasher.h
1 #ifndef STRING_HASHER_CLASS
2 #define STRING_HASHER_CLASS
3
4 /*****************************************************************************\
5 *                                                                             *
6 *  Name   : string_hasher                                                     *
7 *  Author : Chris Koeritz                                                     *
8 *                                                                             *
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 \*****************************************************************************/
17
18 #include "hash_table.h"
19
20 namespace structures {
21
22 //! Implements a simple hashing algorithm for strings.
23 /*! This uses a portion of the string's contents to create a hash value. */
24
25 class string_hasher : public virtual hashing_algorithm
26 {
27 public:
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). */
34
35   virtual hashing_algorithm *clone() const;
36     //!< implements cloning of the algorithm object.
37 };
38
39 //////////////
40
41 class astring_hasher : public virtual hashing_algorithm
42 {
43 public:
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.
46
47   virtual hashing_algorithm *clone() const;
48     //!< implements cloning of the algorithm object.
49 };
50
51 } //namespace.
52
53 #endif
54