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