Gjsify LogoGjsify Logo

The #GHashTable struct is an opaque data structure to represent a [Hash Table][glib-Hash-Tables]. It should only be accessed via the following functions.

record

Type Parameters

  • A = symbol | string | number

  • B = string | number | boolean

Hierarchy

  • HashTable

Index

Constructors

  • Type Parameters

    • A = string | number | symbol

    • B = string | number | boolean

    Returns HashTable<A, B>

Properties

name: string

Methods

  • add(hash_table: HashTable<string | number | symbol, string | number | boolean>, key: object): boolean
  • This is a convenience function for using a #GHashTable as a set. It is equivalent to calling g_hash_table_replace() with key as both the key and the value.

    In particular, this means that if key already exists in the hash table, then the old copy of key in the hash table is freed and key replaces it in the table.

    When a hash table only ever contains keys that have themselves as the corresponding value it is able to be stored more efficiently. See the discussion in the section description.

    Starting from GLib 2.40, this function returns a boolean value to indicate whether the newly added value was already in the hash table or not.

    Parameters

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

      a #GHashTable

    • key: object

      a key to insert

    Returns boolean

  • contains(hash_table: HashTable<string | number | symbol, string | number | boolean>, key: object): boolean
  • Checks if key is in hash_table.

    Parameters

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

      a #GHashTable

    • key: object

      a key to check

    Returns boolean

  • destroy(hash_table: HashTable<string | number | symbol, string | number | boolean>): void
  • Destroys all keys and values in the #GHashTable and decrements its reference count by 1. If keys and/or values are dynamically allocated, you should either free them first or create the #GHashTable with destroy notifiers using g_hash_table_new_full(). In the latter case the destroy functions you supplied will be called on all keys and values during the destruction phase.

    Parameters

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

      a #GHashTable

    Returns void

  • insert(hash_table: HashTable<string | number | symbol, string | number | boolean>, key: object, value: object): boolean
  • Inserts a new key and value into a #GHashTable.

    If the key already exists in the #GHashTable its current value is replaced with the new value. If you supplied a value_destroy_func when creating the #GHashTable, the old value is freed using that function. If you supplied a key_destroy_func when creating the #GHashTable, the passed key is freed using that function.

    Starting from GLib 2.40, this function returns a boolean value to indicate whether the newly added value was already in the hash table or not.

    Parameters

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

      a #GHashTable

    • key: object

      a key to insert

    • value: object

      the value to associate with the key

    Returns boolean

  • lookup(hash_table: HashTable<string | number | symbol, string | number | boolean>, key: object): object
  • Looks up a key in a #GHashTable. Note that this function cannot distinguish between a key that is not present and one which is present and has the value %NULL. If you need this distinction, use g_hash_table_lookup_extended().

    Parameters

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

      a #GHashTable

    • key: object

      the key to look up

    Returns object

  • lookup_extended(hash_table: HashTable<string | number | symbol, string | number | boolean>, lookup_key: object): [boolean, object, object]
  • Looks up a key in the #GHashTable, returning the original key and the associated value and a #gboolean which is %TRUE if the key was found. This is useful if you need to free the memory allocated for the original key, for example before calling g_hash_table_remove().

    You can actually pass %NULL for lookup_key to test whether the %NULL key exists, provided the hash and equal functions of hash_table are %NULL-safe.

    Parameters

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

      a #GHashTable

    • lookup_key: object

      the key to look up

    Returns [boolean, object, object]

  • new_similar(other_hash_table: HashTable<string | number | symbol, string | number | boolean>): HashTable<string | number | symbol, string | number | boolean>
  • Creates a new #GHashTable like g_hash_table_new_full() with a reference count of 1.

    It inherits the hash function, the key equal function, the key destroy function, as well as the value destroy function, from other_hash_table.

    The returned hash table will be empty; it will not contain the keys or values from other_hash_table.

    Parameters

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

      Another #GHashTable

    Returns HashTable<string | number | symbol, string | number | boolean>

  • remove(hash_table: HashTable<string | number | symbol, string | number | boolean>, key: object): boolean
  • Removes a key and its associated value from a #GHashTable.

    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.

    Parameters

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

      a #GHashTable

    • key: object

      the key to remove

    Returns boolean

  • remove_all(hash_table: HashTable<string | number | symbol, string | number | boolean>): void
  • Removes all keys and their associated values from a #GHashTable.

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

    Parameters

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

      a #GHashTable

    Returns void

  • replace(hash_table: HashTable<string | number | symbol, string | number | boolean>, key: object, value: object): boolean
  • Inserts a new key and value into a #GHashTable similar to g_hash_table_insert(). The difference is that if the key already exists in the #GHashTable, it gets replaced by the new key. If you supplied a value_destroy_func when creating the #GHashTable, the old value is freed using that function. If you supplied a key_destroy_func when creating the #GHashTable, the old key is freed using that function.

    Starting from GLib 2.40, this function returns a boolean value to indicate whether the newly added value was already in the hash table or not.

    Parameters

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

      a #GHashTable

    • key: object

      a key to insert

    • value: object

      the value to associate with the key

    Returns boolean

  • size(hash_table: HashTable<string | number | symbol, string | number | boolean>): number
  • Returns the number of elements contained in the #GHashTable.

    Parameters

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

      a #GHashTable

    Returns number

  • steal(hash_table: HashTable<string | number | symbol, string | number | boolean>, key: object): boolean
  • Removes a key and its associated value from a #GHashTable without calling the key and value destroy functions.

    Parameters

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

      a #GHashTable

    • key: object

      the key to remove

    Returns boolean

  • steal_all(hash_table: HashTable<string | number | symbol, string | number | boolean>): void
  • Removes all keys and their associated values from a #GHashTable without calling the key and value destroy functions.

    Parameters

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

      a #GHashTable

    Returns void

  • steal_extended(hash_table: HashTable<string | number | symbol, string | number | boolean>, lookup_key: object): [boolean, object, object]
  • Looks up a key in the #GHashTable, stealing the original key and the associated value and returning %TRUE if the key was found. If the key was not found, %FALSE is returned.

    If found, the stolen key and value are removed from the hash table without calling the key and value destroy functions, and ownership is transferred to the caller of this method; as with g_hash_table_steal().

    You can pass %NULL for lookup_key, provided the hash and equal functions of hash_table are %NULL-safe.

    Parameters

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

      a #GHashTable

    • lookup_key: object

      the key to look up

    Returns [boolean, object, object]

  • unref(hash_table: HashTable<string | number | symbol, string | number | boolean>): void
  • Atomically decrements the reference count of hash_table by one. If the reference count drops to 0, all keys and values will be destroyed, and all memory allocated by the hash table is released. This function is MT-safe and may be called from any thread.

    Parameters

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

      a valid #GHashTable

    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