您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 
 

167 行
5.7 KiB

  1. /* GLIB - Library of useful routines for C programming
  2. * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
  3. *
  4. * This library is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Lesser General Public
  6. * License as published by the Free Software Foundation; either
  7. * version 2 of the License, or (at your option) any later version.
  8. *
  9. * This library is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * Lesser General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Lesser General Public
  15. * License along with this library; if not, write to the
  16. * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  17. * Boston, MA 02111-1307, USA.
  18. */
  19. /*
  20. * Modified by the GLib Team and others 1997-2000. See the AUTHORS
  21. * file for a list of people on the GLib Team. See the ChangeLog
  22. * files for a list of changes. These files are distributed with
  23. * GLib at ftp://ftp.gtk.org/pub/gtk/.
  24. */
  25. #if defined(G_DISABLE_SINGLE_INCLUDES) && !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
  26. #error "Only <glib.h> can be included directly."
  27. #endif
  28. #ifndef __G_HASH_H__
  29. #define __G_HASH_H__
  30. #include <glib/gtypes.h>
  31. #include <glib/glist.h>
  32. G_BEGIN_DECLS
  33. typedef struct _GHashTable GHashTable;
  34. typedef gboolean (*GHRFunc) (gpointer key,
  35. gpointer value,
  36. gpointer user_data);
  37. typedef struct _GHashTableIter GHashTableIter;
  38. struct _GHashTableIter
  39. {
  40. /*< private >*/
  41. gpointer dummy1;
  42. gpointer dummy2;
  43. gpointer dummy3;
  44. int dummy4;
  45. gboolean dummy5;
  46. gpointer dummy6;
  47. };
  48. /* Hash tables
  49. */
  50. GHashTable* g_hash_table_new (GHashFunc hash_func,
  51. GEqualFunc key_equal_func);
  52. GHashTable* g_hash_table_new_full (GHashFunc hash_func,
  53. GEqualFunc key_equal_func,
  54. GDestroyNotify key_destroy_func,
  55. GDestroyNotify value_destroy_func);
  56. void g_hash_table_destroy (GHashTable *hash_table);
  57. void g_hash_table_insert (GHashTable *hash_table,
  58. gpointer key,
  59. gpointer value);
  60. void g_hash_table_replace (GHashTable *hash_table,
  61. gpointer key,
  62. gpointer value);
  63. gboolean g_hash_table_remove (GHashTable *hash_table,
  64. gconstpointer key);
  65. void g_hash_table_remove_all (GHashTable *hash_table);
  66. gboolean g_hash_table_steal (GHashTable *hash_table,
  67. gconstpointer key);
  68. void g_hash_table_steal_all (GHashTable *hash_table);
  69. gpointer g_hash_table_lookup (GHashTable *hash_table,
  70. gconstpointer key);
  71. gboolean g_hash_table_lookup_extended (GHashTable *hash_table,
  72. gconstpointer lookup_key,
  73. gpointer *orig_key,
  74. gpointer *value);
  75. void g_hash_table_foreach (GHashTable *hash_table,
  76. GHFunc func,
  77. gpointer user_data);
  78. gpointer g_hash_table_find (GHashTable *hash_table,
  79. GHRFunc predicate,
  80. gpointer user_data);
  81. guint g_hash_table_foreach_remove (GHashTable *hash_table,
  82. GHRFunc func,
  83. gpointer user_data);
  84. guint g_hash_table_foreach_steal (GHashTable *hash_table,
  85. GHRFunc func,
  86. gpointer user_data);
  87. guint g_hash_table_size (GHashTable *hash_table);
  88. GList * g_hash_table_get_keys (GHashTable *hash_table);
  89. GList * g_hash_table_get_values (GHashTable *hash_table);
  90. void g_hash_table_iter_init (GHashTableIter *iter,
  91. GHashTable *hash_table);
  92. gboolean g_hash_table_iter_next (GHashTableIter *iter,
  93. gpointer *key,
  94. gpointer *value);
  95. GHashTable* g_hash_table_iter_get_hash_table (GHashTableIter *iter);
  96. void g_hash_table_iter_remove (GHashTableIter *iter);
  97. void g_hash_table_iter_steal (GHashTableIter *iter);
  98. /* keeping hash tables alive */
  99. GHashTable* g_hash_table_ref (GHashTable *hash_table);
  100. void g_hash_table_unref (GHashTable *hash_table);
  101. #ifndef G_DISABLE_DEPRECATED
  102. /**
  103. * g_hash_table_freeze:
  104. * @hash_table: a #GHashTable
  105. *
  106. * This function is deprecated and will be removed in the next major
  107. * release of GLib. It does nothing.
  108. **/
  109. #define g_hash_table_freeze(hash_table) ((void)0)
  110. /**
  111. * g_hash_table_thaw:
  112. * @hash_table: a #GHashTable
  113. *
  114. * This function is deprecated and will be removed in the next major
  115. * release of GLib. It does nothing.
  116. **/
  117. #define g_hash_table_thaw(hash_table) ((void)0)
  118. #endif /* G_DISABLE_DEPRECATED */
  119. /* Hash Functions
  120. */
  121. gboolean g_str_equal (gconstpointer v1,
  122. gconstpointer v2);
  123. guint g_str_hash (gconstpointer v);
  124. gboolean g_int_equal (gconstpointer v1,
  125. gconstpointer v2);
  126. guint g_int_hash (gconstpointer v);
  127. gboolean g_int64_equal (gconstpointer v1,
  128. gconstpointer v2);
  129. guint g_int64_hash (gconstpointer v);
  130. gboolean g_double_equal (gconstpointer v1,
  131. gconstpointer v2);
  132. guint g_double_hash (gconstpointer v);
  133. /* This "hash" function will just return the key's address as an
  134. * unsigned integer. Useful for hashing on plain addresses or
  135. * simple integer values.
  136. * Passing NULL into g_hash_table_new() as GHashFunc has the
  137. * same effect as passing g_direct_hash().
  138. */
  139. guint g_direct_hash (gconstpointer v) G_GNUC_CONST;
  140. gboolean g_direct_equal (gconstpointer v1,
  141. gconstpointer v2) G_GNUC_CONST;
  142. G_END_DECLS
  143. #endif /* __G_HASH_H__ */