LMMS
Loading...
Searching...
No Matches
hash.c File Reference
#include <assert.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include "zix/hash.h"

Go to the source code of this file.

Classes

struct  ZixHashEntry
struct  ZixHashImpl

Typedefs

typedef struct ZixHashEntry ZixHashEntry

Functions

static voidzix_hash_value (ZixHashEntry *entry)
ZIX_API ZixHashzix_hash_new (ZixHashFunc hash_func, ZixEqualFunc equal_func, size_t value_size)
ZIX_API void zix_hash_free (ZixHash *hash)
ZIX_API size_t zix_hash_size (const ZixHash *hash)
static void insert_entry (ZixHashEntry **bucket, ZixHashEntry *entry)
static ZixStatus rehash (ZixHash *hash, unsigned new_n_buckets)
static ZixHashEntryfind_entry (const ZixHash *hash, const void *key, const unsigned h, const unsigned h_nomod)
ZIX_API const voidzix_hash_find (const ZixHash *hash, const void *value)
ZIX_API ZixStatus zix_hash_insert (ZixHash *hash, const void *value, const void **inserted)
ZIX_API ZixStatus zix_hash_remove (ZixHash *hash, const void *value)
ZIX_API void zix_hash_foreach (ZixHash *hash, ZixHashVisitFunc f, void *user_data)

Variables

static const unsigned sizes []

Typedef Documentation

◆ ZixHashEntry

typedef struct ZixHashEntry ZixHashEntry

Function Documentation

◆ find_entry()

ZixHashEntry * find_entry ( const ZixHash * hash,
const void * key,
const unsigned h,
const unsigned h_nomod )
inlinestatic

◆ insert_entry()

void insert_entry ( ZixHashEntry ** bucket,
ZixHashEntry * entry )
inlinestatic

◆ rehash()

ZixStatus rehash ( ZixHash * hash,
unsigned new_n_buckets )
inlinestatic

◆ zix_hash_value()

void * zix_hash_value ( ZixHashEntry * entry)
inlinestatic

Variable Documentation

◆ sizes

const unsigned sizes[]
static
Initial value:
= {
53, 97, 193, 389, 769, 1543, 3079, 6151, 12289, 24593, 49157, 98317,
196613, 393241, 786433, 1572869, 3145739, 6291469, 12582917, 25165843,
50331653, 100663319, 201326611, 402653189, 805306457, 1610612741, 0
}

Primes, each slightly less than twice its predecessor, and as far away from powers of two as possible.