diff options
author | Daniel Dunbar <daniel@zuster.org> | 2004-01-07 09:13:43 +0300 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2004-01-07 09:13:43 +0300 |
commit | 7f609ec2aa5f3c4ec3635bf9ab3ac636089ec891 (patch) | |
tree | 70e7998d20bb0be220869bf66e59f513fed55f8c /source/blender/blenlib/BLI_ghash.h | |
parent | 8e9e9e6e357539caee8bbdc337b3369ffb574c14 (diff) |
- added BLI_ghash_size(), number of entries in table
- added GHashIterator ADT, for iterating over GHash-tables
Diffstat (limited to 'source/blender/blenlib/BLI_ghash.h')
-rw-r--r-- | source/blender/blenlib/BLI_ghash.h | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/source/blender/blenlib/BLI_ghash.h b/source/blender/blenlib/BLI_ghash.h index 11dee5df57d..d2f2bcc95e4 100644 --- a/source/blender/blenlib/BLI_ghash.h +++ b/source/blender/blenlib/BLI_ghash.h @@ -37,6 +37,7 @@ struct GHash; typedef struct GHash GHash; +typedef struct GHashIterator GHashIterator; typedef unsigned int (*GHashHashFP) (void *key); typedef int (*GHashCmpFP) (void *a, void *b); @@ -50,6 +51,59 @@ void BLI_ghash_insert (GHash *gh, void *key, void *val); void* BLI_ghash_lookup (GHash *gh, void *key); int BLI_ghash_haskey (GHash *gh, void *key); +int BLI_ghash_size (GHash *gh); + +/* *** */ + + /** + * Create a new GHashIterator. The hash table must not be mutated + * while the iterator is in use, and the iterator will step exactly + * BLI_ghash_size(gh) times before becoming done. + * + * @param gh The GHash to iterate over. + * @return Pointer to a new DynStr. + */ +GHashIterator* BLI_ghashIterator_new (GHash *gh); + /** + * Free a GHashIterator. + * + * @param ghi The iterator to free. + */ +void BLI_ghashIterator_free (GHashIterator *ghi); + + /** + * Retrieve the key from an iterator. + * + * @param ghi The iterator. + * @return The key at the current index, or NULL if the + * iterator is done. + */ +void* BLI_ghashIterator_getKey (GHashIterator *ghi); + /** + * Retrieve the value from an iterator. + * + * @param ghi The iterator. + * @return The value at the current index, or NULL if the + * iterator is done. + */ +void* BLI_ghashIterator_getValue (GHashIterator *ghi); + /** + * Steps the iterator to the next index. + * + * @param ghi The iterator. + */ +void BLI_ghashIterator_step (GHashIterator *ghi); + /** + * Determine if an iterator is done (has reached the end of + * the hash table). + * + * @param ghi The iterator. + * @return True if done, False otherwise. + */ +int BLI_ghashIterator_isDone (GHashIterator *ghi); + +/* *** */ + unsigned int BLI_ghashutil_ptrhash (void *key); int BLI_ghashutil_ptrcmp (void *a, void *b); |