libdict
Data Structure C Library
Loading...
Searching...
No Matches
dict.h File Reference
#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>
#include "hashtable.h"
#include "hashtable2.h"
#include "hb_tree.h"
#include "pr_tree.h"
#include "rb_tree.h"
#include "skiplist.h"
#include "sp_tree.h"
#include "tr_tree.h"
#include "wb_tree.h"
Include dependency graph for dict.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  dict_insert_result
 
struct  dict_remove_result
 
struct  dict_vtable
 
struct  itor_vtable
 
struct  dict
 
struct  dict_itor
 

Macros

#define BEGIN_DECL
 
#define END_DECL
 
#define DICT_VERSION_MAJOR   0
 
#define DICT_VERSION_MINOR   3
 
#define DICT_VERSION_PATCH   0
 
#define dict_private(dct)
 
#define dict_insert(dct, key)
 
#define dict_search(dct, key)
 
#define dict_is_sorted(dct)
 
#define dict_search_le(dct, key)
 
#define dict_search_lt(dct, key)
 
#define dict_search_ge(dct, key)
 
#define dict_search_gt(dct, key)
 
#define dict_remove(dct, key)
 
#define dict_clear(dct, func)
 
#define dict_traverse(dct, func, ud)
 
#define dict_select(dct, n, key, d)
 
#define dict_count(dct)
 
#define dict_verify(dct)
 
#define dict_itor_new(dct)
 
#define dict_itor_private(i)
 
#define dict_itor_valid(i)
 
#define dict_itor_invalidate(i)
 
#define dict_itor_next(i)
 
#define dict_itor_prev(i)
 
#define dict_itor_nextn(i, n)
 
#define dict_itor_prevn(i, n)
 
#define dict_itor_first(i)
 
#define dict_itor_last(i)
 
#define dict_itor_search(i, k)
 
#define dict_itor_search_le(i, k)
 
#define dict_itor_search_lt(i, k)
 
#define dict_itor_search_ge(i, k)
 
#define dict_itor_search_gt(i, k)
 
#define dict_itor_key(i)
 
#define dict_itor_datum(i)
 
#define dict_itor_compare(i1, i2)
 
#define dict_itor_remove(i)
 

Typedefs

typedef int(* dict_compare_func) (const void *, const void *)
 
typedef void(* dict_delete_func) (void *, void *)
 
typedef bool(* dict_visit_func) (const void *, void *, void *)
 
typedef unsigned(* dict_hash_func) (const void *)
 
typedef unsigned(* dict_prio_func) (const void *)
 
typedef struct dict_itor dict_itor
 
typedef dict_itor *(* dict_inew_func) (void *obj)
 
typedef size_t(* dict_dfree_func) (void *obj, dict_delete_func delete_func)
 
typedef dict_insert_result(* dict_insert_func) (void *obj, void *key)
 
typedef void **(* dict_search_func) (void *obj, const void *key)
 
typedef dict_remove_result(* dict_remove_func) (void *obj, const void *key)
 
typedef size_t(* dict_clear_func) (void *obj, dict_delete_func delete_func)
 
typedef size_t(* dict_traverse_func) (void *obj, dict_visit_func visit, void *user_data)
 
typedef bool(* dict_select_func) (void *obj, size_t n, const void **key, void **datum)
 
typedef size_t(* dict_count_func) (const void *obj)
 
typedef bool(* dict_verify_func) (const void *obj)
 
typedef void(* dict_ifree_func) (void *itor)
 
typedef bool(* dict_valid_func) (const void *itor)
 
typedef void(* dict_invalidate_func) (void *itor)
 
typedef bool(* dict_next_func) (void *itor)
 
typedef bool(* dict_prev_func) (void *itor)
 
typedef bool(* dict_nextn_func) (void *itor, size_t count)
 
typedef bool(* dict_prevn_func) (void *itor, size_t count)
 
typedef bool(* dict_first_func) (void *itor)
 
typedef bool(* dict_last_func) (void *itor)
 
typedef void *(* dict_key_func) (void *itor)
 
typedef void **(* dict_datum_func) (void *itor)
 
typedef bool(* dict_isearch_func) (void *itor, const void *key)
 
typedef bool(* dict_iremove_func) (void *itor)
 
typedef int(* dict_icompare_func) (void *itor1, void *itor2)
 

Functions

size_t dict_free (dict *dct, dict_delete_func delete_func)
 
void dict_itor_free (dict_itor *itor)
 
int dict_int_cmp (const void *k1, const void *k2)
 
int dict_uint_cmp (const void *k1, const void *k2)
 
int dict_long_cmp (const void *k1, const void *k2)
 
int dict_ulong_cmp (const void *k1, const void *k2)
 
int dict_ptr_cmp (const void *k1, const void *k2)
 
int dict_str_cmp (const void *k1, const void *k2)
 
unsigned dict_str_hash (const void *str)
 

Variables

const char *const kDictVersionString
 
void *(* dict_malloc_func )(size_t)
 
void(* dict_free_func )(void *)
 

Macro Definition Documentation

◆ BEGIN_DECL

#define BEGIN_DECL

Definition at line 35 of file dict.h.

◆ dict_clear

#define dict_clear ( dct,
func )
Value:
((dct)->_vtable->clear((dct)->_object, (func)))

Definition at line 165 of file dict.h.

◆ dict_count

#define dict_count ( dct)
Value:
((dct)->_vtable->count((dct)->_object))

Definition at line 168 of file dict.h.

◆ dict_insert

#define dict_insert ( dct,
key )
Value:
((dct)->_vtable->insert((dct)->_object, (key)))

Definition at line 157 of file dict.h.

◆ dict_is_sorted

#define dict_is_sorted ( dct)
Value:
((dct)->_vtable->sorted)

Definition at line 159 of file dict.h.

◆ dict_itor_compare

#define dict_itor_compare ( i1,
i2 )
Value:
((i1)->_vtable->compare((i1)->_itor, (i2)->_itor))

Definition at line 195 of file dict.h.

◆ dict_itor_datum

#define dict_itor_datum ( i)
Value:
((i)->_vtable->datum((i)->_itor))

Definition at line 194 of file dict.h.

◆ dict_itor_first

#define dict_itor_first ( i)
Value:
((i)->_vtable->first((i)->_itor))

Definition at line 186 of file dict.h.

◆ dict_itor_invalidate

#define dict_itor_invalidate ( i)
Value:
((i)->_vtable->invalid((i)->_itor))

Definition at line 181 of file dict.h.

◆ dict_itor_key

#define dict_itor_key ( i)
Value:
((i)->_vtable->key((i)->_itor))

Definition at line 193 of file dict.h.

◆ dict_itor_last

#define dict_itor_last ( i)
Value:
((i)->_vtable->last((i)->_itor))

Definition at line 187 of file dict.h.

◆ dict_itor_new

#define dict_itor_new ( dct)
Value:
(dct)->_vtable->inew((dct)->_object)

Definition at line 170 of file dict.h.

◆ dict_itor_next

#define dict_itor_next ( i)
Value:
((i)->_vtable->next((i)->_itor))

Definition at line 182 of file dict.h.

◆ dict_itor_nextn

#define dict_itor_nextn ( i,
n )
Value:
((i)->_vtable->nextn((i)->_itor, (n)))

Definition at line 184 of file dict.h.

◆ dict_itor_prev

#define dict_itor_prev ( i)
Value:
((i)->_vtable->prev((i)->_itor))

Definition at line 183 of file dict.h.

◆ dict_itor_prevn

#define dict_itor_prevn ( i,
n )
Value:
((i)->_vtable->prevn((i)->_itor, (n)))

Definition at line 185 of file dict.h.

◆ dict_itor_private

#define dict_itor_private ( i)
Value:
((i)->_itor)

Definition at line 179 of file dict.h.

◆ dict_itor_remove

#define dict_itor_remove ( i)
Value:
((i)->_vtable->remove && (i)->_vtable->remove((i)->_itor))

Definition at line 196 of file dict.h.

◆ dict_itor_search

#define dict_itor_search ( i,
k )
Value:
((i)->_vtable->search((i)->_itor, (k)))

Definition at line 188 of file dict.h.

◆ dict_itor_search_ge

#define dict_itor_search_ge ( i,
k )
Value:
((i)->_vtable->search_ge && (i)->_vtable->search_ge((i)->_itor, (k)))

Definition at line 191 of file dict.h.

◆ dict_itor_search_gt

#define dict_itor_search_gt ( i,
k )
Value:
((i)->_vtable->search_gt && (i)->_vtable->search_gt((i)->_itor, (k)))

Definition at line 192 of file dict.h.

◆ dict_itor_search_le

#define dict_itor_search_le ( i,
k )
Value:
((i)->_vtable->search_le && (i)->_vtable->search_le((i)->_itor, (k)))

Definition at line 189 of file dict.h.

◆ dict_itor_search_lt

#define dict_itor_search_lt ( i,
k )
Value:
((i)->_vtable->search_lt && (i)->_vtable->search_lt((i)->_itor, (k)))

Definition at line 190 of file dict.h.

◆ dict_itor_valid

#define dict_itor_valid ( i)
Value:
((i)->_vtable->valid((i)->_itor))

Definition at line 180 of file dict.h.

◆ dict_private

#define dict_private ( dct)
Value:
((dct)->_object)

Definition at line 156 of file dict.h.

◆ dict_remove

#define dict_remove ( dct,
key )
Value:
((dct)->_vtable->remove((dct)->_object, (key)))

Definition at line 164 of file dict.h.

◆ dict_search

#define dict_search ( dct,
key )
Value:
((dct)->_vtable->search((dct)->_object, (key)))

Definition at line 158 of file dict.h.

◆ dict_search_ge

#define dict_search_ge ( dct,
key )
Value:
((dct)->_vtable->search_ge ? (dct)->_vtable->search_ge((dct)->_object, (key)) : NULL)

Definition at line 162 of file dict.h.

◆ dict_search_gt

#define dict_search_gt ( dct,
key )
Value:
((dct)->_vtable->search_gt ? (dct)->_vtable->search_gt((dct)->_object, (key)) : NULL)

Definition at line 163 of file dict.h.

◆ dict_search_le

#define dict_search_le ( dct,
key )
Value:
((dct)->_vtable->search_le ? (dct)->_vtable->search_le((dct)->_object, (key)) : NULL)

Definition at line 160 of file dict.h.

◆ dict_search_lt

#define dict_search_lt ( dct,
key )
Value:
((dct)->_vtable->search_lt ? (dct)->_vtable->search_lt((dct)->_object, (key)) : NULL)

Definition at line 161 of file dict.h.

◆ dict_select

#define dict_select ( dct,
n,
key,
d )
Value:
((dct)->_vtable->select && (dct)->_vtable->select((dct)->_object, (n), (key), (d)))

Definition at line 167 of file dict.h.

◆ dict_traverse

#define dict_traverse ( dct,
func,
ud )
Value:
((dct)->_vtable->traverse((dct)->_object, (func), (ud)))

Definition at line 166 of file dict.h.

◆ dict_verify

#define dict_verify ( dct)
Value:
((dct)->_vtable->verify((dct)->_object))

Definition at line 169 of file dict.h.

◆ DICT_VERSION_MAJOR

#define DICT_VERSION_MAJOR   0

Definition at line 45 of file dict.h.

◆ DICT_VERSION_MINOR

#define DICT_VERSION_MINOR   3

Definition at line 46 of file dict.h.

◆ DICT_VERSION_PATCH

#define DICT_VERSION_PATCH   0

Definition at line 47 of file dict.h.

◆ END_DECL

#define END_DECL

Definition at line 36 of file dict.h.

Typedef Documentation

◆ dict_clear_func

typedef size_t(* dict_clear_func) (void *obj, dict_delete_func delete_func)

Definition at line 91 of file dict.h.

◆ dict_compare_func

typedef int(* dict_compare_func) (const void *, const void *)

Definition at line 54 of file dict.h.

◆ dict_count_func

typedef size_t(* dict_count_func) (const void *obj)

Definition at line 94 of file dict.h.

◆ dict_datum_func

typedef void **(* dict_datum_func) (void *itor)

Definition at line 125 of file dict.h.

◆ dict_delete_func

typedef void(* dict_delete_func) (void *, void *)

Definition at line 57 of file dict.h.

◆ dict_dfree_func

typedef size_t(* dict_dfree_func) (void *obj, dict_delete_func delete_func)

Definition at line 85 of file dict.h.

◆ dict_first_func

typedef bool(* dict_first_func) (void *itor)

Definition at line 122 of file dict.h.

◆ dict_hash_func

typedef unsigned(* dict_hash_func) (const void *)

Definition at line 61 of file dict.h.

◆ dict_icompare_func

typedef int(* dict_icompare_func) (void *itor1, void *itor2)

Definition at line 128 of file dict.h.

◆ dict_ifree_func

typedef void(* dict_ifree_func) (void *itor)

Definition at line 115 of file dict.h.

◆ dict_inew_func

typedef dict_itor *(* dict_inew_func) (void *obj)

Definition at line 84 of file dict.h.

◆ dict_insert_func

typedef dict_insert_result(* dict_insert_func) (void *obj, void *key)

Definition at line 86 of file dict.h.

◆ dict_invalidate_func

typedef void(* dict_invalidate_func) (void *itor)

Definition at line 117 of file dict.h.

◆ dict_iremove_func

typedef bool(* dict_iremove_func) (void *itor)

Definition at line 127 of file dict.h.

◆ dict_isearch_func

typedef bool(* dict_isearch_func) (void *itor, const void *key)

Definition at line 126 of file dict.h.

◆ dict_itor

typedef struct dict_itor dict_itor

Definition at line 71 of file dict.h.

◆ dict_key_func

typedef void *(* dict_key_func) (void *itor)

Definition at line 124 of file dict.h.

◆ dict_last_func

typedef bool(* dict_last_func) (void *itor)

Definition at line 123 of file dict.h.

◆ dict_next_func

typedef bool(* dict_next_func) (void *itor)

Definition at line 118 of file dict.h.

◆ dict_nextn_func

typedef bool(* dict_nextn_func) (void *itor, size_t count)

Definition at line 120 of file dict.h.

◆ dict_prev_func

typedef bool(* dict_prev_func) (void *itor)

Definition at line 119 of file dict.h.

◆ dict_prevn_func

typedef bool(* dict_prevn_func) (void *itor, size_t count)

Definition at line 121 of file dict.h.

◆ dict_prio_func

typedef unsigned(* dict_prio_func) (const void *)

Definition at line 63 of file dict.h.

◆ dict_remove_func

typedef dict_remove_result(* dict_remove_func) (void *obj, const void *key)

Definition at line 89 of file dict.h.

◆ dict_search_func

typedef void **(* dict_search_func) (void *obj, const void *key)

Definition at line 88 of file dict.h.

◆ dict_select_func

typedef bool(* dict_select_func) (void *obj, size_t n, const void **key, void **datum)

Definition at line 93 of file dict.h.

◆ dict_traverse_func

typedef size_t(* dict_traverse_func) (void *obj, dict_visit_func visit, void *user_data)

Definition at line 92 of file dict.h.

◆ dict_valid_func

typedef bool(* dict_valid_func) (const void *itor)

Definition at line 116 of file dict.h.

◆ dict_verify_func

typedef bool(* dict_verify_func) (const void *obj)

Definition at line 95 of file dict.h.

◆ dict_visit_func

typedef bool(* dict_visit_func) (const void *, void *, void *)

Definition at line 59 of file dict.h.

Function Documentation

◆ dict_free()

size_t dict_free ( dict * dct,
dict_delete_func delete_func )

Definition at line 103 of file dict.c.

◆ dict_int_cmp()

int dict_int_cmp ( const void * k1,
const void * k2 )

Definition at line 41 of file dict.c.

◆ dict_itor_free()

void dict_itor_free ( dict_itor * itor)

Definition at line 113 of file dict.c.

◆ dict_long_cmp()

int dict_long_cmp ( const void * k1,
const void * k2 )

Definition at line 57 of file dict.c.

◆ dict_ptr_cmp()

int dict_ptr_cmp ( const void * k1,
const void * k2 )

Definition at line 73 of file dict.c.

◆ dict_str_cmp()

int dict_str_cmp ( const void * k1,
const void * k2 )

Definition at line 79 of file dict.c.

◆ dict_str_hash()

unsigned dict_str_hash ( const void * str)

Definition at line 92 of file dict.c.

◆ dict_uint_cmp()

int dict_uint_cmp ( const void * k1,
const void * k2 )

Definition at line 49 of file dict.c.

◆ dict_ulong_cmp()

int dict_ulong_cmp ( const void * k1,
const void * k2 )

Definition at line 65 of file dict.c.

Variable Documentation

◆ dict_free_func

void(* dict_free_func) (void *) ( void * )
extern

Definition at line 38 of file dict.c.

◆ dict_malloc_func

void *(* dict_malloc_func) (size_t) ( size_t )
extern

Definition at line 37 of file dict.c.

◆ kDictVersionString

const char* const kDictVersionString
extern

Definition at line 33 of file dict.c.