### Function

# GLib HashTable foreach

#### Declaration [src]

    void
    g_hash_table_foreach (
      GHashTable* hash_table,
      GHFunc func,
      gpointer user_data
    )

#### Description [src]

Calls the given function for each of the key/value pairs in the `GHashTable`. The function is passed the key and value of each pair, and the given `user_data` parameter. The hash table may not be modified while iterating over it (you can’t add/remove items). To remove all items matching a predicate, use g_hash_table_foreach_remove().

The order in which `g_hash_table_foreach()` iterates over the keys/values in the hash table is not defined.

See `g_hash_table_find()` for performance caveats for linear order searches in contrast to g_hash_table_lookup().

#### Parameters

`hash_table`

  Type: `GHashTable`

  A `GHashTable`.

  The data is owned by the caller of the function.

`func`

  Type: `GHFunc`

  The function to call for each key/value pair.

`user_data`

  Type: `gpointer`

  User data to pass to the function.

  The argument can be `NULL`.
  The data is owned by the caller of the function.