diff options
author | Daniel Lange <DLange@git.local> | 2020-12-07 10:26:01 +0100 |
---|---|---|
committer | Daniel Lange <DLange@git.local> | 2020-12-07 10:26:01 +0100 |
commit | 65357c8c46154de4e4eca14075bfe5523bb5fc14 (patch) | |
tree | 8f430ee5a0d5de377c4e7c94e47842a27c70d7e8 /Hashtable.h | |
parent | f80394a20254938142011855f2954b3f63fe5909 (diff) | |
download | debian_htop-65357c8c46154de4e4eca14075bfe5523bb5fc14.tar.gz debian_htop-65357c8c46154de4e4eca14075bfe5523bb5fc14.tar.bz2 debian_htop-65357c8c46154de4e4eca14075bfe5523bb5fc14.zip |
New upstream version 3.0.3upstream/3.0.3
Diffstat (limited to 'Hashtable.h')
-rw-r--r-- | Hashtable.h | 41 |
1 files changed, 23 insertions, 18 deletions
diff --git a/Hashtable.h b/Hashtable.h index 144f01c..6d93478 100644 --- a/Hashtable.h +++ b/Hashtable.h @@ -3,44 +3,49 @@ /* htop - Hashtable.h (C) 2004-2011 Hisham H. Muhammad -Released under the GNU GPL, see the COPYING file +Released under the GNU GPLv2, see the COPYING file in the source distribution for its full text. */ #include <stdbool.h> -typedef struct Hashtable_ Hashtable; -typedef void(*Hashtable_PairFunction)(int, void*, void*); +typedef unsigned int hkey_t; -typedef struct HashtableItem { - unsigned int key; +typedef void(*Hashtable_PairFunction)(hkey_t key, void* value, void* userdata); + +typedef struct HashtableItem_ { + hkey_t key; + unsigned int probe; void* value; - struct HashtableItem* next; } HashtableItem; -struct Hashtable_ { - int size; - HashtableItem** buckets; - int items; +typedef struct Hashtable_ { + unsigned int size; + HashtableItem* buckets; + unsigned int items; bool owner; -}; +} Hashtable; -#ifdef DEBUG +#ifndef NDEBUG -int Hashtable_count(Hashtable* this); +unsigned int Hashtable_count(const Hashtable* this); -#endif +#endif /* NDEBUG */ -Hashtable* Hashtable_new(int size, bool owner); +Hashtable* Hashtable_new(unsigned int size, bool owner); void Hashtable_delete(Hashtable* this); -void Hashtable_put(Hashtable* this, unsigned int key, void* value); +void Hashtable_clear(Hashtable* this); + +void Hashtable_setSize(Hashtable* this, unsigned int size); + +void Hashtable_put(Hashtable* this, hkey_t key, void* value); -void* Hashtable_remove(Hashtable* this, unsigned int key); +void* Hashtable_remove(Hashtable* this, hkey_t key); -void* Hashtable_get(Hashtable* this, unsigned int key); +void* Hashtable_get(Hashtable* this, hkey_t key); void Hashtable_foreach(Hashtable* this, Hashtable_PairFunction f, void* userData); |