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