Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Implemented hash_iter_keys().
  • Loading branch information
icculus committed Nov 11, 2011
1 parent 585f4b5 commit 3f6d236
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
27 changes: 27 additions & 0 deletions mojoshader_common.c
Expand Up @@ -85,6 +85,33 @@ int hash_iter(const HashTable *table, const void *key,
return 0;
} // hash_iter

int hash_iter_keys(const HashTable *table, const void **_key, void **iter)
{
HashItem *item = *iter;
int idx = 0;

if (item != NULL)
{
const HashItem *orig = item;
item = item->next;
if (item == NULL)
idx = calc_hash(table, orig->key) + 1;
} // if

while (!item && (idx < table->table_len))
item = table->table[idx++]; // skip empty buckets...

if (item == NULL) // no more matches?
{
*_key = NULL;
*iter = NULL;
return 0;
} // if

*_key = item->key;
*iter = item;
return 1;
} // hash_iter_keys

int hash_insert(HashTable *table, const void *key, const void *value)
{
Expand Down
1 change: 1 addition & 0 deletions mojoshader_internal.h
Expand Up @@ -193,6 +193,7 @@ int hash_insert(HashTable *table, const void *key, const void *value);
int hash_remove(HashTable *table, const void *key);
int hash_find(const HashTable *table, const void *key, const void **_value);
int hash_iter(const HashTable *table, const void *key, const void **_value, void **iter);
int hash_iter_keys(const HashTable *table, const void **_key, void **iter);

uint32 hash_hash_string(const void *sym, void *unused);
int hash_keymatch_string(const void *a, const void *b, void *unused);
Expand Down

0 comments on commit 3f6d236

Please sign in to comment.