QuantHash.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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)(
  20. const HashTable *, const HashKey_t, const HashVal_t, void *);
  21. typedef void (*IteratorUpdateFunc)(
  22. const HashTable *, const HashKey_t, HashVal_t *, void *);
  23. typedef void (*ComputeFunc)(const HashTable *, const HashKey_t, HashVal_t *);
  24. typedef void (*CollisionFunc)(
  25. const HashTable *, HashKey_t *, HashVal_t *, HashKey_t, HashVal_t);
  26. HashTable *
  27. hashtable_new(HashFunc hf, HashCmpFunc cf);
  28. void
  29. hashtable_free(HashTable *h);
  30. void
  31. hashtable_foreach(HashTable *h, IteratorFunc i, void *u);
  32. void
  33. hashtable_foreach_update(HashTable *h, IteratorUpdateFunc i, void *u);
  34. int
  35. hashtable_insert(HashTable *h, HashKey_t key, HashVal_t val);
  36. int
  37. hashtable_lookup(const HashTable *h, const HashKey_t key, HashVal_t *valp);
  38. int
  39. hashtable_insert_or_update_computed(
  40. HashTable *h, HashKey_t key, ComputeFunc newFunc, ComputeFunc existsFunc);
  41. void *
  42. hashtable_set_user_data(HashTable *h, void *data);
  43. void *
  44. hashtable_get_user_data(const HashTable *h);
  45. uint32_t
  46. hashtable_get_count(const HashTable *h);
  47. void
  48. hashtable_rehash_compute(HashTable *h, CollisionFunc cf);
  49. #endif // __QUANTHASH_H__