Package org.gnome.glib
Class HashTableIter
java.lang.Object
io.github.jwharm.javagi.base.ProxyInstance
org.gnome.glib.HashTableIter
- All Implemented Interfaces:
Proxy
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.
-
Constructor Summary
ConstructorDescriptionAllocate a new HashTableIter.HashTableIter
(Arena arena) Allocate a new HashTableIter.HashTableIter
(MemorySegment address) Create a HashTableIter proxy instance for the provided memory address.HashTableIter
(MemorySegment dummy1, MemorySegment dummy2, MemorySegment dummy3, int dummy4, boolean dummy5, MemorySegment dummy6) Allocate a new HashTableIter with the fields set to the provided values.HashTableIter
(MemorySegment dummy1, MemorySegment dummy2, MemorySegment dummy3, int dummy4, boolean dummy5, MemorySegment dummy6, Arena arena) Allocate a new HashTableIter with the fields set to the provided values. -
Method Summary
Modifier and TypeMethodDescriptionReturns theGHashTable
associated with this HashTableIter.static MemoryLayout
The memory layout of the native struct.void
init
(HashTable<MemorySegment, MemorySegment> hashTable) Initializes a key/value pair iterator and associates it withhashTable
.boolean
next
(@Nullable Out<MemorySegment> key, @Nullable Out<MemorySegment> value) Advances this HashTableIter and retrieves the key and/or value that are now pointed to as a result of this advancement.Read the value of the fielddummy1
.Read the value of the fielddummy2
.Read the value of the fielddummy3
.int
Read the value of the fielddummy4
.boolean
Read the value of the fielddummy5
.Read the value of the fielddummy6
.void
remove()
Removes the key/value pair currently pointed to by the iterator from its associatedGHashTable
.void
replace
(@Nullable MemorySegment value) Replaces the value currently pointed to by the iterator from its associatedGHashTable
.void
steal()
Removes the key/value pair currently pointed to by the iterator from its associatedGHashTable
, without calling the key and value destroy functions.void
writeDummy1
(MemorySegment dummy1) Write a value in the fielddummy1
.void
writeDummy2
(MemorySegment dummy2) Write a value in the fielddummy2
.void
writeDummy3
(MemorySegment dummy3) Write a value in the fielddummy3
.void
writeDummy4
(int dummy4) Write a value in the fielddummy4
.void
writeDummy5
(boolean dummy5) Write a value in the fielddummy5
.void
writeDummy6
(MemorySegment dummy6) Write a value in the fielddummy6
.Methods inherited from class io.github.jwharm.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
HashTableIter
Create a HashTableIter proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
HashTableIter
Allocate a new HashTableIter.- Parameters:
arena
- to control the memory allocation scope
-
HashTableIter
public HashTableIter()Allocate a new HashTableIter. The memory is allocated withArena.ofAuto()
. -
HashTableIter
public HashTableIter(MemorySegment dummy1, MemorySegment dummy2, MemorySegment dummy3, int dummy4, boolean dummy5, MemorySegment dummy6, Arena arena) Allocate a new HashTableIter with the fields set to the provided values.- Parameters:
dummy1
- value for the fielddummy1
dummy2
- value for the fielddummy2
dummy3
- value for the fielddummy3
dummy4
- value for the fielddummy4
dummy5
- value for the fielddummy5
dummy6
- value for the fielddummy6
arena
- to control the memory allocation scope
-
HashTableIter
public HashTableIter(MemorySegment dummy1, MemorySegment dummy2, MemorySegment dummy3, int dummy4, boolean dummy5, MemorySegment dummy6) Allocate a new HashTableIter with the fields set to the provided values. The memory is allocated withArena.ofAuto()
.- Parameters:
dummy1
- value for the fielddummy1
dummy2
- value for the fielddummy2
dummy3
- value for the fielddummy3
dummy4
- value for the fielddummy4
dummy5
- value for the fielddummy5
dummy6
- value for the fielddummy6
-
-
Method Details
-
getMemoryLayout
The memory layout of the native struct.- Returns:
- the memory layout
-
readDummy1
Read the value of the fielddummy1
.- Returns:
- The value of the field
dummy1
-
writeDummy1
Write a value in the fielddummy1
.- Parameters:
dummy1
- The new value for the fielddummy1
-
readDummy2
Read the value of the fielddummy2
.- Returns:
- The value of the field
dummy2
-
writeDummy2
Write a value in the fielddummy2
.- Parameters:
dummy2
- The new value for the fielddummy2
-
readDummy3
Read the value of the fielddummy3
.- Returns:
- The value of the field
dummy3
-
writeDummy3
Write a value in the fielddummy3
.- Parameters:
dummy3
- The new value for the fielddummy3
-
readDummy4
public int readDummy4()Read the value of the fielddummy4
.- Returns:
- The value of the field
dummy4
-
writeDummy4
public void writeDummy4(int dummy4) Write a value in the fielddummy4
.- Parameters:
dummy4
- The new value for the fielddummy4
-
readDummy5
public boolean readDummy5()Read the value of the fielddummy5
.- Returns:
- The value of the field
dummy5
-
writeDummy5
public void writeDummy5(boolean dummy5) Write a value in the fielddummy5
.- Parameters:
dummy5
- The new value for the fielddummy5
-
readDummy6
Read the value of the fielddummy6
.- Returns:
- The value of the field
dummy6
-
writeDummy6
Write a value in the fielddummy6
.- Parameters:
dummy6
- The new value for the fielddummy6
-
getHashTable
Returns theGHashTable
associated with this HashTableIter.- Returns:
- the
GHashTable
associated with this HashTableIter.
-
init
Initializes a key/value pair iterator and associates it withhashTable
. 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
- aGHashTable
-
next
public boolean next(@Nullable @Nullable Out<MemorySegment> key, @Nullable @Nullable Out<MemorySegment> value) Advances this HashTableIter and retrieves the key and/or value that are now pointed to as a result of this advancement. Iffalse
is returned,key
andvalue
are not set, and the iterator becomes invalid.- Parameters:
key
- a location to store the keyvalue
- a location to store the value- Returns:
false
if the end of theGHashTable
has been reached.
-
remove
public void remove()Removes the key/value pair currently pointed to by the iterator from its associatedGHashTable
. Can only be called after g_hash_table_iter_next() returnedtrue
, 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); }
-
replace
Replaces the value currently pointed to by the iterator from its associatedGHashTable
. Can only be called after g_hash_table_iter_next() returnedtrue
.If you supplied a
valueDestroyFunc
when creating theGHashTable
, the old value is freed using that function.- Parameters:
value
- the value to replace with
-
steal
public void steal()Removes the key/value pair currently pointed to by the iterator from its associatedGHashTable
, without calling the key and value destroy functions. Can only be called after g_hash_table_iter_next() returnedtrue
, and cannot be called more than once for the same key/value pair.
-