Inexor
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Macros | Functions
cube_hash.hpp File Reference
#include "inexor/shared/cube_types.hpp"
#include "inexor/shared/cube_loops.hpp"
#include "inexor/shared/cube_tools.hpp"
#include <string.h>

Go to the source code of this file.

Classes

struct  hashbase< H, E, K, T >
 
struct  hashbase< H, E, K, T >::chain
 
struct  hashbase< H, E, K, T >::chainchunk
 
struct  hashset< T >
 
struct  hashnameset< T >
 
struct  hashtableentry< K, T >
 
struct  hashtable< K, T >
 

Macros

#define HTFIND(success, fail)
 
#define enumeratekt(ht, k, e, t, f, b)   loopi((ht).size) for(void *ec = (ht).chains[i]; ec;) { k &e = (ht).enumkey(ec); t &f = (ht).enumdata(ec); ec = (ht).enumnext(ec); b; }
 
#define enumerate(ht, t, e, b)   loopi((ht).size) for(void *ec = (ht).chains[i]; ec;) { t &e = (ht).enumdata(ec); ec = (ht).enumnext(ec); b; }
 

Functions

static uint memhash (const void *ptr, int len)
 Legacy Hashing algorithms and hashmap-implementation. More...
 
static uint hthash (const stringslice &s)
 
static bool htcmp (const stringslice &x, const char *y)
 
static uint hthash (int key)
 
static bool htcmp (int x, int y)
 compares values of x and y More...
 
static uint hthash (const char *key)
 
static bool htcmp (const char *x, const char *y)
 

Class Documentation

struct hashbase::chain

template<class H, class E, class K, class T>
struct hashbase< H, E, K, T >::chain

Class Members
E elem
chain * next
struct hashbase::chainchunk

template<class H, class E, class K, class T>
struct hashbase< H, E, K, T >::chainchunk

Class Members
chain chains[CHUNKSIZE]
chainchunk * next
struct hashtableentry

template<class K, class T>
struct hashtableentry< K, T >

Class Members
T data
K key

Macro Definition Documentation

#define enumerate (   ht,
  t,
  e,
 
)    loopi((ht).size) for(void *ec = (ht).chains[i]; ec;) { t &e = (ht).enumdata(ec); ec = (ht).enumnext(ec); b; }
#define enumeratekt (   ht,
  k,
  e,
  t,
  f,
 
)    loopi((ht).size) for(void *ec = (ht).chains[i]; ec;) { k &e = (ht).enumkey(ec); t &f = (ht).enumdata(ec); ec = (ht).enumnext(ec); b; }
#define HTFIND (   success,
  fail 
)
Value:
uint h = hthash(key)&(this->size-1); \
for(chain *c = this->chains[h]; c; c = c->next) \
{ \
if(htcmp(key, H::getkey(c->elem))) return success H::getdata(c->elem); \
} \
return (fail);
unsigned int uint
Definition: cube_types.hpp:9
static bool htcmp(const stringslice &x, const char *y)
Definition: cube_hash.hpp:24
if(NOT DEFINED PROJECT_ARCH) message(FATAL_ERROR"You are generating from the wrong folder! \"Where is the Source
Definition: CMakeLists.txt:2
GLuint GLuint GLintptr GLsizeiptr size
Definition: glexts.hpp:412
static uint hthash(const stringslice &s)
Definition: cube_hash.hpp:22

Referenced by hashbase< hashtable< animmodel::shaderparams, animmodel::shaderparamskey >, hashtableentry< animmodel::shaderparams, animmodel::shaderparamskey >, animmodel::shaderparams, animmodel::shaderparamskey >::access(), hashbase< hashtable< animmodel::shaderparams, animmodel::shaderparamskey >, hashtableentry< animmodel::shaderparams, animmodel::shaderparamskey >, animmodel::shaderparams, animmodel::shaderparamskey >::find(), and hashbase< hashtable< animmodel::shaderparams, animmodel::shaderparamskey >, hashtableentry< animmodel::shaderparams, animmodel::shaderparamskey >, animmodel::shaderparams, animmodel::shaderparamskey >::operator[]().

Function Documentation

static bool htcmp ( const stringslice x,
const char *  y 
)
inlinestatic
static bool htcmp ( int  x,
int  y 
)
inlinestatic

compares values of x and y

static bool htcmp ( const char *  x,
const char *  y 
)
inlinestatic
static uint hthash ( const stringslice s)
inlinestatic
static uint hthash ( int  key)
inlinestatic
static uint hthash ( const char *  key)
inlinestatic

bernstein k=33 xor

static uint memhash ( const void ptr,
int  len 
)
inlinestatic

Legacy Hashing algorithms and hashmap-implementation.

Avoid this by all means in new code. Those hashing functions are order of magnitudes slower than their std::map and std::unordered_map equivalents. They offer specialisations for more types by house (e.g. char*) though.

Referenced by hthash().