dict.h revision a11cbede4711e1efe2d6fb0a8a5b2050b2fe941c
1/*
2 * This file is part of ltrace.
3 * Copyright (C) 2011,2012 Petr Machata
4 * Copyright (C) 2003,2004,2008,2009 Juan Cespedes
5 * Copyright (C) 2006 Ian Wienand
6 * Copyright (C) ???? Morten Eriksen <mortene@sim.no>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of the
11 * License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
21 * 02110-1301 USA
22 */
23
24#ifndef _DICT_H_
25#define _DICT_H_
26
27/*
28 * Dictionary based on code by Morten Eriksen <mortene@sim.no>.
29 */
30
31typedef struct dict Dict;
32
33extern Dict *dict_init(unsigned int (*key2hash) (const void *),
34		       int (*key_cmp) (const void *, const void *));
35extern void dict_clear(Dict *d);
36extern int dict_enter(Dict *d, void *key, void *value);
37extern void *dict_remove(Dict *d, void *key);
38extern void *dict_find_entry(Dict *d, const void *key);
39extern void dict_apply_to_all(Dict *d,
40			      void (*func) (void *key, void *value, void *data),
41			      void *data);
42
43extern unsigned int dict_key2hash_string(const void *key);
44extern int dict_key_cmp_string(const void *key1, const void *key2);
45
46extern unsigned int dict_key2hash_int(const void *key);
47extern int dict_key_cmp_int(const void *key1, const void *key2);
48
49extern Dict * dict_clone(Dict *old, void * (*key_clone)(void*), void * (*value_clone)(void*));
50extern Dict * dict_clone2(Dict * old,
51			  void * (* key_clone)(void * key, void * data),
52			  void * (* value_clone)(void * value, void * data),
53			  void * data);
54
55#endif /* _DICT_H_ */
56