2.4.2.2 Setup — Zix 0.6.2 documentation

# 2.4.2.2 Setup

typedef const ZixHashKey *(*ZixKeyFunc)(const ZixHashRecord *record)

  User function for getting the key of a record.

typedef ZixHashCode (*ZixHashFunc)(const ZixHashKey *key)

  User function for computing the hash of a key.

typedef bool (*ZixKeyEqualFunc)(const ZixHashKey *a, const ZixHashKey *b)

  User function for determining if two keys are truly equal.

ZixHash *zix_hash_new(ZixAllocator *allocator, ZixKeyFunc key_func, ZixHashFunc hash_func, ZixKeyEqualFunc equal_func)

  Create a new hash table.

  Parameters:

    - allocator – Allocator used for the internal array.

    - key_func – A function to retrieve the key from a record.

    - hash_func – The key hashing function.

    - equal_func – A function to test keys for equality.

void zix_hash_free(ZixHash *hash)

  Free `hash`

size_t zix_hash_size(const ZixHash *hash)

  Return the number of elements in the hash.