00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef _LIBDICO_H_INCLUDED
00023 #define _LIBDICO_H_INCLUDED
00024
00025 #ifdef __cplusplus
00026 extern "C" {
00027 #endif
00028
00029 #define INIT_CAPACITY 512
00030
00031 typedef struct dictionary {
00032 int size;
00033 int capacity;
00034 int (*compar)(void *, void *);
00035 void (*keyfree)(void *);
00036 void **key;
00037 void **value;
00038 } DICTIONARY;
00039
00040
00041
00042
00043
00044 extern DICTIONARY *dict_new(int (*_compar)(void *, void *), void (*_keyfree)(void *));
00045 extern int dict_expand_capacity(DICTIONARY *dict);
00046 extern void *dict_get(DICTIONARY *d, void *key);
00047 extern int dict_get_nth(DICTIONARY *d, void **key, void **value, int n);
00048 extern int dict_index_for_key(DICTIONARY *d, void *key);
00049 extern void *dict_put(DICTIONARY *d, void *key, void *value);
00050 extern void *dict_put_nonunique(DICTIONARY *d, void *key, void *value);
00051 extern void *dict_remove(DICTIONARY *d, void *key);
00052 extern void *dict_remove_specific(DICTIONARY *d, void *key, void *value);
00053 extern void **dict_remove_all(DICTIONARY *d, void *key, int *num_removed);
00054 extern void dict_free(DICTIONARY *d);
00055
00056 #ifdef __cplusplus
00057 }
00058 #endif
00059
00060 #endif