25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
919B

  1. #ifndef TLHASH_H
  2. #define TLHASH_H
  3. #include <stddef.h>
  4. typedef struct el {
  5. void *key, *value;
  6. size_t key_length;
  7. struct el *next;
  8. } tlhash_element_t;
  9. typedef struct {
  10. size_t n_buckets, size;
  11. tlhash_element_t **buckets;
  12. } tlhash_t;
  13. int tlhash_init ( tlhash_t *tab, size_t n_buckets );
  14. int tlhash_finalize ( tlhash_t *tab );
  15. int tlhash_insert ( tlhash_t *tab, void *key, size_t keylen, void *val );
  16. int tlhash_lookup ( tlhash_t *tab, void *key, size_t keylen, void **val );
  17. int tlhash_remove ( tlhash_t *tab, void *key, size_t key_length );
  18. size_t tlhash_size ( tlhash_t *tab );
  19. void tlhash_keys ( tlhash_t *tab, void **keys );
  20. void tlhash_values ( tlhash_t *tab, void **values );
  21. #define TLHASH_SUCCESS 0 /* Success */
  22. #define TLHASH_ENOMEM 1 /* No memory available */
  23. #define TLHASH_ENOENT 2 /* No such table entry */
  24. #define TLHASH_EEXIST 3 /* Table entry already exists */
  25. #endif