dictionary.h

来自「SRI international 发布的OAA框架软件」· C头文件 代码 · 共 41 行

H
41
字号
/* Make sure only loaded once... */
#ifndef _LIBDICO_H_INCLUDED
#define _LIBDICO_H_INCLUDED

#ifdef __cplusplus
extern "C" {
#endif

#define INIT_CAPACITY 512

  typedef struct dictionary {
    int size;
    int capacity;
    int  (*compar)(void *, void *);    /* user fn for comparing keys & values */
    void (*keyfree)(void *);	      /* user fn for freeing keeys */
    void **key;
    void **value;
  } DICTIONARY;

  /*
   * prototypes
   */

  extern DICTIONARY *dict_new(int (*_compar)(void *, void *), void (*_keyfree)(void *));
  extern int 	   dict_expand_capacity(DICTIONARY *dict);
  extern void 	  *dict_get(DICTIONARY *d, void *key);
  extern int dict_get_nth(DICTIONARY *d, void **key, void **value, int n);
  extern int 	   dict_index_for_key(DICTIONARY *d, void *key);
  extern void 	  *dict_put(DICTIONARY *d, void *key, void *value);
  extern void	  *dict_put_nonunique(DICTIONARY *d, void *key, void *value);
  extern void	  *dict_remove(DICTIONARY *d, void *key);
  extern void	  *dict_remove_specific(DICTIONARY *d, void *key, void *value);
  extern void	 **dict_remove_all(DICTIONARY *d, void *key, int *num_removed);
  extern void	   dict_free(DICTIONARY *d);

#ifdef __cplusplus
}
#endif

#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?