remake  4.3+dbg-1.5
Data Structures | Macros | Typedefs | Functions | Variables
hash.h File Reference
#include <stdio.h>
#include <ctype.h>

Go to the source code of this file.

Data Structures

struct  hash_table
 

Macros

#define __P(protos)   ()
 
#define HASH_VACANT(item)   ((item) == 0 || (void *) (item) == hash_deleted_item)
 
#define STRING_HASH_1(KEY, RESULT)
 
#define return_STRING_HASH_1(KEY)
 
#define STRING_HASH_2(KEY, RESULT)
 
#define return_STRING_HASH_2(KEY)
 
#define STRING_COMPARE(X, Y, RESULT)
 
#define return_STRING_COMPARE(X, Y)
 
#define STRING_N_HASH_1(KEY, N, RESULT)
 
#define return_STRING_N_HASH_1(KEY, N)
 
#define STRING_N_HASH_2(KEY, N, RESULT)
 
#define return_STRING_N_HASH_2(KEY, N)
 
#define STRING_N_COMPARE(X, Y, N, RESULT)
 
#define return_STRING_N_COMPARE(X, Y, N)
 
#define ISTRING_HASH_1(KEY, RESULT)   STRING_HASH_1 ((KEY), (RESULT))
 
#define return_ISTRING_HASH_1(KEY)   return_STRING_HASH_1 (KEY)
 
#define ISTRING_HASH_2(KEY, RESULT)   STRING_HASH_2 ((KEY), (RESULT))
 
#define return_ISTRING_HASH_2(KEY)   return_STRING_HASH_2 (KEY)
 
#define ISTRING_COMPARE(X, Y, RESULT)   STRING_COMPARE ((X), (Y), (RESULT))
 
#define return_ISTRING_COMPARE(X, Y)   return_STRING_COMPARE ((X), (Y))
 
#define INTEGER_HASH_1(KEY, RESULT)
 
#define return_INTEGER_HASH_1(KEY)
 
#define INTEGER_HASH_2(KEY, RESULT)
 
#define return_INTEGER_HASH_2(KEY)
 
#define INTEGER_COMPARE(X, Y, RESULT)
 
#define return_INTEGER_COMPARE(X, Y)
 
#define ADDRESS_HASH_1(KEY, RESULT)   INTEGER_HASH_1 (((unsigned long)(KEY)) >> 3, (RESULT))
 
#define ADDRESS_HASH_2(KEY, RESULT)   INTEGER_HASH_2 (((unsigned long)(KEY)) >> 3, (RESULT))
 
#define ADDRESS_COMPARE(X, Y, RESULT)   INTEGER_COMPARE ((X), (Y), (RESULT))
 
#define return_ADDRESS_HASH_1(KEY)   return_INTEGER_HASH_1 (((unsigned long)(KEY)) >> 3)
 
#define return_ADDRESS_HASH_2(KEY)   return_INTEGER_HASH_2 (((unsigned long)(KEY)) >> 3)
 
#define return_ADDRESS_COMPARE(X, Y)   return_INTEGER_COMPARE ((X), (Y))
 

Typedefs

typedef unsigned long hash_func_t __P((void const *key))
 

Functions

void hash_init __P ((struct hash_table *ht, unsigned long size, hash_func_t hash_1, hash_func_t hash_2, hash_cmp_func_t hash_cmp))
 
void hash_load __P ((struct hash_table *ht, void *item_table, unsigned long cardinality, unsigned long size))
 
void **hash_find_slot __P ((struct hash_table *ht, void const *key))
 
void *hash_insert __P ((struct hash_table *ht, const void *item))
 
void *hash_insert_at __P ((struct hash_table *ht, const void *item, void const *slot))
 
void *hash_delete_at __P ((struct hash_table *ht, void const *slot))
 
void hash_delete_items __P ((struct hash_table *ht))
 
void hash_free __P ((struct hash_table *ht, int free_items))
 
void hash_map __P ((struct hash_table *ht, hash_map_func_t map))
 
void hash_map_arg __P ((struct hash_table *ht, hash_map_arg_func_t map, void *arg))
 
void hash_print_stats __P ((struct hash_table *ht, FILE *out_FILE))
 
void **hash_dump __P ((struct hash_table *ht, void **vector_0, qsort_cmp_t compare))
 
unsigned jhash (unsigned char const *key, int n)
 
unsigned jhash_string (unsigned char const *key)
 

Variables

void * hash_deleted_item
 

Macro Definition Documentation

◆ __P

#define __P (   protos)    ()

◆ ADDRESS_COMPARE

#define ADDRESS_COMPARE (   X,
  Y,
  RESULT 
)    INTEGER_COMPARE ((X), (Y), (RESULT))

◆ ADDRESS_HASH_1

#define ADDRESS_HASH_1 (   KEY,
  RESULT 
)    INTEGER_HASH_1 (((unsigned long)(KEY)) >> 3, (RESULT))

◆ ADDRESS_HASH_2

#define ADDRESS_HASH_2 (   KEY,
  RESULT 
)    INTEGER_HASH_2 (((unsigned long)(KEY)) >> 3, (RESULT))

◆ HASH_VACANT

#define HASH_VACANT (   item)    ((item) == 0 || (void *) (item) == hash_deleted_item)

◆ INTEGER_COMPARE

#define INTEGER_COMPARE (   X,
  Y,
  RESULT 
)
Value:
do { \
(RESULT) = X - Y; \
} while (0)

◆ INTEGER_HASH_1

#define INTEGER_HASH_1 (   KEY,
  RESULT 
)
Value:
do { \
(RESULT) += ((unsigned long)(KEY)); \
} while (0)

◆ INTEGER_HASH_2

#define INTEGER_HASH_2 (   KEY,
  RESULT 
)
Value:
do { \
(RESULT) += ~((unsigned long)(KEY)); \
} while (0)

◆ ISTRING_COMPARE

#define ISTRING_COMPARE (   X,
  Y,
  RESULT 
)    STRING_COMPARE ((X), (Y), (RESULT))

◆ ISTRING_HASH_1

#define ISTRING_HASH_1 (   KEY,
  RESULT 
)    STRING_HASH_1 ((KEY), (RESULT))

◆ ISTRING_HASH_2

#define ISTRING_HASH_2 (   KEY,
  RESULT 
)    STRING_HASH_2 ((KEY), (RESULT))

◆ return_ADDRESS_COMPARE

#define return_ADDRESS_COMPARE (   X,
 
)    return_INTEGER_COMPARE ((X), (Y))

◆ return_ADDRESS_HASH_1

#define return_ADDRESS_HASH_1 (   KEY)    return_INTEGER_HASH_1 (((unsigned long)(KEY)) >> 3)

◆ return_ADDRESS_HASH_2

#define return_ADDRESS_HASH_2 (   KEY)    return_INTEGER_HASH_2 (((unsigned long)(KEY)) >> 3)

◆ return_INTEGER_COMPARE

#define return_INTEGER_COMPARE (   X,
 
)
Value:
do { \
int _result_; \
INTEGER_COMPARE (X, Y, _result_); \
return _result_; \
} while (0)

◆ return_INTEGER_HASH_1

#define return_INTEGER_HASH_1 (   KEY)
Value:
do { \
unsigned long _result_ = 0; \
INTEGER_HASH_1 ((KEY), _result_); \
return _result_; \
} while (0)

◆ return_INTEGER_HASH_2

#define return_INTEGER_HASH_2 (   KEY)
Value:
do { \
unsigned long _result_ = 0; \
INTEGER_HASH_2 ((KEY), _result_); \
return _result_; \
} while (0)

◆ return_ISTRING_COMPARE

#define return_ISTRING_COMPARE (   X,
 
)    return_STRING_COMPARE ((X), (Y))

◆ return_ISTRING_HASH_1

#define return_ISTRING_HASH_1 (   KEY)    return_STRING_HASH_1 (KEY)

◆ return_ISTRING_HASH_2

#define return_ISTRING_HASH_2 (   KEY)    return_STRING_HASH_2 (KEY)

◆ return_STRING_COMPARE

#define return_STRING_COMPARE (   X,
 
)
Value:
do { \
return (X) == (Y) ? 0 : strcmp ((X), (Y)); \
} while (0)

◆ return_STRING_HASH_1

#define return_STRING_HASH_1 (   KEY)
Value:
do { \
unsigned long _result_ = 0; \
STRING_HASH_1 ((KEY), _result_); \
return _result_; \
} while (0)

◆ return_STRING_HASH_2

#define return_STRING_HASH_2 (   KEY)
Value:
do { \
unsigned long _result_ = 0; \
STRING_HASH_2 ((KEY), _result_); \
return _result_; \
} while (0)

◆ return_STRING_N_COMPARE

#define return_STRING_N_COMPARE (   X,
  Y,
 
)
Value:
do { \
return (X) == (Y) ? 0 : memcmp ((X), (Y), (N)); \
} while (0)

◆ return_STRING_N_HASH_1

#define return_STRING_N_HASH_1 (   KEY,
 
)
Value:
do { \
unsigned long _result_ = 0; \
STRING_N_HASH_1 ((KEY), (N), _result_); \
return _result_; \
} while (0)

◆ return_STRING_N_HASH_2

#define return_STRING_N_HASH_2 (   KEY,
 
)
Value:
do { \
unsigned long _result_ = 0; \
STRING_N_HASH_2 ((KEY), (N), _result_); \
return _result_; \
} while (0)

◆ STRING_COMPARE

#define STRING_COMPARE (   X,
  Y,
  RESULT 
)
Value:
do { \
RESULT = (X) == (Y) ? 0 : strcmp ((X), (Y)); \
} while (0)

◆ STRING_HASH_1

#define STRING_HASH_1 (   KEY,
  RESULT 
)
Value:
do { \
unsigned char const *_key_ = (unsigned char const *) (KEY); \
(RESULT) += jhash_string(_key_); \
} while (0)
unsigned jhash_string(unsigned char const *key)

◆ STRING_HASH_2

#define STRING_HASH_2 (   KEY,
  RESULT 
)
Value:
do { \
(void)(KEY); \
} while (0)

◆ STRING_N_COMPARE

#define STRING_N_COMPARE (   X,
  Y,
  N,
  RESULT 
)
Value:
do { \
RESULT = (X) == (Y) ? 0 : memcmp ((X), (Y), (N)); \
} while (0)

◆ STRING_N_HASH_1

#define STRING_N_HASH_1 (   KEY,
  N,
  RESULT 
)
Value:
do { \
unsigned char const *_key_ = (unsigned char const *) (KEY); \
(RESULT) += jhash(_key_, N); \
} while (0)
unsigned jhash(unsigned char const *key, int n)

◆ STRING_N_HASH_2

#define STRING_N_HASH_2 (   KEY,
  N,
  RESULT 
)
Value:
do { \
(void)(KEY); \
(void)(N); \
} while (0)

Typedef Documentation

◆ __P

void hash_free_items __P ( (void const *key)  )

Function Documentation

◆ __P() [1/12]

void hash_init __P ( (struct hash_table *ht, unsigned long size, hash_func_t hash_1, hash_func_t hash_2, hash_cmp_func_t hash_cmp)  )

◆ __P() [2/12]

void hash_load __P ( (struct hash_table *ht, void *item_table, unsigned long cardinality, unsigned long size)  )

◆ __P() [3/12]

void** hash_find_slot __P ( (struct hash_table *ht, void const *key)  )

◆ __P() [4/12]

void* hash_insert __P ( (struct hash_table *ht, const void *item)  )

◆ __P() [5/12]

void* hash_insert_at __P ( (struct hash_table *ht, const void *item, void const *slot)  )

◆ __P() [6/12]

void* hash_delete_at __P ( (struct hash_table *ht, void const *slot)  )

◆ __P() [7/12]

void hash_delete_items __P ( (struct hash_table *ht)  )

◆ __P() [8/12]

void hash_free __P ( (struct hash_table *ht, int free_items)  )

◆ __P() [9/12]

void hash_map __P ( (struct hash_table *ht, hash_map_func_t map)  )

◆ __P() [10/12]

void hash_map_arg __P ( (struct hash_table *ht, hash_map_arg_func_t map, void *arg)  )

◆ __P() [11/12]

void hash_print_stats __P ( (struct hash_table *ht, FILE *out_FILE)  )

◆ __P() [12/12]

void** hash_dump __P ( (struct hash_table *ht, void **vector_0, qsort_cmp_t compare)  )

◆ jhash()

unsigned jhash ( unsigned char const *  key,
int  n 
)

◆ jhash_string()

unsigned jhash_string ( unsigned char const *  key)

Variable Documentation

◆ hash_deleted_item

void* hash_deleted_item