1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module glib.HashTable;
26 
27 private import glib.ConstructionException;
28 private import glib.ListG;
29 private import glib.c.functions;
30 public  import glib.c.types;
31 public  import gtkc.glibtypes;
32 
33 
34 /**
35  * The #GHashTable struct is an opaque data structure to represent a
36  * [Hash Table][glib-Hash-Tables]. It should only be accessed via the
37  * following functions.
38  */
39 public class HashTable
40 {
41 	/** the main Gtk struct */
42 	protected GHashTable* gHashTable;
43 	protected bool ownedRef;
44 
45 	/** Get the main Gtk struct */
46 	public GHashTable* getHashTableStruct(bool transferOwnership = false)
47 	{
48 		if (transferOwnership)
49 			ownedRef = false;
50 		return gHashTable;
51 	}
52 
53 	/** the main Gtk struct as a void* */
54 	protected void* getStruct()
55 	{
56 		return cast(void*)gHashTable;
57 	}
58 
59 	/**
60 	 * Sets our main struct and passes it to the parent class.
61 	 */
62 	public this (GHashTable* gHashTable, bool ownedRef = false)
63 	{
64 		this.gHashTable = gHashTable;
65 		this.ownedRef = ownedRef;
66 	}
67 
68 
69 	/**
70 	 * This is a convenience function for using a #GHashTable as a set.  It
71 	 * is equivalent to calling g_hash_table_replace() with @key as both the
72 	 * key and the value.
73 	 *
74 	 * When a hash table only ever contains keys that have themselves as the
75 	 * corresponding value it is able to be stored more efficiently.  See
76 	 * the discussion in the section description.
77 	 *
78 	 * Starting from GLib 2.40, this function returns a boolean value to
79 	 * indicate whether the newly added value was already in the hash table
80 	 * or not.
81 	 *
82 	 * Params:
83 	 *     key = a key to insert
84 	 *
85 	 * Returns: %TRUE if the key did not exist yet
86 	 *
87 	 * Since: 2.32
88 	 */
89 	public bool add(void* key)
90 	{
91 		return g_hash_table_add(gHashTable, key) != 0;
92 	}
93 
94 	/**
95 	 * Checks if @key is in @hash_table.
96 	 *
97 	 * Params:
98 	 *     key = a key to check
99 	 *
100 	 * Returns: %TRUE if @key is in @hash_table, %FALSE otherwise.
101 	 *
102 	 * Since: 2.32
103 	 */
104 	public bool contains(void* key)
105 	{
106 		return g_hash_table_contains(gHashTable, key) != 0;
107 	}
108 
109 	/**
110 	 * Destroys all keys and values in the #GHashTable and decrements its
111 	 * reference count by 1. If keys and/or values are dynamically allocated,
112 	 * you should either free them first or create the #GHashTable with destroy
113 	 * notifiers using g_hash_table_new_full(). In the latter case the destroy
114 	 * functions you supplied will be called on all keys and values during the
115 	 * destruction phase.
116 	 */
117 	public void destroy()
118 	{
119 		g_hash_table_destroy(gHashTable);
120 	}
121 
122 	/**
123 	 * Calls the given function for key/value pairs in the #GHashTable
124 	 * until @predicate returns %TRUE. The function is passed the key
125 	 * and value of each pair, and the given @user_data parameter. The
126 	 * hash table may not be modified while iterating over it (you can't
127 	 * add/remove items).
128 	 *
129 	 * Note, that hash tables are really only optimized for forward
130 	 * lookups, i.e. g_hash_table_lookup(). So code that frequently issues
131 	 * g_hash_table_find() or g_hash_table_foreach() (e.g. in the order of
132 	 * once per every entry in a hash table) should probably be reworked
133 	 * to use additional or different data structures for reverse lookups
134 	 * (keep in mind that an O(n) find/foreach operation issued for all n
135 	 * values in a hash table ends up needing O(n*n) operations).
136 	 *
137 	 * Params:
138 	 *     predicate = function to test the key/value pairs for a certain property
139 	 *     userData = user data to pass to the function
140 	 *
141 	 * Returns: The value of the first key/value pair is returned,
142 	 *     for which @predicate evaluates to %TRUE. If no pair with the
143 	 *     requested property is found, %NULL is returned.
144 	 *
145 	 * Since: 2.4
146 	 */
147 	public void* find(GHRFunc predicate, void* userData)
148 	{
149 		return g_hash_table_find(gHashTable, predicate, userData);
150 	}
151 
152 	alias foreac = foreach_;
153 	/**
154 	 * Calls the given function for each of the key/value pairs in the
155 	 * #GHashTable.  The function is passed the key and value of each
156 	 * pair, and the given @user_data parameter.  The hash table may not
157 	 * be modified while iterating over it (you can't add/remove
158 	 * items). To remove all items matching a predicate, use
159 	 * g_hash_table_foreach_remove().
160 	 *
161 	 * See g_hash_table_find() for performance caveats for linear
162 	 * order searches in contrast to g_hash_table_lookup().
163 	 *
164 	 * Params:
165 	 *     func = the function to call for each key/value pair
166 	 *     userData = user data to pass to the function
167 	 */
168 	public void foreach_(GHFunc func, void* userData)
169 	{
170 		g_hash_table_foreach(gHashTable, func, userData);
171 	}
172 
173 	/**
174 	 * Calls the given function for each key/value pair in the
175 	 * #GHashTable. If the function returns %TRUE, then the key/value
176 	 * pair is removed from the #GHashTable. If you supplied key or
177 	 * value destroy functions when creating the #GHashTable, they are
178 	 * used to free the memory allocated for the removed keys and values.
179 	 *
180 	 * See #GHashTableIter for an alternative way to loop over the
181 	 * key/value pairs in the hash table.
182 	 *
183 	 * Params:
184 	 *     func = the function to call for each key/value pair
185 	 *     userData = user data to pass to the function
186 	 *
187 	 * Returns: the number of key/value pairs removed
188 	 */
189 	public uint foreachRemove(GHRFunc func, void* userData)
190 	{
191 		return g_hash_table_foreach_remove(gHashTable, func, userData);
192 	}
193 
194 	/**
195 	 * Calls the given function for each key/value pair in the
196 	 * #GHashTable. If the function returns %TRUE, then the key/value
197 	 * pair is removed from the #GHashTable, but no key or value
198 	 * destroy functions are called.
199 	 *
200 	 * See #GHashTableIter for an alternative way to loop over the
201 	 * key/value pairs in the hash table.
202 	 *
203 	 * Params:
204 	 *     func = the function to call for each key/value pair
205 	 *     userData = user data to pass to the function
206 	 *
207 	 * Returns: the number of key/value pairs removed.
208 	 */
209 	public uint foreachSteal(GHRFunc func, void* userData)
210 	{
211 		return g_hash_table_foreach_steal(gHashTable, func, userData);
212 	}
213 
214 	/**
215 	 * Retrieves every key inside @hash_table. The returned data is valid
216 	 * until changes to the hash release those keys.
217 	 *
218 	 * This iterates over every entry in the hash table to build its return value.
219 	 * To iterate over the entries in a #GHashTable more efficiently, use a
220 	 * #GHashTableIter.
221 	 *
222 	 * Returns: a #GList containing all the keys
223 	 *     inside the hash table. The content of the list is owned by the
224 	 *     hash table and should not be modified or freed. Use g_list_free()
225 	 *     when done using the list.
226 	 *
227 	 * Since: 2.14
228 	 */
229 	public ListG getKeys()
230 	{
231 		auto p = g_hash_table_get_keys(gHashTable);
232 
233 		if(p is null)
234 		{
235 			return null;
236 		}
237 
238 		return new ListG(cast(GList*) p);
239 	}
240 
241 	/**
242 	 * Retrieves every key inside @hash_table, as an array.
243 	 *
244 	 * The returned array is %NULL-terminated but may contain %NULL as a
245 	 * key.  Use @length to determine the true length if it's possible that
246 	 * %NULL was used as the value for a key.
247 	 *
248 	 * Note: in the common case of a string-keyed #GHashTable, the return
249 	 * value of this function can be conveniently cast to (const gchar **).
250 	 *
251 	 * This iterates over every entry in the hash table to build its return value.
252 	 * To iterate over the entries in a #GHashTable more efficiently, use a
253 	 * #GHashTableIter.
254 	 *
255 	 * You should always free the return result with g_free().  In the
256 	 * above-mentioned case of a string-keyed hash table, it may be
257 	 * appropriate to use g_strfreev() if you call g_hash_table_steal_all()
258 	 * first to transfer ownership of the keys.
259 	 *
260 	 * Returns: a
261 	 *     %NULL-terminated array containing each key from the table.
262 	 *
263 	 * Since: 2.40
264 	 */
265 	public void*[] getKeysAsArray()
266 	{
267 		uint length;
268 
269 		auto p = g_hash_table_get_keys_as_array(gHashTable, &length);
270 
271 		return p[0 .. length];
272 	}
273 
274 	/**
275 	 * Retrieves every value inside @hash_table. The returned data
276 	 * is valid until @hash_table is modified.
277 	 *
278 	 * This iterates over every entry in the hash table to build its return value.
279 	 * To iterate over the entries in a #GHashTable more efficiently, use a
280 	 * #GHashTableIter.
281 	 *
282 	 * Returns: a #GList containing all the values
283 	 *     inside the hash table. The content of the list is owned by the
284 	 *     hash table and should not be modified or freed. Use g_list_free()
285 	 *     when done using the list.
286 	 *
287 	 * Since: 2.14
288 	 */
289 	public ListG getValues()
290 	{
291 		auto p = g_hash_table_get_values(gHashTable);
292 
293 		if(p is null)
294 		{
295 			return null;
296 		}
297 
298 		return new ListG(cast(GList*) p);
299 	}
300 
301 	/**
302 	 * Inserts a new key and value into a #GHashTable.
303 	 *
304 	 * If the key already exists in the #GHashTable its current
305 	 * value is replaced with the new value. If you supplied a
306 	 * @value_destroy_func when creating the #GHashTable, the old
307 	 * value is freed using that function. If you supplied a
308 	 * @key_destroy_func when creating the #GHashTable, the passed
309 	 * key is freed using that function.
310 	 *
311 	 * Starting from GLib 2.40, this function returns a boolean value to
312 	 * indicate whether the newly added value was already in the hash table
313 	 * or not.
314 	 *
315 	 * Params:
316 	 *     key = a key to insert
317 	 *     value = the value to associate with the key
318 	 *
319 	 * Returns: %TRUE if the key did not exist yet
320 	 */
321 	public bool insert(void* key, void* value)
322 	{
323 		return g_hash_table_insert(gHashTable, key, value) != 0;
324 	}
325 
326 	/**
327 	 * Looks up a key in a #GHashTable. Note that this function cannot
328 	 * distinguish between a key that is not present and one which is present
329 	 * and has the value %NULL. If you need this distinction, use
330 	 * g_hash_table_lookup_extended().
331 	 *
332 	 * Params:
333 	 *     key = the key to look up
334 	 *
335 	 * Returns: the associated value, or %NULL if the key is not found
336 	 */
337 	public void* lookup(void* key)
338 	{
339 		return g_hash_table_lookup(gHashTable, key);
340 	}
341 
342 	/**
343 	 * Looks up a key in the #GHashTable, returning the original key and the
344 	 * associated value and a #gboolean which is %TRUE if the key was found. This
345 	 * is useful if you need to free the memory allocated for the original key,
346 	 * for example before calling g_hash_table_remove().
347 	 *
348 	 * You can actually pass %NULL for @lookup_key to test
349 	 * whether the %NULL key exists, provided the hash and equal functions
350 	 * of @hash_table are %NULL-safe.
351 	 *
352 	 * Params:
353 	 *     lookupKey = the key to look up
354 	 *     origKey = return location for the original key
355 	 *     value = return location for the value associated
356 	 *         with the key
357 	 *
358 	 * Returns: %TRUE if the key was found in the #GHashTable
359 	 */
360 	public bool lookupExtended(void* lookupKey, out void* origKey, out void* value)
361 	{
362 		return g_hash_table_lookup_extended(gHashTable, lookupKey, &origKey, &value) != 0;
363 	}
364 
365 	/**
366 	 * Creates a new #GHashTable with a reference count of 1.
367 	 *
368 	 * Hash values returned by @hash_func are used to determine where keys
369 	 * are stored within the #GHashTable data structure. The g_direct_hash(),
370 	 * g_int_hash(), g_int64_hash(), g_double_hash() and g_str_hash()
371 	 * functions are provided for some common types of keys.
372 	 * If @hash_func is %NULL, g_direct_hash() is used.
373 	 *
374 	 * @key_equal_func is used when looking up keys in the #GHashTable.
375 	 * The g_direct_equal(), g_int_equal(), g_int64_equal(), g_double_equal()
376 	 * and g_str_equal() functions are provided for the most common types
377 	 * of keys. If @key_equal_func is %NULL, keys are compared directly in
378 	 * a similar fashion to g_direct_equal(), but without the overhead of
379 	 * a function call. @key_equal_func is called with the key from the hash table
380 	 * as its first parameter, and the user-provided key to check against as
381 	 * its second.
382 	 *
383 	 * Params:
384 	 *     hashFunc = a function to create a hash value from a key
385 	 *     keyEqualFunc = a function to check two keys for equality
386 	 *
387 	 * Returns: a new #GHashTable
388 	 *
389 	 * Throws: ConstructionException GTK+ fails to create the object.
390 	 */
391 	public this(GHashFunc hashFunc, GEqualFunc keyEqualFunc)
392 	{
393 		auto p = g_hash_table_new(hashFunc, keyEqualFunc);
394 
395 		if(p is null)
396 		{
397 			throw new ConstructionException("null returned by new");
398 		}
399 
400 		this(cast(GHashTable*) p);
401 	}
402 
403 	/**
404 	 * Creates a new #GHashTable like g_hash_table_new() with a reference
405 	 * count of 1 and allows to specify functions to free the memory
406 	 * allocated for the key and value that get called when removing the
407 	 * entry from the #GHashTable.
408 	 *
409 	 * Since version 2.42 it is permissible for destroy notify functions to
410 	 * recursively remove further items from the hash table. This is only
411 	 * permissible if the application still holds a reference to the hash table.
412 	 * This means that you may need to ensure that the hash table is empty by
413 	 * calling g_hash_table_remove_all() before releasing the last reference using
414 	 * g_hash_table_unref().
415 	 *
416 	 * Params:
417 	 *     hashFunc = a function to create a hash value from a key
418 	 *     keyEqualFunc = a function to check two keys for equality
419 	 *     keyDestroyFunc = a function to free the memory allocated for the key
420 	 *         used when removing the entry from the #GHashTable, or %NULL
421 	 *         if you don't want to supply such a function.
422 	 *     valueDestroyFunc = a function to free the memory allocated for the
423 	 *         value used when removing the entry from the #GHashTable, or %NULL
424 	 *         if you don't want to supply such a function.
425 	 *
426 	 * Returns: a new #GHashTable
427 	 *
428 	 * Throws: ConstructionException GTK+ fails to create the object.
429 	 */
430 	public this(GHashFunc hashFunc, GEqualFunc keyEqualFunc, GDestroyNotify keyDestroyFunc, GDestroyNotify valueDestroyFunc)
431 	{
432 		auto p = g_hash_table_new_full(hashFunc, keyEqualFunc, keyDestroyFunc, valueDestroyFunc);
433 
434 		if(p is null)
435 		{
436 			throw new ConstructionException("null returned by new_full");
437 		}
438 
439 		this(cast(GHashTable*) p);
440 	}
441 
442 	alias doref = ref_;
443 	/**
444 	 * Atomically increments the reference count of @hash_table by one.
445 	 * This function is MT-safe and may be called from any thread.
446 	 *
447 	 * Returns: the passed in #GHashTable
448 	 *
449 	 * Since: 2.10
450 	 */
451 	public HashTable ref_()
452 	{
453 		auto p = g_hash_table_ref(gHashTable);
454 
455 		if(p is null)
456 		{
457 			return null;
458 		}
459 
460 		return new HashTable(cast(GHashTable*) p);
461 	}
462 
463 	/**
464 	 * Removes a key and its associated value from a #GHashTable.
465 	 *
466 	 * If the #GHashTable was created using g_hash_table_new_full(), the
467 	 * key and value are freed using the supplied destroy functions, otherwise
468 	 * you have to make sure that any dynamically allocated values are freed
469 	 * yourself.
470 	 *
471 	 * Params:
472 	 *     key = the key to remove
473 	 *
474 	 * Returns: %TRUE if the key was found and removed from the #GHashTable
475 	 */
476 	public bool remove(void* key)
477 	{
478 		return g_hash_table_remove(gHashTable, key) != 0;
479 	}
480 
481 	/**
482 	 * Removes all keys and their associated values from a #GHashTable.
483 	 *
484 	 * If the #GHashTable was created using g_hash_table_new_full(),
485 	 * the keys and values are freed using the supplied destroy functions,
486 	 * otherwise you have to make sure that any dynamically allocated
487 	 * values are freed yourself.
488 	 *
489 	 * Since: 2.12
490 	 */
491 	public void removeAll()
492 	{
493 		g_hash_table_remove_all(gHashTable);
494 	}
495 
496 	/**
497 	 * Inserts a new key and value into a #GHashTable similar to
498 	 * g_hash_table_insert(). The difference is that if the key
499 	 * already exists in the #GHashTable, it gets replaced by the
500 	 * new key. If you supplied a @value_destroy_func when creating
501 	 * the #GHashTable, the old value is freed using that function.
502 	 * If you supplied a @key_destroy_func when creating the
503 	 * #GHashTable, the old key is freed using that function.
504 	 *
505 	 * Starting from GLib 2.40, this function returns a boolean value to
506 	 * indicate whether the newly added value was already in the hash table
507 	 * or not.
508 	 *
509 	 * Params:
510 	 *     key = a key to insert
511 	 *     value = the value to associate with the key
512 	 *
513 	 * Returns: %TRUE if the key did not exist yet
514 	 */
515 	public bool replace(void* key, void* value)
516 	{
517 		return g_hash_table_replace(gHashTable, key, value) != 0;
518 	}
519 
520 	/**
521 	 * Returns the number of elements contained in the #GHashTable.
522 	 *
523 	 * Returns: the number of key/value pairs in the #GHashTable.
524 	 */
525 	public uint size()
526 	{
527 		return g_hash_table_size(gHashTable);
528 	}
529 
530 	/**
531 	 * Removes a key and its associated value from a #GHashTable without
532 	 * calling the key and value destroy functions.
533 	 *
534 	 * Params:
535 	 *     key = the key to remove
536 	 *
537 	 * Returns: %TRUE if the key was found and removed from the #GHashTable
538 	 */
539 	public bool steal(void* key)
540 	{
541 		return g_hash_table_steal(gHashTable, key) != 0;
542 	}
543 
544 	/**
545 	 * Removes all keys and their associated values from a #GHashTable
546 	 * without calling the key and value destroy functions.
547 	 *
548 	 * Since: 2.12
549 	 */
550 	public void stealAll()
551 	{
552 		g_hash_table_steal_all(gHashTable);
553 	}
554 
555 	/**
556 	 * Atomically decrements the reference count of @hash_table by one.
557 	 * If the reference count drops to 0, all keys and values will be
558 	 * destroyed, and all memory allocated by the hash table is released.
559 	 * This function is MT-safe and may be called from any thread.
560 	 *
561 	 * Since: 2.10
562 	 */
563 	public void unref()
564 	{
565 		g_hash_table_unref(gHashTable);
566 	}
567 
568 	/**
569 	 * Compares two #gpointer arguments and returns %TRUE if they are equal.
570 	 * It can be passed to g_hash_table_new() as the @key_equal_func
571 	 * parameter, when using opaque pointers compared by pointer value as
572 	 * keys in a #GHashTable.
573 	 *
574 	 * This equality function is also appropriate for keys that are integers
575 	 * stored in pointers, such as `GINT_TO_POINTER (n)`.
576 	 *
577 	 * Params:
578 	 *     v1 = a key
579 	 *     v2 = a key to compare with @v1
580 	 *
581 	 * Returns: %TRUE if the two keys match.
582 	 */
583 	public static bool directEqual(void* v1, void* v2)
584 	{
585 		return g_direct_equal(v1, v2) != 0;
586 	}
587 
588 	/**
589 	 * Converts a gpointer to a hash value.
590 	 * It can be passed to g_hash_table_new() as the @hash_func parameter,
591 	 * when using opaque pointers compared by pointer value as keys in a
592 	 * #GHashTable.
593 	 *
594 	 * This hash function is also appropriate for keys that are integers
595 	 * stored in pointers, such as `GINT_TO_POINTER (n)`.
596 	 *
597 	 * Params:
598 	 *     v = a #gpointer key
599 	 *
600 	 * Returns: a hash value corresponding to the key.
601 	 */
602 	public static uint directHash(void* v)
603 	{
604 		return g_direct_hash(v);
605 	}
606 
607 	/**
608 	 * Compares the two #gdouble values being pointed to and returns
609 	 * %TRUE if they are equal.
610 	 * It can be passed to g_hash_table_new() as the @key_equal_func
611 	 * parameter, when using non-%NULL pointers to doubles as keys in a
612 	 * #GHashTable.
613 	 *
614 	 * Params:
615 	 *     v1 = a pointer to a #gdouble key
616 	 *     v2 = a pointer to a #gdouble key to compare with @v1
617 	 *
618 	 * Returns: %TRUE if the two keys match.
619 	 *
620 	 * Since: 2.22
621 	 */
622 	public static bool doubleEqual(void* v1, void* v2)
623 	{
624 		return g_double_equal(v1, v2) != 0;
625 	}
626 
627 	/**
628 	 * Converts a pointer to a #gdouble to a hash value.
629 	 * It can be passed to g_hash_table_new() as the @hash_func parameter,
630 	 * It can be passed to g_hash_table_new() as the @hash_func parameter,
631 	 * when using non-%NULL pointers to doubles as keys in a #GHashTable.
632 	 *
633 	 * Params:
634 	 *     v = a pointer to a #gdouble key
635 	 *
636 	 * Returns: a hash value corresponding to the key.
637 	 *
638 	 * Since: 2.22
639 	 */
640 	public static uint doubleHash(void* v)
641 	{
642 		return g_double_hash(v);
643 	}
644 
645 	/**
646 	 * Compares the two #gint64 values being pointed to and returns
647 	 * %TRUE if they are equal.
648 	 * It can be passed to g_hash_table_new() as the @key_equal_func
649 	 * parameter, when using non-%NULL pointers to 64-bit integers as keys in a
650 	 * #GHashTable.
651 	 *
652 	 * Params:
653 	 *     v1 = a pointer to a #gint64 key
654 	 *     v2 = a pointer to a #gint64 key to compare with @v1
655 	 *
656 	 * Returns: %TRUE if the two keys match.
657 	 *
658 	 * Since: 2.22
659 	 */
660 	public static bool int64Equal(void* v1, void* v2)
661 	{
662 		return g_int64_equal(v1, v2) != 0;
663 	}
664 
665 	/**
666 	 * Converts a pointer to a #gint64 to a hash value.
667 	 *
668 	 * It can be passed to g_hash_table_new() as the @hash_func parameter,
669 	 * when using non-%NULL pointers to 64-bit integer values as keys in a
670 	 * #GHashTable.
671 	 *
672 	 * Params:
673 	 *     v = a pointer to a #gint64 key
674 	 *
675 	 * Returns: a hash value corresponding to the key.
676 	 *
677 	 * Since: 2.22
678 	 */
679 	public static uint int64Hash(void* v)
680 	{
681 		return g_int64_hash(v);
682 	}
683 
684 	/**
685 	 * Compares the two #gint values being pointed to and returns
686 	 * %TRUE if they are equal.
687 	 * It can be passed to g_hash_table_new() as the @key_equal_func
688 	 * parameter, when using non-%NULL pointers to integers as keys in a
689 	 * #GHashTable.
690 	 *
691 	 * Note that this function acts on pointers to #gint, not on #gint
692 	 * directly: if your hash table's keys are of the form
693 	 * `GINT_TO_POINTER (n)`, use g_direct_equal() instead.
694 	 *
695 	 * Params:
696 	 *     v1 = a pointer to a #gint key
697 	 *     v2 = a pointer to a #gint key to compare with @v1
698 	 *
699 	 * Returns: %TRUE if the two keys match.
700 	 */
701 	public static bool intEqual(void* v1, void* v2)
702 	{
703 		return g_int_equal(v1, v2) != 0;
704 	}
705 
706 	/**
707 	 * Converts a pointer to a #gint to a hash value.
708 	 * It can be passed to g_hash_table_new() as the @hash_func parameter,
709 	 * when using non-%NULL pointers to integer values as keys in a #GHashTable.
710 	 *
711 	 * Note that this function acts on pointers to #gint, not on #gint
712 	 * directly: if your hash table's keys are of the form
713 	 * `GINT_TO_POINTER (n)`, use g_direct_hash() instead.
714 	 *
715 	 * Params:
716 	 *     v = a pointer to a #gint key
717 	 *
718 	 * Returns: a hash value corresponding to the key.
719 	 */
720 	public static uint intHash(void* v)
721 	{
722 		return g_int_hash(v);
723 	}
724 
725 	/**
726 	 * Compares two strings for byte-by-byte equality and returns %TRUE
727 	 * if they are equal. It can be passed to g_hash_table_new() as the
728 	 * @key_equal_func parameter, when using non-%NULL strings as keys in a
729 	 * #GHashTable.
730 	 *
731 	 * Note that this function is primarily meant as a hash table comparison
732 	 * function. For a general-purpose, %NULL-safe string comparison function,
733 	 * see g_strcmp0().
734 	 *
735 	 * Params:
736 	 *     v1 = a key
737 	 *     v2 = a key to compare with @v1
738 	 *
739 	 * Returns: %TRUE if the two keys match
740 	 */
741 	public static bool strEqual(void* v1, void* v2)
742 	{
743 		return g_str_equal(v1, v2) != 0;
744 	}
745 
746 	/**
747 	 * Converts a string to a hash value.
748 	 *
749 	 * This function implements the widely used "djb" hash apparently
750 	 * posted by Daniel Bernstein to comp.lang.c some time ago.  The 32
751 	 * bit unsigned hash value starts at 5381 and for each byte 'c' in
752 	 * the string, is updated: `hash = hash * 33 + c`. This function
753 	 * uses the signed value of each byte.
754 	 *
755 	 * It can be passed to g_hash_table_new() as the @hash_func parameter,
756 	 * when using non-%NULL strings as keys in a #GHashTable.
757 	 *
758 	 * Note that this function may not be a perfect fit for all use cases.
759 	 * For example, it produces some hash collisions with strings as short
760 	 * as 2.
761 	 *
762 	 * Params:
763 	 *     v = a string key
764 	 *
765 	 * Returns: a hash value corresponding to the key
766 	 */
767 	public static uint strHash(void* v)
768 	{
769 		return g_str_hash(v);
770 	}
771 }