summaryrefslogtreecommitdiff
path: root/src/libply/ply-hashtable.h
blob: e7e1a6eb28abf32151fe5ba3c28952c7f117bd7d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/* ply-hashtable.h - hash table implementation
 *
 * Copyright (C) 2009 Charlie Brej <cbrej@cs.man.ac.uk>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2, or (at your option)
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 * 02111-1307, USA.
 *
 * Written by: Charlie Brej <cbrej@cs.man.ac.uk>
 */
#ifndef PLY_HASHTABLE_H
#define PLY_HASHTABLE_H

typedef struct _ply_hashtable ply_hashtable_t;

typedef int (ply_hashtable_compare_func_t) (void *elementa,
                                            void *elementb);
typedef unsigned int (ply_hashtable_hash_func_t) (void *element);
typedef void (ply_hashtable_foreach_func_t) (void *key,
                                             void *data,
                                             void *user_data);


#ifndef PLY_HIDE_FUNCTION_DECLARATIONS
int ply_hashtable_direct_compare (void *elementa,
                              	  void *elementb);
unsigned int ply_hashtable_direct_hash (void *element);
unsigned int ply_hashtable_string_hash (void *element);
int ply_hashtable_string_compare (void *elementa,
                                  void *elementb);
ply_hashtable_t *ply_hashtable_new (ply_hashtable_hash_func_t    *hash_func,
                                    ply_hashtable_compare_func_t *compare_func);
void ply_hashtable_free (ply_hashtable_t *hashtable);
void ply_hashtable_resize (ply_hashtable_t *hashtable);
void ply_hashtable_insert (ply_hashtable_t *hashtable,
                    	   void            *key,
                    	   void            *data);
void *ply_hashtable_remove (ply_hashtable_t *hashtable,
                    		void            *key);
void *ply_hashtable_lookup (ply_hashtable_t *hashtable,
                    		void            *key);
int ply_hashtable_lookup_full (ply_hashtable_t *hashtable,
                        	   void            *key,
                        	   void           **reply_key,
                        	   void           **reply_data);
void ply_hashtable_foreach (ply_hashtable_t              *hashtable,
							ply_hashtable_foreach_func_t  func,
							void                         *user_data);

int ply_hashtable_get_size (ply_hashtable_t *hashtable);
#endif

#endif /* PLY_HASHTABLE_H */