Sign up

tutorial or example for using glib.HashTable

hi,

is there any example or tutorial for using glib.HashTable.

public this (GHashTable* gHashTable, bool ownedRef = false);
public this(GHashFunc hashFunc, GEqualFunc keyEqualFunc);

HashTable has above kind of constructor.

and insert method:

bool insert (void* key, void* value);

and the looking method:

void* lookup (void* key);

All the method and param is C kind of pointer, I'm confused.

the C code is like this:

GHashTable *table = NULL;
table = g_hash_table_new(g_str_hash, g_str_equal);

any help? Thanks!

Re: tutorial or example for using glib.HashTable

On Tue, 18 Sep 2018 14:08:50 GMT, binghoo dang wrote:

hi,

is there any example or tutorial for using glib.HashTable.

public this (GHashTable* gHashTable, bool ownedRef = false);
public this(GHashFunc hashFunc, GEqualFunc keyEqualFunc);

HashTable has above kind of constructor.

and insert method:

bool insert (void* key, void* value);

and the looking method:

void* lookup (void* key);

All the method and param is C kind of pointer, I'm confused.

the C code is like this:

GHashTable *table = NULL;
table = g_hash_table_new(g_str_hash, g_str_equal);

any help? Thanks!

Tilix uses it with the secret API, you can see an example here of creating a hashtable and populating it.

https://github.com/gnunn1/tilix/blob/e0f123cb473dc8b784e8de1ddf346f8c960b7c08/source/gx/tilix/terminal/password.d#L218

Re: tutorial or example for using glib.HashTable

On Sun, 23 Sep 2018 03:32:27 GMT, Gerald Nunn wrote:

On Tue, 18 Sep 2018 14:08:50 GMT, binghoo dang wrote:

hi,

is there any example or tutorial for using glib.HashTable.

public this (GHashTable* gHashTable, bool ownedRef = false);
public this(GHashFunc hashFunc, GEqualFunc keyEqualFunc);

HashTable has above kind of constructor.

and insert method:

bool insert (void* key, void* value);

and the looking method:

void* lookup (void* key);

All the method and param is C kind of pointer, I'm confused.

the C code is like this:

GHashTable *table = NULL;
table = g_hash_table_new(g_str_hash, g_str_equal);

any help? Thanks!

Tilix uses it with the secret API, you can see an example here of creating a hashtable and populating it.

https://github.com/gnunn1/tilix/blob/e0f123cb473dc8b784e8de1ddf346f8c960b7c08/source/gx/tilix/terminal/password.d#L218

thanks, Gerald, tilix is great as a gtkd programming reference. ^_^