hashfunc.h File Reference

#include <string>
#include <cctype>
#include "string/string.h"
#include "container/array.h"
Include dependency graph for hashfunc.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

class  ub1_default_traits
class  ub1_nocase_traits
class  ub1x4_default_traits
class  ub1x4_nocase_traits
class  ub4_default_traits
class  ub4_nocase_traits
struct  RawStringHash
struct  HashString
struct  HashStringNoCase
class  HashKey< UB4Traits >
 Hashable key type that stores a string as an array of ub4 - making hashing faster. Also caches the 32-bit result of the hash to speed up comparison of keys. More...
struct  HashKeyHasher
 Hash function to use with HashKey. More...

Defines

#define INCLUDED_CONTAINER_HASHFUNC_H
#define hashsize(n)   ((ub4)1<<(n))
#define hashmask(n)   (hashsize(n)-1)
#define mix(a, b, c)
#define mix2(a, b, c)

Typedefs

typedef unsigned long int ub4
typedef unsigned char ub1
typedef ub4 hash_t

Functions

ub1 ub1_as_ub1_nocase (ub1 byte)
ub4 ub1x4_as_ub4_nocase (const ub1 bytes[4])
template<typename UB1Traits , typename UB4x1Traits >
ub4 hash (const ub1 *k, ub4 length, ub4 initval, const UB1Traits &ub1traits, const UB4x1Traits &ub4x1traits)
template<typename UB4Traits >
ub4 hash2 (const ub4 *k, ub4 length, ub4 initval, const UB4Traits &ub4traits)
hash_t hash_ub1 (const ub1 *key, std::size_t len, hash_t previous=0)
hash_t hash_ub1_nocase (const ub1 *key, std::size_t len, hash_t previous=0)
template<typename UB4Traits >
hash_t hash_ub4 (const ub4 *key, std::size_t len, const UB4Traits &traits, hash_t previous=0)
ub4 hash_combine (ub4 left, ub4 right)
template<typename POD >
hash_t pod_hash (const POD &pod)
hash_t string_hash (const char *string, hash_t previous=0)
hash_t string_hash_nocase (const char *string, hash_t previous=0)
std::size_t string_length_ub4 (const char *string)
 Length of a string in ub4. "wibble" (6) gives 2, "and" (3) gives 1, "bleh" (4) gives 2.

Define Documentation

#define hashmask (  )     (hashsize(n)-1)

Definition at line 92 of file hashfunc.h.

#define hashsize (  )     ((ub4)1<<(n))

Definition at line 91 of file hashfunc.h.

#define INCLUDED_CONTAINER_HASHFUNC_H

Definition at line 23 of file hashfunc.h.

#define mix ( a,
b,
 ) 
Value:
{ \
  a -= b; a -= c; a ^= (c>>13); \
  b -= c; b -= a; b ^= (a<<8); \
  c -= a; c -= b; c ^= (b>>13); \
  a -= b; a -= c; a ^= (c>>12);  \
  b -= c; b -= a; b ^= (a<<16); \
  c -= a; c -= b; c ^= (b>>5); \
  a -= b; a -= c; a ^= (c>>3);  \
  b -= c; b -= a; b ^= (a<<10); \
  c -= a; c -= b; c ^= (b>>15); \
}

Definition at line 120 of file hashfunc.h.

Referenced by hash(), and hash2().

#define mix2 ( a,
b,
 ) 
Value:
{ \
  a -= b; a -= c; a ^= (c>>13); \
  b -= c; b -= a; b ^= (a<< 8); \
  c -= a; c -= b; c ^= ((b&0xffffffff)>>13); \
  a -= b; a -= c; a ^= ((c&0xffffffff)>>12); \
  b -= c; b -= a; b = (b ^ (a<<16)) & 0xffffffff; \
  c -= a; c -= b; c = (c ^ (b>> 5)) & 0xffffffff; \
  a -= b; a -= c; a = (a ^ (c>> 3)) & 0xffffffff; \
  b -= c; b -= a; b = (b ^ (a<<10)) & 0xffffffff; \
  c -= a; c -= b; c = (c ^ (b>>15)) & 0xffffffff; \
}

Definition at line 134 of file hashfunc.h.


Typedef Documentation

typedef ub4 hash_t

Definition at line 280 of file hashfunc.h.

typedef unsigned char ub1

Definition at line 30 of file hashfunc.h.

typedef unsigned long int ub4

Definition at line 29 of file hashfunc.h.


Function Documentation

template<typename UB1Traits , typename UB4x1Traits >
ub4 hash ( const ub1 k,
ub4  length,
ub4  initval,
const UB1Traits &  ub1traits,
const UB4x1Traits &  ub4x1traits 
) [inline]
template<typename UB4Traits >
ub4 hash2 ( const ub4 k,
ub4  length,
ub4  initval,
const UB4Traits &  ub4traits 
) [inline]

Definition at line 242 of file hashfunc.h.

References len, and mix.

Referenced by hash_ub4().

ub4 hash_combine ( ub4  left,
ub4  right 
) [inline]

Definition at line 295 of file hashfunc.h.

References hash_ub1().

hash_t hash_ub1 ( const ub1 key,
std::size_t  len,
hash_t  previous = 0 
) [inline]

Definition at line 282 of file hashfunc.h.

References hash().

Referenced by hash_combine(), pod_hash(), and string_hash().

hash_t hash_ub1_nocase ( const ub1 key,
std::size_t  len,
hash_t  previous = 0 
) [inline]

Definition at line 286 of file hashfunc.h.

References hash().

Referenced by string_hash_nocase().

template<typename UB4Traits >
hash_t hash_ub4 ( const ub4 key,
std::size_t  len,
const UB4Traits &  traits,
hash_t  previous = 0 
) [inline]

Definition at line 291 of file hashfunc.h.

References hash2().

Referenced by HashKey< UB4Traits >::copy().

template<typename POD >
hash_t pod_hash ( const POD &  pod  )  [inline]

Definition at line 300 of file hashfunc.h.

References hash_ub1().

hash_t string_hash ( const char *  string,
hash_t  previous = 0 
) [inline]

Definition at line 304 of file hashfunc.h.

References hash_ub1().

Referenced by HashString::operator()(), and RawStringHash::operator()().

hash_t string_hash_nocase ( const char *  string,
hash_t  previous = 0 
) [inline]

Definition at line 308 of file hashfunc.h.

References hash_ub1_nocase().

Referenced by HashStringNoCase::operator()().

std::size_t string_length_ub4 ( const char *  string  )  [inline]

Length of a string in ub4. "wibble" (6) gives 2, "and" (3) gives 1, "bleh" (4) gives 2.

Definition at line 337 of file hashfunc.h.

Referenced by HashKey< UB4Traits >::operator=().

ub1 ub1_as_ub1_nocase ( ub1  byte  )  [inline]

Definition at line 32 of file hashfunc.h.

Referenced by ub1_nocase_traits::as_ub1(), and ub1x4_as_ub4_nocase().

ub4 ub1x4_as_ub4_nocase ( const ub1  bytes[4]  )  [inline]

Definition at line 36 of file hashfunc.h.

References ub1_as_ub1_nocase().

Referenced by ub4_nocase_traits::as_ub4(), and ub1x4_nocase_traits::as_ub4().


Generated by  doxygen 1.6.2