GLib.HashTableIter¶
Fields¶
Name |
Type |
Access |
Description |
---|---|---|---|
dummy1 |
r |
||
dummy2 |
r |
||
dummy3 |
r |
||
dummy4 |
r |
||
dummy5 |
r |
||
dummy6 |
r |
Methods¶
|
|
|
|
|
|
|
|
|
Details¶
- class GLib.HashTableIter¶
A
GLib.HashTableIter
structure represents an iterator that can be used to iterate over the elements of aGLib.HashTable
.GLib.HashTableIter
structures are typically allocated on the stack and then initialized withGLib.HashTableIter.init
().The iteration order of a
GLib.HashTableIter
over the keys/values in a hash table is not defined.- get_hash_table()[source]¶
- Returns:
the
GLib.HashTable
associated with self.- Return type:
Returns the
GLib.HashTable
associated with self.New in version 2.16.
- init(hash_table)[source]¶
- Parameters:
hash_table ({
object
:object
}) – aGLib.HashTable
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
GLib.HashTableIter
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 }
New in version 2.16.
- next()[source]¶
- Returns:
False
if the end of theGLib.HashTable
has been reached.- key:
a location to store the key
- value:
a location to store the value
- Return type:
Advances self 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.New in version 2.16.
- remove()[source]¶
Removes the key/value pair currently pointed to by the iterator from its associated
GLib.HashTable
. Can only be called afterGLib.HashTableIter.next
() returnedTrue
, and cannot be called more than once for the same key/value pair.If the
GLib.HashTable
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
GLib.HashTable
afterward:while (g_hash_table_iter_next (&iter, &key, &value)) { if (condition) g_hash_table_iter_remove (&iter); }
New in version 2.16.
- replace(value)[source]¶
-
Replaces the value currently pointed to by the iterator from its associated
GLib.HashTable
. Can only be called afterGLib.HashTableIter.next
() returnedTrue
.If you supplied a value_destroy_func when creating the
GLib.HashTable
, the old value is freed using that function.New in version 2.30.
- steal()[source]¶
Removes the key/value pair currently pointed to by the iterator from its associated
GLib.HashTable
, without calling the key and value destroy functions. Can only be called afterGLib.HashTableIter.next
() returnedTrue
, and cannot be called more than once for the same key/value pair.New in version 2.16.