2006-03-04 18:16:49 +00:00
|
|
|
#ifndef HEADER_Hashtable
|
|
|
|
#define HEADER_Hashtable
|
|
|
|
/*
|
2011-12-26 21:35:57 +00:00
|
|
|
htop - Hashtable.h
|
2011-05-26 16:35:07 +00:00
|
|
|
(C) 2004-2011 Hisham H. Muhammad
|
2020-10-05 07:51:32 +00:00
|
|
|
Released under the GNU GPLv2, see the COPYING file
|
2006-03-04 18:16:49 +00:00
|
|
|
in the source distribution for its full text.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdbool.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;
|
|
|
|
};
|
|
|
|
|
2020-09-17 20:27:33 +00:00
|
|
|
#ifndef NDEBUG
|
2006-11-12 21:52:14 +00:00
|
|
|
|
2020-09-02 07:38:44 +00:00
|
|
|
int Hashtable_count(Hashtable* this);
|
2006-11-12 21:52:14 +00:00
|
|
|
|
2020-09-17 20:27:33 +00:00
|
|
|
#endif /* NDEBUG */
|
2006-11-12 21:52:14 +00:00
|
|
|
|
2020-09-02 07:38:44 +00:00
|
|
|
Hashtable* Hashtable_new(int size, bool owner);
|
2006-03-04 18:16:49 +00:00
|
|
|
|
2020-09-02 07:38:44 +00:00
|
|
|
void Hashtable_delete(Hashtable* this);
|
2006-03-04 18:16:49 +00:00
|
|
|
|
2020-09-02 07:38:44 +00:00
|
|
|
void Hashtable_put(Hashtable* this, unsigned int key, void* value);
|
2006-03-04 18:16:49 +00:00
|
|
|
|
2020-09-02 07:38:44 +00:00
|
|
|
void* Hashtable_remove(Hashtable* this, unsigned int key);
|
2006-11-12 21:52:14 +00:00
|
|
|
|
2020-09-02 07:38:44 +00:00
|
|
|
void* Hashtable_get(Hashtable* this, unsigned int key);
|
2006-03-04 18:16:49 +00:00
|
|
|
|
2020-09-02 07:38:44 +00:00
|
|
|
void Hashtable_foreach(Hashtable* this, Hashtable_PairFunction f, void* userData);
|
2006-03-04 18:16:49 +00:00
|
|
|
|
|
|
|
#endif
|