~ubuntu-branches/ubuntu/precise/glib2.0/precise-updates

« back to all changes in this revision

Viewing changes to glib/ghash.c

  • Committer: Package Import Robot
  • Author(s): Sebastien Bacher
  • Date: 2012-01-10 16:23:46 UTC
  • mfrom: (1.59.35)
  • Revision ID: package-import@ubuntu.com-20120110162346-5s54yf7s1va1zb6i
Tags: 2.31.8-0ubuntu1
* New upstream version, drop patch which is in the new version
* debian/libglib2.0-0.symbols: new version update

Show diffs side-by-side

added added

removed removed

Lines of Context:
102
102
 * }
103
103
 *
104
104
 * void
105
 
 * set_insert (GHashTable *set,
106
 
 *             gpointer    element)
 
105
 * set_add (GHashTable *set,
 
106
 *          gpointer    element)
107
107
 * {
108
 
 *   g_hash_table_insert (set, element, element);
 
108
 *   g_hash_table_replace (set, element, element);
109
109
 * }
110
110
 *
111
111
 * gboolean
123
123
 * }
124
124
 * </programlisting>
125
125
 * </example>
 
126
 *
 
127
 * As of version 2.32, there is also a g_hash_table_add() function to
 
128
 * add a key to a #GHashTable that is being used as a set.
126
129
 */
127
130
 
128
131
/**
1182
1185
  g_hash_table_insert_internal (hash_table, key, value, TRUE);
1183
1186
}
1184
1187
 
 
1188
/**
 
1189
 * g_hash_table_add:
 
1190
 * @hash_table: a #GHashTable
 
1191
 * @key: a key to insert
 
1192
 *
 
1193
 * This is a convenience function for using a #GHashTable as a set.  It
 
1194
 * is equivalent to calling g_hash_table_replace() with @key as both the
 
1195
 * key and the value.
 
1196
 *
 
1197
 * When a hash table only ever contains keys that have themselves as the
 
1198
 * corresponding value it is able to be stored more efficiently.  See
 
1199
 * the discussion in the section description.
 
1200
 *
 
1201
 * Since: 2.32
 
1202
 **/
 
1203
void
 
1204
g_hash_table_add (GHashTable *hash_table,
 
1205
                  gpointer    key)
 
1206
{
 
1207
  g_hash_table_insert_internal (hash_table, key, key, TRUE);
 
1208
}
 
1209
 
 
1210
/**
 
1211
 * g_hash_table_contains:
 
1212
 * @hash_table: a #GHashTable
 
1213
 * @key: a key to check
 
1214
 *
 
1215
 * Checks if @key is in @hash_table.
 
1216
 *
 
1217
 * Since: 2.32
 
1218
 **/
 
1219
gboolean
 
1220
g_hash_table_contains (GHashTable    *hash_table,
 
1221
                       gconstpointer  key)
 
1222
{
 
1223
  guint node_index;
 
1224
  guint node_hash;
 
1225
 
 
1226
  g_return_val_if_fail (hash_table != NULL, FALSE);
 
1227
 
 
1228
  node_index = g_hash_table_lookup_node (hash_table, key, &node_hash);
 
1229
 
 
1230
  return HASH_IS_REAL (hash_table->hashes[node_index]);
 
1231
}
 
1232
 
1185
1233
/*
1186
1234
 * g_hash_table_remove_internal:
1187
1235
 * @hash_table: our #GHashTable