Gjsify LogoGjsify Logo

A GHashTableIter structure represents an iterator that can be used to iterate over the elements of a #GHashTable. GHashTableIter structures are typically allocated on the stack and then initialized with g_hash_table_iter_init().

The iteration order of a #GHashTableIter over the keys/values in a hash table is not defined.

record

Hierarchy

  • HashTableIter

Index

Constructors

Properties

Methods

Constructors

Properties

name: string

Methods

  • init(hashTable: HashTable<string | number | symbol, string | number | boolean>): void
  • Initializes a key/value pair iterator and associates it with hash_table. Modifying the hash table after calling this function invalidates the returned iterator.

    The iteration order of a #GHashTableIter over the keys/values in a hash table is not defined.

    GHashTableIter iter;
    gpointer key, value;

    g_hash_table_iter_init (&iter, hash_table);
    while (g_hash_table_iter_next (&iter, &key, &value))
    {
    // do something with key and value
    }

    Parameters

    • hashTable: HashTable<string | number | symbol, string | number | boolean>

      a #GHashTable

    Returns void

  • next(): [boolean, object, object]
  • Advances iter and retrieves the key and/or value that are now pointed to as a result of this advancement. If %FALSE is returned, key and value are not set, and the iterator becomes invalid.

    Returns [boolean, object, object]

  • remove(): void
  • Removes the key/value pair currently pointed to by the iterator from its associated #GHashTable. Can only be called after g_hash_table_iter_next() returned %TRUE, and cannot be called more than once for the same key/value pair.

    If the #GHashTable was created using g_hash_table_new_full(), the key and value are freed using the supplied destroy functions, otherwise you have to make sure that any dynamically allocated values are freed yourself.

    It is safe to continue iterating the #GHashTable afterward:

    while (g_hash_table_iter_next (&iter, &key, &value))
    {
    if (condition)
    g_hash_table_iter_remove (&iter);
    }

    Returns void

  • replace(value: object): void
  • Replaces the value currently pointed to by the iterator from its associated #GHashTable. Can only be called after g_hash_table_iter_next() returned %TRUE.

    If you supplied a value_destroy_func when creating the #GHashTable, the old value is freed using that function.

    Parameters

    • value: object

      the value to replace with

    Returns void

  • steal(): void
  • Removes the key/value pair currently pointed to by the iterator from its associated #GHashTable, without calling the key and value destroy functions. Can only be called after g_hash_table_iter_next() returned %TRUE, and cannot be called more than once for the same key/value pair.

    Returns void

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Type alias with type parameter
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method