/[LeafOK_CVS]/pvpgn-1.7.4/src/common/hashtable.h
ViewVC logotype

Contents of /pvpgn-1.7.4/src/common/hashtable.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1.1.1 - (show annotations) (vendor branch)
Tue Jun 6 03:41:38 2006 UTC (19 years, 9 months ago) by sysadm
Branch: GNU, MAIN
CVS Tags: arelease, HEAD
Changes since 1.1: +0 -0 lines
Content type: text/x-chdr
Error occurred while calculating annotation data.
no message

1 /*
2 * Copyright (C) 2000 Ross Combs (rocombs@cs.nmsu.edu)
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */
18 #ifndef INCLUDED_HASHTABLE_TYPES
19 #define INCLUDED_HASHTABLE_TYPES
20
21 #ifdef HASHTABLE_INTERNAL_ACCESS
22 struct hashtable; /* forward reference for t_entry */
23 #endif
24
25 #ifdef HASHTABLE_INTERNAL_ACCESS
26 typedef struct internentry
27 {
28 void * data;
29 struct internentry * next;
30 }
31 t_internentry;
32 #endif
33
34 typedef struct entry
35 #ifdef HASHTABLE_INTERNAL_ACCESS
36 {
37 unsigned int row;
38 t_internentry * real;
39 struct hashtable const * hashtable;
40 }
41 #endif
42 t_entry;
43
44 typedef struct hashtable
45 #ifdef HASHTABLE_INTERNAL_ACCESS
46 {
47 unsigned int num_rows;
48 unsigned int len;
49 unsigned int zombies;
50 t_internentry * * rows;
51 }
52 #endif
53 t_hashtable;
54
55 #endif
56
57
58 /*****/
59 #ifndef JUST_NEED_TYPES
60 #ifndef INCLUDED_HASHTABLE_PROTOS
61 #define INCLUDED_HASHTABLE_PROTOS
62
63 extern t_hashtable * hashtable_create(unsigned int num_rows) ;
64 extern int hashtable_destroy(t_hashtable * hashtable);
65 extern int hashtable_purge(t_hashtable * hashtable);
66 extern int hashtable_check(t_hashtable const * hashtable);
67 extern unsigned int hashtable_get_length(t_hashtable const * hashtable);
68 extern int hashtable_insert_data(t_hashtable * hashtable, void * data, unsigned int hash);
69 extern t_entry * hashtable_get_entry_by_data(t_hashtable const * hashtable, void const * data, unsigned int hash);
70 extern t_entry const * hashtable_get_entry_by_data_const(t_hashtable const * hashtable, void const * data, unsigned int hash);
71 extern int hashtable_remove_data(t_hashtable * hashtable, void const * data, unsigned int hash); /* delete matching item */
72 extern int hashtable_remove_entry(t_hashtable * hashtable, t_entry * entry);
73 extern void * hashtable_get_data_by_pos(t_hashtable const * hashtable, unsigned int pos);
74 extern void * entry_get_data(t_entry const * entry);
75 #ifdef HASHTABLE_DEBUG
76 extern t_entry * hashtable_match_get_first_real(t_hashtable const * hashtable, unsigned int hash, char const * fn, unsigned int ln);
77 # define hashtable_match_get_first(L,H) hashtable_match_get_first_real(L,H,__FILE__,__LINE__)
78 #else
79 extern t_entry * hashtable_match_get_first(t_hashtable const * hashtable, unsigned int hash);
80 #endif
81 extern t_entry * entry_match_get_next(t_entry const * entry, unsigned int hash);
82 #ifdef HASHTABLE_DEBUG
83 extern t_entry * hashtable_get_first_real(t_hashtable const * hashtable, char const * fn, unsigned int ln);
84 # define hashtable_get_first(L) hashtable_get_first_real(L,__FILE__,__LINE__)
85 #else
86 extern t_entry * hashtable_get_first(t_hashtable const * hashtable);
87 #endif
88 extern t_entry * entry_get_next(t_entry * entry);
89 #ifdef HASHTABLE_DEBUG
90 extern t_entry * hashtable_get_first_matching_real(t_hashtable const * hashtable, unsigned int hash, char const * fn, unsigned int ln);
91 # define hashtable_get_first_matching(L,H) hashtable_get_first_matching_real(L,H,__FILE__,__LINE__)
92 #else
93 extern t_entry * hashtable_get_first_matching(t_hashtable const * hashtable, unsigned int hash);
94 #endif
95 extern t_entry * entry_get_next_matching(t_entry * entry);
96 extern int hashtable_entry_release(t_entry * entry);
97 extern int hashtable_stats(t_hashtable * hashtable);
98
99 #define HASHTABLE_TRAVERSE(hashtable,curr) for (curr=hashtable_get_first(hashtable); curr; curr=entry_get_next(curr))
100 #define HASHTABLE_TRAVERSE_MATCHING(hashtable,curr,hash) for (curr=hashtable_get_first_matching(hashtable,hash); curr; curr=entry_get_next_matching(curr))
101
102 #endif
103 #endif

webmaster@leafok.com
ViewVC Help
Powered by ViewVC 1.3.0-beta1