Freeciv-3.2
Loading...
Searching...
No Matches
Macros | Typedefs | Functions | Variables
spechash.h File Reference
#include "genhash.h"
#include "iterator.h"
#include "support.h"

Go to the source code of this file.

Macros

#define SPECHASH_VPTR_TO_IKEY(p)   ((SPECHASH_IKEY_TYPE)(p))
 
#define SPECHASH_VPTR_TO_IDATA(p)   ((SPECHASH_IDATA_TYPE)(p))
 
#define SPECHASH_UKEY_TYPE   SPECHASH_IKEY_TYPE
 
#define SPECHASH_UDATA_TYPE   SPECHASH_IDATA_TYPE
 
#define SPECHASH_IKEY_VAL   NULL
 
#define SPECHASH_IKEY_COMP   NULL
 
#define SPECHASH_IKEY_COPY   NULL
 
#define SPECHASH_IKEY_FREE   NULL
 
#define SPECHASH_IDATA_COMP   NULL
 
#define SPECHASH_IDATA_COPY   NULL
 
#define SPECHASH_IDATA_FREE   NULL
 
#define SPECHASH_UKEY_TO_IKEY(ukey)   ((SPECHASH_IKEY_TYPE) (ukey))
 
#define SPECHASH_IKEY_TO_UKEY(ikey)   ((SPECHASH_UKEY_TYPE) (ikey))
 
#define SPECHASH_UDATA_TO_IDATA(udata)   ((SPECHASH_IDATA_TYPE) (udata))
 
#define SPECHASH_IDATA_TO_UDATA(idata)   ((SPECHASH_UDATA_TYPE) (idata))
 
#define SPECHASH_PASTE_(x, y)   x ## y
 
#define SPECHASH_PASTE(x, y)   SPECHASH_PASTE_(x, y)
 
#define SPECHASH_HASH   struct SPECHASH_PASTE(SPECHASH_TAG, _hash)
 
#define SPECHASH_ITER   struct SPECHASH_PASTE(SPECHASH_TAG, _hash_iter)
 
#define SPECHASH_FOO(suffix)   SPECHASH_PASTE(SPECHASH_TAG, suffix)
 
#define FC__SPECHASH_H
 
#define TYPED_HASH_DATA_ITERATE(TYPE_data, ARG_ht, NAME_data)
 
#define HASH_DATA_ITERATE_END   generic_iterate_end
 
#define TYPED_HASH_KEYS_ITERATE(TYPE_key, ARG_ht, NAME_key)
 
#define HASH_KEYS_ITERATE_END
 
#define TYPED_HASH_ITERATE(TYPE_key, TYPE_data, ARG_ht, NAME_key, NAME_data)
 
#define HASH_ITERATE_END    } genhash_iterate_end;
 

Typedefs

typedef genhash_val_t(*)(const SPECHASH_IKEY_TYPE SPECHASH_FOO) (_hash_key_val_fn_t)
 

Functions

static SPECHASH_HASH *SPECHASH_FOO() _hash_new (void) fc__warn_unused_result
 
static SPECHASH_HASH *SPECHASH_FOO() _hash_new_full (SPECHASH_FOO(_hash_key_val_fn_t) key_val_func, key_comp_func, key_copy_func, key_free_func, data_copy_func, data_free_func) fc__warn_unused_result
 
static SPECHASH_HASH *SPECHASH_FOO() _hash_new_nentries (size_t nentries) fc__warn_unused_result
 
static SPECHASH_HASH *SPECHASH_FOO() _hash_new_nentries_full (SPECHASH_FOO(_hash_key_val_fn_t) key_val_func, key_comp_func, key_copy_func, key_free_func, data_copy_func, data_free_func, size_t nentries) fc__warn_unused_result
 
static void SPECHASH_FOO() _hash_destroy (SPECHASH_HASH *tthis)
 
static bool SPECHASH_FOO() _hash_set_no_shrink (SPECHASH_HASH *tthis, bool no_shrink)
 
static size_t SPECHASH_FOO() _hash_size (const SPECHASH_HASH *tthis)
 
static size_t SPECHASH_FOO() _hash_capacity (const SPECHASH_HASH *tthis)
 
static SPECHASH_HASH *SPECHASH_FOO() _hash_copy (const SPECHASH_HASH *tthis) fc__warn_unused_result
 
static void SPECHASH_FOO() _hash_clear (SPECHASH_HASH *tthis)
 
static bool SPECHASH_FOO() _hash_insert (SPECHASH_HASH *tthis, const SPECHASH_UKEY_TYPE ukey, const SPECHASH_UDATA_TYPE udata)
 
static bool SPECHASH_FOO() _hash_replace (SPECHASH_HASH *tthis, const SPECHASH_UKEY_TYPE ukey, const SPECHASH_UDATA_TYPE udata)
 
static bool SPECHASH_FOO() _hash_replace_full (SPECHASH_HASH *tthis, const SPECHASH_UKEY_TYPE ukey, const SPECHASH_UDATA_TYPE udata, SPECHASH_UKEY_TYPE *old_pukey, SPECHASH_UDATA_TYPE *old_pudata)
 
static bool SPECHASH_FOO() _hash_lookup (const SPECHASH_HASH *tthis, const SPECHASH_UKEY_TYPE ukey, SPECHASH_UDATA_TYPE *pudata)
 
static bool SPECHASH_FOO() _hash_remove (SPECHASH_HASH *tthis, const SPECHASH_UKEY_TYPE ukey)
 
static bool SPECHASH_FOO() _hash_remove_full (SPECHASH_HASH *tthis, const SPECHASH_UKEY_TYPE ukey, SPECHASH_UKEY_TYPE *deleted_pukey, SPECHASH_UDATA_TYPE *deleted_pudata)
 
static bool SPECHASH_FOO() _hashes_are_equal_full (const SPECHASH_HASH *phash1, const SPECHASH_HASH *phash2, data_comp_func)
 
static bool SPECHASH_FOO() _hashes_are_equal (const SPECHASH_HASH *phash1, const SPECHASH_HASH *phash2)
 
static size_t SPECHASH_FOO() _hash_iter_sizeof (void)
 
static struct iterator *SPECHASH_FOO() _hash_iter_init (SPECHASH_ITER *iter, const SPECHASH_HASH *tthis)
 
static struct iterator *SPECHASH_FOO() _hash_key_iter_init (SPECHASH_ITER *iter, const SPECHASH_HASH *tthis)
 
static struct iterator *SPECHASH_FOO() _hash_value_iter_init (SPECHASH_ITER *iter, const SPECHASH_HASH *tthis)
 

Variables

 SPECHASH_HASH
 
 SPECHASH_ITER
 

Macro Definition Documentation

◆ FC__SPECHASH_H

#define FC__SPECHASH_H

Definition at line 689 of file spechash.h.

◆ HASH_DATA_ITERATE_END

#define HASH_DATA_ITERATE_END   generic_iterate_end

Definition at line 702 of file spechash.h.

◆ HASH_ITERATE_END

#define HASH_ITERATE_END    } genhash_iterate_end;

Definition at line 732 of file spechash.h.

◆ HASH_KEYS_ITERATE_END

#define HASH_KEYS_ITERATE_END
Value:
} \
} while (FALSE);
#define FALSE
Definition support.h:47

Definition at line 715 of file spechash.h.

◆ SPECHASH_FOO

#define SPECHASH_FOO (   suffix)    SPECHASH_PASTE(SPECHASH_TAG, suffix)

Definition at line 290 of file spechash.h.

◆ SPECHASH_HASH

Definition at line 288 of file spechash.h.

◆ SPECHASH_IDATA_COMP

#define SPECHASH_IDATA_COMP   NULL

Definition at line 262 of file spechash.h.

◆ SPECHASH_IDATA_COPY

#define SPECHASH_IDATA_COPY   NULL

Definition at line 265 of file spechash.h.

◆ SPECHASH_IDATA_FREE

#define SPECHASH_IDATA_FREE   NULL

Definition at line 268 of file spechash.h.

◆ SPECHASH_IDATA_TO_UDATA

#define SPECHASH_IDATA_TO_UDATA (   idata)    ((SPECHASH_UDATA_TYPE) (idata))

Definition at line 282 of file spechash.h.

◆ SPECHASH_IKEY_COMP

#define SPECHASH_IKEY_COMP   NULL

Definition at line 253 of file spechash.h.

◆ SPECHASH_IKEY_COPY

#define SPECHASH_IKEY_COPY   NULL

Definition at line 256 of file spechash.h.

◆ SPECHASH_IKEY_FREE

#define SPECHASH_IKEY_FREE   NULL

Definition at line 259 of file spechash.h.

◆ SPECHASH_IKEY_TO_UKEY

#define SPECHASH_IKEY_TO_UKEY (   ikey)    ((SPECHASH_UKEY_TYPE) (ikey))

Definition at line 276 of file spechash.h.

◆ SPECHASH_IKEY_VAL

#define SPECHASH_IKEY_VAL   NULL

Definition at line 250 of file spechash.h.

◆ SPECHASH_ITER

Definition at line 289 of file spechash.h.

◆ SPECHASH_PASTE

#define SPECHASH_PASTE (   x,
  y 
)    SPECHASH_PASTE_(x, y)

Definition at line 286 of file spechash.h.

◆ SPECHASH_PASTE_

#define SPECHASH_PASTE_ (   x,
  y 
)    x ## y

Definition at line 285 of file spechash.h.

◆ SPECHASH_UDATA_TO_IDATA

#define SPECHASH_UDATA_TO_IDATA (   udata)    ((SPECHASH_IDATA_TYPE) (udata))

Definition at line 279 of file spechash.h.

◆ SPECHASH_UDATA_TYPE

#define SPECHASH_UDATA_TYPE   SPECHASH_IDATA_TYPE

Definition at line 245 of file spechash.h.

◆ SPECHASH_UKEY_TO_IKEY

#define SPECHASH_UKEY_TO_IKEY (   ukey)    ((SPECHASH_IKEY_TYPE) (ukey))

Definition at line 273 of file spechash.h.

◆ SPECHASH_UKEY_TYPE

#define SPECHASH_UKEY_TYPE   SPECHASH_IKEY_TYPE

Definition at line 239 of file spechash.h.

◆ SPECHASH_VPTR_TO_IDATA

#define SPECHASH_VPTR_TO_IDATA (   p)    ((SPECHASH_IDATA_TYPE)(p))

Definition at line 229 of file spechash.h.

◆ SPECHASH_VPTR_TO_IKEY

#define SPECHASH_VPTR_TO_IKEY (   p)    ((SPECHASH_IKEY_TYPE)(p))

Definition at line 225 of file spechash.h.

◆ TYPED_HASH_DATA_ITERATE

#define TYPED_HASH_DATA_ITERATE (   TYPE_data,
  ARG_ht,
  NAME_data 
)
Value:
(const struct genhash *) (ARG_ht))
char * incite_cost
Definition comments.c:75
struct iterator * genhash_value_iter_init(struct genhash_iter *iter, const struct genhash *pgenhash)
Definition genhash.c:909
size_t genhash_iter_sizeof(void)
Definition genhash.c:795
#define generic_iterate(TYPE_it, TYPE_a, NAME_a, FUNC_size, FUNC_init,...)
Definition iterator.h:117

Definition at line 696 of file spechash.h.

◆ TYPED_HASH_ITERATE

#define TYPED_HASH_ITERATE (   TYPE_key,
  TYPE_data,
  ARG_ht,
  NAME_key,
  NAME_data 
)
Value:
genhash_iterate((const struct genhash *) (ARG_ht), MY_iter) { \
void * genhash_iter_key(const struct iterator *genhash_iter)
Definition genhash.c:803
void * genhash_iter_value(const struct iterator *genhash_iter)
Definition genhash.c:812
#define genhash_iterate(ARG_ht, NAME_iter)
Definition genhash.h:128

Definition at line 726 of file spechash.h.

◆ TYPED_HASH_KEYS_ITERATE

#define TYPED_HASH_KEYS_ITERATE (   TYPE_key,
  ARG_ht,
  NAME_key 
)
Value:
(const struct genhash *) (ARG_ht))
struct iterator * genhash_key_iter_init(struct genhash_iter *iter, const struct genhash *pgenhash)
Definition genhash.c:900

Definition at line 709 of file spechash.h.

Typedef Documentation

◆ SPECHASH_FOO

static SPECHASH_HASH * SPECHASH_FOO
inline

Create a new spechash.

Create a new spechash with a set of control functions.

Create a new spechash with n entries.

Create a new spechash with n entries and a set of control functions.

Definition at line 299 of file spechash.h.

Function Documentation

◆ _hash_capacity()

static size_t SPECHASH_FOO() _hash_capacity ( const SPECHASH_HASH tthis)
inlinestatic

Return the real number of buckets.

Definition at line 455 of file spechash.h.

◆ _hash_clear()

static void SPECHASH_FOO() _hash_clear ( SPECHASH_HASH tthis)
inlinestatic

Remove all elements of the spechash.

Definition at line 476 of file spechash.h.

◆ _hash_copy()

static SPECHASH_HASH *SPECHASH_FOO() _hash_copy ( const SPECHASH_HASH tthis)
inlinestatic

Duplicate the spechash.

Definition at line 468 of file spechash.h.

◆ _hash_destroy()

static void SPECHASH_FOO() _hash_destroy ( SPECHASH_HASH tthis)
inlinestatic

Free a spechash.

Definition at line 429 of file spechash.h.

◆ _hash_insert()

static bool SPECHASH_FOO() _hash_insert ( SPECHASH_HASH tthis,
const SPECHASH_UKEY_TYPE  ukey,
const SPECHASH_UDATA_TYPE  udata 
)
inlinestatic

Insert an element into the spechash. Returns TRUE on success (if no collision).

Definition at line 486 of file spechash.h.

◆ _hash_iter_init()

static struct iterator *SPECHASH_FOO() _hash_iter_init ( SPECHASH_ITER iter,
const SPECHASH_HASH tthis 
)
inlinestatic

Initialize an iterator.

Definition at line 627 of file spechash.h.

◆ _hash_iter_sizeof()

static size_t SPECHASH_FOO() _hash_iter_sizeof ( void  )
inlinestatic

Remove the size of the iterator type.

Definition at line 618 of file spechash.h.

◆ _hash_key_iter_init()

static struct iterator *SPECHASH_FOO() _hash_key_iter_init ( SPECHASH_ITER iter,
const SPECHASH_HASH tthis 
)
inlinestatic

Initialize a key iterator.

Definition at line 638 of file spechash.h.

◆ _hash_lookup()

static bool SPECHASH_FOO() _hash_lookup ( const SPECHASH_HASH tthis,
const SPECHASH_UKEY_TYPE  ukey,
SPECHASH_UDATA_TYPE pudata 
)
inlinestatic

Lookup an element. Returns TRUE if found.

Definition at line 540 of file spechash.h.

◆ _hash_new()

static SPECHASH_HASH *SPECHASH_FOO() _hash_new ( void  )
inlinestatic

Create a new spechash.

Definition at line 349 of file spechash.h.

◆ _hash_new_full()

static SPECHASH_HASH *SPECHASH_FOO() _hash_new_full ( SPECHASH_FOO(_hash_key_val_fn_t key_val_func,
key_comp_func  ,
key_copy_func  ,
key_free_func  ,
data_copy_func  ,
data_free_func   
)
inlinestatic

Create a new spechash with a set of control functions.

Definition at line 363 of file spechash.h.

Referenced by _hash_new().

◆ _hash_new_nentries()

static SPECHASH_HASH *SPECHASH_FOO() _hash_new_nentries ( size_t  nentries)
inlinestatic

Create a new spechash with n entries.

Definition at line 388 of file spechash.h.

◆ _hash_new_nentries_full()

static SPECHASH_HASH *SPECHASH_FOO() _hash_new_nentries_full ( SPECHASH_FOO(_hash_key_val_fn_t key_val_func,
key_comp_func  ,
key_copy_func  ,
key_free_func  ,
data_copy_func  ,
data_free_func  ,
size_t  nentries 
)
inlinestatic

Create a new spechash with n entries and a set of control functions.

Definition at line 403 of file spechash.h.

Referenced by _hash_new_nentries().

◆ _hash_remove()

static bool SPECHASH_FOO() _hash_remove ( SPECHASH_HASH tthis,
const SPECHASH_UKEY_TYPE  ukey 
)
inlinestatic

Remove an element. Returns TRUE on success.

Definition at line 559 of file spechash.h.

◆ _hash_remove_full()

static bool SPECHASH_FOO() _hash_remove_full ( SPECHASH_HASH tthis,
const SPECHASH_UKEY_TYPE  ukey,
SPECHASH_UKEY_TYPE deleted_pukey,
SPECHASH_UDATA_TYPE deleted_pudata 
)
inlinestatic

Remove an element. Returns TRUE on success.

Definition at line 570 of file spechash.h.

◆ _hash_replace()

static bool SPECHASH_FOO() _hash_replace ( SPECHASH_HASH tthis,
const SPECHASH_UKEY_TYPE  ukey,
const SPECHASH_UDATA_TYPE  udata 
)
inlinestatic

Replace an element into the spechash. Returns TRUE if it replaced an old element.

Definition at line 500 of file spechash.h.

◆ _hash_replace_full()

static bool SPECHASH_FOO() _hash_replace_full ( SPECHASH_HASH tthis,
const SPECHASH_UKEY_TYPE  ukey,
const SPECHASH_UDATA_TYPE  udata,
SPECHASH_UKEY_TYPE old_pukey,
SPECHASH_UDATA_TYPE old_pudata 
)
inlinestatic

Replace an element into the spechash. Returns TRUE if it replaced an old element.

Definition at line 514 of file spechash.h.

◆ _hash_set_no_shrink()

static bool SPECHASH_FOO() _hash_set_no_shrink ( SPECHASH_HASH tthis,
bool  no_shrink 
)
inlinestatic

Enable/Disable shrinking.

Definition at line 437 of file spechash.h.

◆ _hash_size()

static size_t SPECHASH_FOO() _hash_size ( const SPECHASH_HASH tthis)
inlinestatic

Return the number of elements.

Definition at line 446 of file spechash.h.

◆ _hash_value_iter_init()

static struct iterator *SPECHASH_FOO() _hash_value_iter_init ( SPECHASH_ITER iter,
const SPECHASH_HASH tthis 
)
inlinestatic

Initialize a value iterator.

Definition at line 649 of file spechash.h.

◆ _hashes_are_equal()

static bool SPECHASH_FOO() _hashes_are_equal ( const SPECHASH_HASH phash1,
const SPECHASH_HASH phash2 
)
inlinestatic

Compare the specific hash tables.

Definition at line 608 of file spechash.h.

◆ _hashes_are_equal_full()

static bool SPECHASH_FOO() _hashes_are_equal_full ( const SPECHASH_HASH phash1,
const SPECHASH_HASH phash2,
data_comp_func   
)
inlinestatic

Compare the specific hash tables.

Definition at line 594 of file spechash.h.

Referenced by _hashes_are_equal().

Variable Documentation

◆ SPECHASH_HASH

SPECHASH_HASH

Definition at line 293 of file spechash.h.

◆ SPECHASH_ITER

SPECHASH_ITER

Definition at line 296 of file spechash.h.