QuantHash.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*
  2. * The Python Imaging Library
  3. * $Id$
  4. *
  5. * image quantizer
  6. *
  7. * Written by Toby J Sargeant <tjs@longford.cs.monash.edu.au>.
  8. *
  9. * See the README file for information on usage and redistribution.
  10. */
  11. #ifndef __QUANTHASH_H__
  12. #define __QUANTHASH_H__
  13. #include "QuantTypes.h"
  14. typedef struct _HashTable HashTable;
  15. typedef Pixel HashKey_t;
  16. typedef uint32_t HashVal_t;
  17. typedef uint32_t (*HashFunc)(const HashTable *,const HashKey_t);
  18. typedef int (*HashCmpFunc)(const HashTable *,const HashKey_t,const HashKey_t);
  19. typedef void (*IteratorFunc)(const HashTable *,const HashKey_t,const HashVal_t,void *);
  20. typedef void (*IteratorUpdateFunc)(const HashTable *,const HashKey_t,HashVal_t *,void *);
  21. typedef void (*ComputeFunc)(const HashTable *,const HashKey_t,HashVal_t *);
  22. typedef void (*CollisionFunc)(const HashTable *,HashKey_t *,HashVal_t *,HashKey_t,HashVal_t);
  23. HashTable * hashtable_new(HashFunc hf,HashCmpFunc cf);
  24. void hashtable_free(HashTable *h);
  25. void hashtable_foreach(HashTable *h,IteratorFunc i,void *u);
  26. void hashtable_foreach_update(HashTable *h,IteratorUpdateFunc i,void *u);
  27. int hashtable_insert(HashTable *h,HashKey_t key,HashVal_t val);
  28. int hashtable_lookup(const HashTable *h,const HashKey_t key,HashVal_t *valp);
  29. int hashtable_insert_or_update_computed(HashTable *h,HashKey_t key,ComputeFunc newFunc,ComputeFunc existsFunc);
  30. void *hashtable_set_user_data(HashTable *h,void *data);
  31. void *hashtable_get_user_data(const HashTable *h);
  32. uint32_t hashtable_get_count(const HashTable *h);
  33. void hashtable_rehash_compute(HashTable *h,CollisionFunc cf);
  34. #endif // __QUANTHASH_H__