Class HashTableIter

java.lang.Object
org.javagi.base.ProxyInstance
org.gnome.glib.HashTableIter
All Implemented Interfaces:
Proxy

@Generated("org.javagi.JavaGI") public class HashTableIter extends ProxyInstance

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 Details

    • HashTableIter

      public HashTableIter(MemorySegment address)
      Create a HashTableIter proxy instance for the provided memory address.
      Parameters:
      address - the memory address of the native object
    • HashTableIter

      public HashTableIter(Arena arena)
      Allocate a new HashTableIter.
      Parameters:
      arena - to control the memory allocation scope
    • HashTableIter

      public HashTableIter()
      Allocate a new HashTableIter. The memory is allocated with Arena.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 field dummy1
      dummy2 - value for the field dummy2
      dummy3 - value for the field dummy3
      dummy4 - value for the field dummy4
      dummy5 - value for the field dummy5
      dummy6 - value for the field dummy6
      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 with Arena.ofAuto().
      Parameters:
      dummy1 - value for the field dummy1
      dummy2 - value for the field dummy2
      dummy3 - value for the field dummy3
      dummy4 - value for the field dummy4
      dummy5 - value for the field dummy5
      dummy6 - value for the field dummy6
  • Method Details

    • getMemoryLayout

      public static MemoryLayout getMemoryLayout()
      The memory layout of the native struct.
      Returns:
      the memory layout
    • readDummy1

      public MemorySegment readDummy1()
      Read the value of the field dummy1.
      Returns:
      The value of the field dummy1
    • writeDummy1

      public void writeDummy1(MemorySegment dummy1)
      Write a value in the field dummy1.
      Parameters:
      dummy1 - The new value for the field dummy1
    • readDummy2

      public MemorySegment readDummy2()
      Read the value of the field dummy2.
      Returns:
      The value of the field dummy2
    • writeDummy2

      public void writeDummy2(MemorySegment dummy2)
      Write a value in the field dummy2.
      Parameters:
      dummy2 - The new value for the field dummy2
    • readDummy3

      public MemorySegment readDummy3()
      Read the value of the field dummy3.
      Returns:
      The value of the field dummy3
    • writeDummy3

      public void writeDummy3(MemorySegment dummy3)
      Write a value in the field dummy3.
      Parameters:
      dummy3 - The new value for the field dummy3
    • readDummy4

      public int readDummy4()
      Read the value of the field dummy4.
      Returns:
      The value of the field dummy4
    • writeDummy4

      public void writeDummy4(int dummy4)
      Write a value in the field dummy4.
      Parameters:
      dummy4 - The new value for the field dummy4
    • readDummy5

      public boolean readDummy5()
      Read the value of the field dummy5.
      Returns:
      The value of the field dummy5
    • writeDummy5

      public void writeDummy5(boolean dummy5)
      Write a value in the field dummy5.
      Parameters:
      dummy5 - The new value for the field dummy5
    • readDummy6

      public MemorySegment readDummy6()
      Read the value of the field dummy6.
      Returns:
      The value of the field dummy6
    • writeDummy6

      public void writeDummy6(MemorySegment dummy6)
      Write a value in the field dummy6.
      Parameters:
      dummy6 - The new value for the field dummy6
    • getHashTable

      public HashTable<MemorySegment, MemorySegment> getHashTable()
      Returns the GHashTable associated with iter.
      Returns:
      the GHashTable associated with iter.
      Since:
      2.16
    • init

      public void init(HashTable<MemorySegment, MemorySegment> hashTable)

      Initializes a key/value pair iterator and associates it with hashTable. 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 - a GHashTable
      Since:
      2.16
    • next

      public 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. If false is returned, key and value are not set, and the iterator becomes invalid.
      Parameters:
      key - a location to store the key
      value - a location to store the value
      Returns:
      false if the end of the GHashTable has been reached.
      Since:
      2.16
    • remove

      public void remove()

      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);
        }
      
      Since:
      2.16
    • replace

      public void replace(@Nullable MemorySegment value)

      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 valueDestroyFunc when creating the GHashTable, the old value is freed using that function.

      Parameters:
      value - the value to replace with
      Since:
      2.30
    • steal

      public void steal()
      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.
      Since:
      2.16