An emulator, assembler, and disassembler for the Sega Game Gear
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

hash_table.h 960 B

12345678910111213141516171819202122232425262728293031323334
  1. /* Copyright (C) 2014-2015 Ben Kurtovic <ben.kurtovic@gmail.com>
  2. Released under the terms of the MIT License. See LICENSE for details. */
  3. #pragma once
  4. #include <stdbool.h>
  5. #include <stddef.h>
  6. #include <unistd.h>
  7. #define hash_table_NEW(node, key, next, callback) \
  8. hash_table_new(offsetof(node, key), offsetof(node, next), \
  9. (HashFreeCallback) callback)
  10. /* Structs */
  11. typedef struct HashNode HashNode;
  12. typedef void (*HashFreeCallback)(HashNode*);
  13. typedef struct {
  14. HashNode **nodes;
  15. size_t buckets;
  16. size_t key_offset;
  17. size_t next_offset;
  18. HashFreeCallback free;
  19. } HashTable;
  20. /* Functions */
  21. HashTable* hash_table_new(size_t, size_t, HashFreeCallback);
  22. void hash_table_free(HashTable*);
  23. const HashNode* hash_table_find(const HashTable*, const char*, ssize_t);
  24. void hash_table_insert(HashTable*, HashNode*);
  25. bool hash_table_remove(HashTable*, const char*, ssize_t);