summaryrefslogtreecommitdiff
path: root/sim/src/hashtable.h
blob: 0bab3745f85b36889949bd5395dff924c7655523 (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
// Copyright 2005-2006 Nanorex, Inc.  See LICENSE file for details. 
#ifndef HASHTABLE_H_INCLUDED
#define HASHTABLE_H_INCLUDED

#define RCSID_HASHTABLE_H  "$Id$"

struct hashtable_bucket
{
  int hash;
  char *key;
  void *value;
};


struct hashtable 
{
  int size; /* length of buckets array */
  int count; /* number of items (full buckets) in the hashtable */
  struct hashtable_bucket *buckets;
};

extern struct hashtable *hashtable_new(int initial_size);

extern void *hashtable_put(struct hashtable *table, char *key, void *value);

extern void *hashtable_get(struct hashtable *table, char *key);

extern void hashtable_print(FILE *f, struct hashtable *table);

extern void hashtable_iterate(struct hashtable *table, void func(char *key, void *value));

extern void hashtable_destroy(struct hashtable *table, void func(void *value));

#endif