VgaGames4

VgaGames4 - hash man-pages

[.. upper level ..]

# vg4->hash->list()

Listing entries of a hash: return key of next entry.

SYNTAX
const char * vg4->hash->list(struct VG_Hash *hsh, void **vpos)
FUNCTION PARAMETERS

hsh | Hash
vpos | For returning actual position of listing

RETURN VALUE
Returns key of next entry
DESCRIPTION
Listing entries of a hash: return key of next entry. This function list entries of a hash by returning step-by-step the next key until all entries are through. The current state is held by vpos. At the first call vpos must be NULL. The end of list has been reached, when vpos returns NULL again.
EXAMPLE

    struct VG_Hash *hsh = vg4->hash->create();
    void *vpos;
    const char *key;

    [...]  /* insert hash entries */

    /* list hash entries and remove them while listing */
    vpos = NULL;
    for (key = vg4->hash->list(hsh, &vpos); vpos != NULL; key = vg4->hash->list(hsh, &vpos)) {
      printf("- %s\n", key);
      vpos = vg4->hash->remove(hsh, key);  /* remove entry */
    }