2006-06-06 20:28:42 +00:00
|
|
|
/* Do not edit this file. It was automatically generated. */
|
2006-03-04 18:16:49 +00:00
|
|
|
|
|
|
|
#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>
|
2006-11-12 21:52:14 +00:00
|
|
|
#include <assert.h>
|
2006-03-04 18:16:49 +00:00
|
|
|
|
|
|
|
#include "debug.h"
|
|
|
|
|
|
|
|
typedef struct Hashtable_ Hashtable;
|
|
|
|
|
|
|
|
typedef void(*Hashtable_PairFunction)(int, void*, void*);
|
|
|
|
|
|
|
|
typedef struct HashtableItem {
|
2007-04-05 19:53:23 +00:00
|
|
|
unsigned int key;
|
2006-03-04 18:16:49 +00:00
|
|
|
void* value;
|
|
|
|
struct HashtableItem* next;
|
|
|
|
} HashtableItem;
|
|
|
|
|
|
|
|
struct Hashtable_ {
|
|
|
|
int size;
|
|
|
|
HashtableItem** buckets;
|
|
|
|
int items;
|
|
|
|
bool owner;
|
|
|
|
};
|
|
|
|
|
2006-11-12 21:52:14 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
|
|
|
|
bool Hashtable_isConsistent(Hashtable* this);
|
|
|
|
|
|
|
|
int Hashtable_count(Hashtable* this);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2007-04-05 19:53:23 +00:00
|
|
|
HashtableItem* HashtableItem_new(unsigned int key, void* value);
|
2006-03-04 18:16:49 +00:00
|
|
|
|
|
|
|
Hashtable* Hashtable_new(int size, bool owner);
|
|
|
|
|
|
|
|
void Hashtable_delete(Hashtable* this);
|
|
|
|
|
2007-08-10 05:59:36 +00:00
|
|
|
extern int Hashtable_size(Hashtable* this);
|
2006-03-04 18:16:49 +00:00
|
|
|
|
2007-04-05 19:53:23 +00:00
|
|
|
void Hashtable_put(Hashtable* this, unsigned int key, void* value);
|
2006-03-04 18:16:49 +00:00
|
|
|
|
2007-04-05 19:53:23 +00:00
|
|
|
void* Hashtable_remove(Hashtable* this, unsigned int key);
|
2006-11-12 21:52:14 +00:00
|
|
|
|
2007-08-10 05:59:36 +00:00
|
|
|
extern void* Hashtable_get(Hashtable* this, unsigned int key);
|
2006-03-04 18:16:49 +00:00
|
|
|
|
|
|
|
void Hashtable_foreach(Hashtable* this, Hashtable_PairFunction f, void* userData);
|
|
|
|
|
|
|
|
#endif
|