EvEmu  0.8.4
11 September 2021
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Utils::Hash Class Reference

a class to keep track of all the utility hash functions More...

#include "Util.h"

Static Public Member Functions

static uint32 djb2_hash (const char *str)
 djb2 algorithm taken from http://www.cse.yorku.ca/~oz/hash.html slightly modified More...
 
static uint32 djb2_hash (const wchar_t *str)
 djb2 algorithm taken from http://www.cse.yorku.ca/~oz/hash.html slightly modified More...
 
static uint32 djb2_hash (const std::string &oStr)
 djb2 algorithm taken from http://www.cse.yorku.ca/~oz/hash.html slightly modified More...
 
static uint32 djb2_hash (const std::wstring &oStr)
 djb2 algorithm taken from http://www.cse.yorku.ca/~oz/hash.html slightly modified More...
 
static uint32 djb2_hash (const char *str, int len)
 djb2 algorithm taken from http://www.cse.yorku.ca/~oz/hash.html slightly modified More...
 
static uint32 sdbm_hash (std::string &oStr)
 sdbm algorithm taken from http://www.cse.yorku.ca/~oz/hash.html slightly modified More...
 
static uint32 sdbm_hash (const char *str)
 sdbm algorithm taken from http://www.cse.yorku.ca/~oz/hash.html slightly modified More...
 
static uint32 sdbm_hash (const wchar_t *str)
 sdbm algorithm taken from http://www.cse.yorku.ca/~oz/hash.html slightly modified More...
 
static uint32 sdbm_hash (const char *str, int len)
 sdbm algorithm taken from http://www.cse.yorku.ca/~oz/hash.html slightly modified More...
 

Detailed Description

a class to keep track of all the utility hash functions

Author
Captnoord.
Date
January 2009

Definition at line 249 of file Util.h.

Member Function Documentation

static uint32 Utils::Hash::djb2_hash ( const char *  str)
inlinestatic

djb2 algorithm taken from http://www.cse.yorku.ca/~oz/hash.html slightly modified

Parameters
[in]oStrstring that needs to be hashed.
Returns
djb2 hash of the string.

Definition at line 260 of file Util.h.

261  {
262  uint32 hash = 5381;
263  int c;
264 
265  while ((c = *str++))
266  hash = ((hash << 5) + hash) + c; /* hash * 33 + c */
267 
268  return hash;
269  }
unsigned __int32 uint32
Definition: eve-compat.h:50
static uint32 Utils::Hash::djb2_hash ( const wchar_t *  str)
inlinestatic

djb2 algorithm taken from http://www.cse.yorku.ca/~oz/hash.html slightly modified

Parameters
[in]oStrstring that needs to be hashed.
Returns
djb2 hash of the string.

Definition at line 279 of file Util.h.

280  {
281  uint32 hash = 5381;
282  int c;
283 
284  while ((c = *str++))
285  hash = ((hash << 5) + hash) + c; /* hash * 33 + c */
286 
287  return hash;
288  }
unsigned __int32 uint32
Definition: eve-compat.h:50
static uint32 Utils::Hash::djb2_hash ( const std::string &  oStr)
inlinestatic

djb2 algorithm taken from http://www.cse.yorku.ca/~oz/hash.html slightly modified

Parameters
[in]oStrstring that needs to be hashed.
Returns
djb2 hash of the string.

Definition at line 298 of file Util.h.

299  {
300  const char * str = oStr.c_str();
301 
302  uint32 hash = 5381;
303  int c;
304 
305  while ((c = *str++))
306  hash = ((hash << 5) + hash) + c; /* hash * 33 + c */
307 
308  return hash;
309  }
unsigned __int32 uint32
Definition: eve-compat.h:50
static uint32 Utils::Hash::djb2_hash ( const std::wstring &  oStr)
inlinestatic

djb2 algorithm taken from http://www.cse.yorku.ca/~oz/hash.html slightly modified

Parameters
[in]oStrstring that needs to be hashed.
Returns
djb2 hash of the string.

Definition at line 319 of file Util.h.

320  {
321  const wchar_t * str = oStr.c_str();
322 
323  uint32 hash = 5381;
324  int c;
325 
326  while ((c = *str++))
327  hash = ((hash << 5) + hash) + c; /* hash * 33 + c */
328 
329  return hash;
330  }
unsigned __int32 uint32
Definition: eve-compat.h:50
static uint32 Utils::Hash::djb2_hash ( const char *  str,
int  len 
)
inlinestatic

djb2 algorithm taken from http://www.cse.yorku.ca/~oz/hash.html slightly modified

Parameters
[in]strstring that needs to be hashed.
[in]lenthe size of the string.
Returns
djb2 hash of the string.

Definition at line 341 of file Util.h.

342  {
343  uint32 hash = 5381;
344  int c, i;
345 
346  for (i = 0; i < len; i++)
347  {
348  c = str[i];
349  hash = ((hash << 5) + hash) + c; /* hash * 33 + c */
350  }
351 
352  return hash;
353  }
unsigned __int32 uint32
Definition: eve-compat.h:50
static uint32 Utils::Hash::sdbm_hash ( std::string &  oStr)
inlinestatic

sdbm algorithm taken from http://www.cse.yorku.ca/~oz/hash.html slightly modified

Parameters
[in]oStrstring that needs to be hashed.
Returns
sdbm hash of the string.

Definition at line 363 of file Util.h.

364  {
365  uint8 *str = (uint8*)oStr.c_str();
366  uint32 hash = 0;
367  int c;
368 
369  while ((c = *str++))
370  hash = c + (hash << 6) + (hash << 16) - hash;
371 
372  return hash;
373  }
unsigned __int8 uint8
Definition: eve-compat.h:46
unsigned __int32 uint32
Definition: eve-compat.h:50
static uint32 Utils::Hash::sdbm_hash ( const char *  str)
inlinestatic

sdbm algorithm taken from http://www.cse.yorku.ca/~oz/hash.html slightly modified

Parameters
[in]oStrstring that needs to be hashed.
Returns
sdbm hash of the string.

Definition at line 383 of file Util.h.

384  {
385  uint32 hash = 0;
386  int c;
387 
388  while ((c = *str++))
389  hash = c + (hash << 6) + (hash << 16) - hash;
390 
391  return hash;
392  }
unsigned __int32 uint32
Definition: eve-compat.h:50
static uint32 Utils::Hash::sdbm_hash ( const wchar_t *  str)
inlinestatic

sdbm algorithm taken from http://www.cse.yorku.ca/~oz/hash.html slightly modified

Parameters
[in]oStrstring that needs to be hashed.
Returns
sdbm hash of the string.

Definition at line 402 of file Util.h.

403  {
404  uint32 hash = 0;
405  int c;
406 
407  while ((c = *str++))
408  hash = c + (hash << 6) + (hash << 16) - hash;
409 
410  return hash;
411  }
unsigned __int32 uint32
Definition: eve-compat.h:50
static uint32 Utils::Hash::sdbm_hash ( const char *  str,
int  len 
)
inlinestatic

sdbm algorithm taken from http://www.cse.yorku.ca/~oz/hash.html slightly modified

Parameters
[in]oStrstring that needs to be hashed.
[in]lenlength of the string that needs to be hashed.
Returns
sdbm hash of the string.

Definition at line 422 of file Util.h.

423  {
424  uint32 hash = 0;
425  int c;
426 
427  for (int i = 0; i < len; i++)
428  {
429  c = str[i];
430  hash = c + (hash << 6) + (hash << 16) - hash;
431  }
432 
433  return hash;
434  }
unsigned __int32 uint32
Definition: eve-compat.h:50

The documentation for this class was generated from the following file: