Hashtable.h 1.05 KB
Newer Older
Hisham Muhammad's avatar
Hisham Muhammad committed
1
/* Do not edit this file. It was automatically generated. */
Hisham Muhammad's avatar
Hisham Muhammad committed
2
3
4
5
6
7
8
9
10
11
12
13
14

#ifndef HEADER_Hashtable
#define HEADER_Hashtable
/*
htop
(C) 2004-2006 Hisham H. Muhammad
Released under the GNU GPL, see the COPYING file
in the source distribution for its full text.
*/


#include <stdlib.h>
#include <stdbool.h>
Hisham Muhammad's avatar
Hisham Muhammad committed
15
#include <assert.h>
Hisham Muhammad's avatar
Hisham Muhammad committed
16
17
18
19
20
21
22
23

#include "debug.h"

typedef struct Hashtable_ Hashtable;

typedef void(*Hashtable_PairFunction)(int, void*, void*);

typedef struct HashtableItem {
24
   unsigned int key;
Hisham Muhammad's avatar
Hisham Muhammad committed
25
26
27
28
29
30
31
32
33
34
35
   void* value;
   struct HashtableItem* next;
} HashtableItem;

struct Hashtable_ {
   int size;
   HashtableItem** buckets;
   int items;
   bool owner;
};

Hisham Muhammad's avatar
Hisham Muhammad committed
36
37
38
39
40
41
#ifdef DEBUG

int Hashtable_count(Hashtable* this);

#endif

Hisham Muhammad's avatar
Hisham Muhammad committed
42
43
44
45
Hashtable* Hashtable_new(int size, bool owner);

void Hashtable_delete(Hashtable* this);

46
void Hashtable_put(Hashtable* this, unsigned int key, void* value);
Hisham Muhammad's avatar
Hisham Muhammad committed
47

48
void* Hashtable_remove(Hashtable* this, unsigned int key);
Hisham Muhammad's avatar
Hisham Muhammad committed
49

50
extern void* Hashtable_get(Hashtable* this, unsigned int key);
Hisham Muhammad's avatar
Hisham Muhammad committed
51
52
53
54

void Hashtable_foreach(Hashtable* this, Hashtable_PairFunction f, void* userData);

#endif