WvStreams
wvhash.h
00001 /* -*- Mode: C++ -*-
00002  * Worldvisions Weaver Software:
00003  *   Copyright (C) 1997-2002 Net Integration Technologies, Inc.
00004  *
00005  * Common hash functions for use with wvscatterhash.h and wvhashtable.h.
00006  */
00007 #ifndef __WVHASH_H
00008 #define __WVHASH_H
00009 
00010 #include "wvstring.h"
00011 
00012 // predefined hashing functions (note: string hashes are case-insensitive)
00013 unsigned WvHash(WvStringParm s);
00014 unsigned WvHash(const char *s);
00015 unsigned WvHash(const int &i);
00016 unsigned WvHash(const void *p);
00017 
00018 
00019 // Default comparison function used by WvHashTable
00020 template <class K>
00021 struct OpEqComp
00022 {
00023     static bool compare(const K *key1, const K *key2)
00024         { return *key1 == *key2; }
00025 };
00026 
00027 
00028 // Case-insensitive comparison function for WvHashTable
00029 template <class K>
00030 struct StrCaseComp
00031 {
00032     static bool compare(const K *key1, const K *key2)
00033         { return strcasecmp(*key1, *key2) == 0; }
00034 };
00035 
00036 #endif // __WVHASH_H