TORCS  1.3.9
The Open Racing Car Simulator
hash.cpp File Reference

Hash API. More...

#include <tgf.h>
Include dependency graph for hash.cpp:

Go to the source code of this file.

Classes

struct  HashElem
 
struct  HashHeader
 

Macros

#define HASH_BYTE(x, y)   (((y) + ((x) << 4) + ((x) >> 4)) * 11)
 
#define DEFAULT_SIZE   32
 

Typedefs

typedef struct HashElem tHashElem
 
typedef struct HashHeader tHashHeader
 

Functions

 GF_TAILQ_HEAD (HashHead, tHashElem)
 
static unsigned int hash_str (tHashHeader *hash, const char *sstr)
 
static unsigned int hash_buf (tHashHeader *hash, char *sdata, int len)
 
void * GfHashCreate (int type)
 Create a new hash table. More...
 
static void gfIncreaseHash (tHashHeader *curHeader)
 Double the size of the hash table. More...
 
int GfHashAddStr (void *hash, const char *key, const void *data)
 Add an element with a string key to a hash table. More...
 
static const void * gfRemElem (tHashHead *hashHead, tHashElem *elem)
 Remove a table element. More...
 
const void * GfHashRemStr (void *hash, char *key)
 Remove an element with a string key from a hash table. More...
 
const void * GfHashGetStr (void *hash, const char *key)
 Get the user data associated with a string key. More...
 
void GfHashAddBuf (void *hash, char *key, size_t sz, void *data)
 Add an element with a memory buffer key to a hash table. More...
 
const void * GfHashRemBuf (void *hash, char *key, size_t sz)
 Remove an element with a memory buffer key from a hash table. More...
 
const void * GfHashGetBuf (void *hash, char *key, size_t sz)
 Get the user data associated with a memory buffer key. More...
 
void GfHashRelease (void *hash, tfHashFree hashFree)
 Release a hash table. More...
 
const void * GfHashGetFirst (void *hash)
 Get the first user data of a hash table, this is used for table scans. More...
 
const void * GfHashGetNext (void *hash)
 Get the next user data of a hash table, this is used for table scans. More...
 

Detailed Description

Hash API.

Author
Bernhard Wymann, Eric Espie
Version
$Id$

Definition in file hash.cpp.

Macro Definition Documentation

◆ DEFAULT_SIZE

#define DEFAULT_SIZE   32

Definition at line 51 of file hash.cpp.

◆ HASH_BYTE

#define HASH_BYTE (   x,
  y 
)    (((y) + ((x) << 4) + ((x) >> 4)) * 11)

Definition at line 50 of file hash.cpp.

Typedef Documentation

◆ tHashElem

typedef struct HashElem tHashElem

◆ tHashHeader

typedef struct HashHeader tHashHeader

Function Documentation

◆ GF_TAILQ_HEAD()

GF_TAILQ_HEAD ( HashHead  ,
tHashElem   
)

◆ gfIncreaseHash()

static void gfIncreaseHash ( tHashHeader curHeader)
static

Double the size of the hash table.

Definition at line 122 of file hash.cpp.

Here is the call graph for this function:

◆ gfRemElem()

static const void* gfRemElem ( tHashHead *  hashHead,
tHashElem elem 
)
static

Remove a table element.

Definition at line 201 of file hash.cpp.

◆ hash_buf()

static unsigned int hash_buf ( tHashHeader hash,
char *  sdata,
int  len 
)
static

Definition at line 74 of file hash.cpp.

◆ hash_str()

static unsigned int hash_str ( tHashHeader hash,
const char *  sstr 
)
static

Definition at line 54 of file hash.cpp.