FFmpeg
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
Functions
hashtable.h File Reference
#include <stddef.h>

Go to the source code of this file.

Functions

int ff_hashtable_alloc (struct FFHashtableContext **ctx, size_t key_size, size_t val_size, size_t max_entries)
 Create a fixed-sized Robin Hood hash table. More...
 
int ff_hashtable_get (const struct FFHashtableContext *ctx, const void *key, void *val)
 Look up a value from a hash table given a key. More...
 
int ff_hashtable_set (struct FFHashtableContext *ctx, const void *key, const void *val)
 Store a value in a hash table given a key. More...
 
int ff_hashtable_delete (struct FFHashtableContext *ctx, const void *key)
 Delete a value from a hash table given a key. More...
 
void ff_hashtable_clear (struct FFHashtableContext *ctx)
 Delete all values from a hash table. More...
 
void ff_hashtable_freep (struct FFHashtableContext **ctx)
 Free a hash table. More...
 

Function Documentation

◆ ff_hashtable_alloc()

int ff_hashtable_alloc ( struct FFHashtableContext **  ctx,
size_t  key_size,
size_t  val_size,
size_t  max_entries 
)

Create a fixed-sized Robin Hood hash table.

Parameters
ctxcontext to allocate and initialize
key_sizesize of key type in bytes
val_sizesize of value type in bytes
max_entriesmaximum number of key-value pairs to store
Returns
zero on success, nonzero on error

Definition at line 59 of file hashtable.c.

Referenced by dxv_init(), and main().

◆ ff_hashtable_get()

int ff_hashtable_get ( const struct FFHashtableContext ctx,
const void *  key,
void *  val 
)

Look up a value from a hash table given a key.

Parameters
ctxhash table context
keypointer to key data
valdestination pointer for value data
Returns
1 if the key is found, zero if the key is not found

Definition at line 97 of file hashtable.c.

Referenced by dxv_compress_dxt1(), and main().

◆ ff_hashtable_set()

int ff_hashtable_set ( struct FFHashtableContext ctx,
const void *  key,
const void *  val 
)

Store a value in a hash table given a key.

Parameters
ctxhash table context
keypointer to key data
valpointer for value data
Returns
1 if the key is written, zero if the key is not written due to the hash table reaching max capacity

Definition at line 119 of file hashtable.c.

Referenced by dxv_compress_dxt1(), and main().

◆ ff_hashtable_delete()

int ff_hashtable_delete ( struct FFHashtableContext ctx,
const void *  key 
)

Delete a value from a hash table given a key.

Parameters
ctxhash table context
keypointer to key data
Returns
1 if the key is deleted, zero if the key is not deleted due to not being found

Definition at line 163 of file hashtable.c.

Referenced by dxv_compress_dxt1(), and main().

◆ ff_hashtable_clear()

void ff_hashtable_clear ( struct FFHashtableContext ctx)

Delete all values from a hash table.

Parameters
ctxhash table context

Definition at line 201 of file hashtable.c.

Referenced by dxv_compress_dxt1().

◆ ff_hashtable_freep()

void ff_hashtable_freep ( struct FFHashtableContext **  ctx)

Free a hash table.

Parameters
ctxhash table context

Definition at line 206 of file hashtable.c.

Referenced by dxv_close(), ff_hashtable_alloc(), and main().