hash.h 1.3 KB

123456789101112131415161718192021222324252627282930313233
  1. #ifndef MUPDF_FITZ_HASH_H
  2. #define MUPDF_FITZ_HASH_H
  3. #include "mupdf/fitz/system.h"
  4. #include "mupdf/fitz/context.h"
  5. #include "mupdf/fitz/output.h"
  6. /*
  7. * Generic hash-table with fixed-length keys.
  8. *
  9. * The keys and values are NOT reference counted by the hash table.
  10. * Callers are responsible for taking care the reference counts are correct.
  11. * Inserting a duplicate entry will NOT overwrite the old value, and will
  12. * return the old value.
  13. *
  14. * The drop_val callback function is only used to release values when the hash table
  15. * is destroyed.
  16. */
  17. typedef struct fz_hash_table_s fz_hash_table;
  18. typedef void (*fz_hash_table_drop_fn)(fz_context *ctx, void *val);
  19. fz_hash_table *fz_new_hash_table(fz_context *ctx, int initialsize, int keylen, int lock, fz_hash_table_drop_fn drop_val);
  20. void fz_drop_hash_table(fz_context *ctx, fz_hash_table *table);
  21. void *fz_hash_find(fz_context *ctx, fz_hash_table *table, const void *key);
  22. void *fz_hash_insert(fz_context *ctx, fz_hash_table *table, const void *key, void *val);
  23. void fz_hash_remove(fz_context *ctx, fz_hash_table *table, const void *key);
  24. void fz_print_hash(fz_context *ctx, fz_output *out, fz_hash_table *table);
  25. void fz_print_hash_details(fz_context *ctx, fz_output *out, fz_hash_table *table, void (*details)(fz_context*, fz_output*, void*), int compact);
  26. #endif