mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-03-03 14:42:10 +01:00
Introduced new function type GEqualFunc to return TRUE for equal params.
2000-10-30 Sebastian Wilhelmi <wilhelmi@ira.uka.de> * gcache.h, gcache.c, ghash.h, ghash.c, grel.c, grel.h, gtypes.h: Introduced new function type GEqualFunc to return TRUE for equal params. This is now used instead of GCompareFunc (which should work akin to strcmp) here. This kind of fixes Bug #14412. Note that technically GCompareFunc and GEqualFunc are still the same types, as gint == gboolean. * ghash.h, gutils.c: g_int_equal and g_direct_equal now return gboolean to be really become GEqualFunc. * gscanner.c, testglib.c, tests/hash-test.c: Some tiny changes to follow the above change.
This commit is contained in:
parent
d42361a6e3
commit
267b681370
15
ChangeLog
15
ChangeLog
@ -1,3 +1,18 @@
|
||||
2000-10-30 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
||||
|
||||
* gcache.h, gcache.c, ghash.h, ghash.c, grel.c, grel.h, gtypes.h:
|
||||
Introduced new function type GEqualFunc to return TRUE for equal
|
||||
params. This is now used instead of GCompareFunc (which should
|
||||
work akin to strcmp) here. This kind of fixes Bug #14412. Note
|
||||
that technically GCompareFunc and GEqualFunc are still the same
|
||||
types, as gint == gboolean.
|
||||
|
||||
* ghash.h, gutils.c: g_int_equal and g_direct_equal now return
|
||||
gboolean to be really become GEqualFunc.
|
||||
|
||||
* gscanner.c, testglib.c, tests/hash-test.c: Some tiny changes to
|
||||
follow the above change.
|
||||
|
||||
2000-10-27 Tor Lillqvist <tml@iki.fi>
|
||||
|
||||
* makefile.{mingw,msc}.in (glib_OBJECTS): Add gmarkup.
|
||||
|
@ -1,3 +1,18 @@
|
||||
2000-10-30 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
||||
|
||||
* gcache.h, gcache.c, ghash.h, ghash.c, grel.c, grel.h, gtypes.h:
|
||||
Introduced new function type GEqualFunc to return TRUE for equal
|
||||
params. This is now used instead of GCompareFunc (which should
|
||||
work akin to strcmp) here. This kind of fixes Bug #14412. Note
|
||||
that technically GCompareFunc and GEqualFunc are still the same
|
||||
types, as gint == gboolean.
|
||||
|
||||
* ghash.h, gutils.c: g_int_equal and g_direct_equal now return
|
||||
gboolean to be really become GEqualFunc.
|
||||
|
||||
* gscanner.c, testglib.c, tests/hash-test.c: Some tiny changes to
|
||||
follow the above change.
|
||||
|
||||
2000-10-27 Tor Lillqvist <tml@iki.fi>
|
||||
|
||||
* makefile.{mingw,msc}.in (glib_OBJECTS): Add gmarkup.
|
||||
|
@ -1,3 +1,18 @@
|
||||
2000-10-30 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
||||
|
||||
* gcache.h, gcache.c, ghash.h, ghash.c, grel.c, grel.h, gtypes.h:
|
||||
Introduced new function type GEqualFunc to return TRUE for equal
|
||||
params. This is now used instead of GCompareFunc (which should
|
||||
work akin to strcmp) here. This kind of fixes Bug #14412. Note
|
||||
that technically GCompareFunc and GEqualFunc are still the same
|
||||
types, as gint == gboolean.
|
||||
|
||||
* ghash.h, gutils.c: g_int_equal and g_direct_equal now return
|
||||
gboolean to be really become GEqualFunc.
|
||||
|
||||
* gscanner.c, testglib.c, tests/hash-test.c: Some tiny changes to
|
||||
follow the above change.
|
||||
|
||||
2000-10-27 Tor Lillqvist <tml@iki.fi>
|
||||
|
||||
* makefile.{mingw,msc}.in (glib_OBJECTS): Add gmarkup.
|
||||
|
@ -1,3 +1,18 @@
|
||||
2000-10-30 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
||||
|
||||
* gcache.h, gcache.c, ghash.h, ghash.c, grel.c, grel.h, gtypes.h:
|
||||
Introduced new function type GEqualFunc to return TRUE for equal
|
||||
params. This is now used instead of GCompareFunc (which should
|
||||
work akin to strcmp) here. This kind of fixes Bug #14412. Note
|
||||
that technically GCompareFunc and GEqualFunc are still the same
|
||||
types, as gint == gboolean.
|
||||
|
||||
* ghash.h, gutils.c: g_int_equal and g_direct_equal now return
|
||||
gboolean to be really become GEqualFunc.
|
||||
|
||||
* gscanner.c, testglib.c, tests/hash-test.c: Some tiny changes to
|
||||
follow the above change.
|
||||
|
||||
2000-10-27 Tor Lillqvist <tml@iki.fi>
|
||||
|
||||
* makefile.{mingw,msc}.in (glib_OBJECTS): Add gmarkup.
|
||||
|
@ -1,3 +1,18 @@
|
||||
2000-10-30 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
||||
|
||||
* gcache.h, gcache.c, ghash.h, ghash.c, grel.c, grel.h, gtypes.h:
|
||||
Introduced new function type GEqualFunc to return TRUE for equal
|
||||
params. This is now used instead of GCompareFunc (which should
|
||||
work akin to strcmp) here. This kind of fixes Bug #14412. Note
|
||||
that technically GCompareFunc and GEqualFunc are still the same
|
||||
types, as gint == gboolean.
|
||||
|
||||
* ghash.h, gutils.c: g_int_equal and g_direct_equal now return
|
||||
gboolean to be really become GEqualFunc.
|
||||
|
||||
* gscanner.c, testglib.c, tests/hash-test.c: Some tiny changes to
|
||||
follow the above change.
|
||||
|
||||
2000-10-27 Tor Lillqvist <tml@iki.fi>
|
||||
|
||||
* makefile.{mingw,msc}.in (glib_OBJECTS): Add gmarkup.
|
||||
|
@ -1,3 +1,18 @@
|
||||
2000-10-30 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
||||
|
||||
* gcache.h, gcache.c, ghash.h, ghash.c, grel.c, grel.h, gtypes.h:
|
||||
Introduced new function type GEqualFunc to return TRUE for equal
|
||||
params. This is now used instead of GCompareFunc (which should
|
||||
work akin to strcmp) here. This kind of fixes Bug #14412. Note
|
||||
that technically GCompareFunc and GEqualFunc are still the same
|
||||
types, as gint == gboolean.
|
||||
|
||||
* ghash.h, gutils.c: g_int_equal and g_direct_equal now return
|
||||
gboolean to be really become GEqualFunc.
|
||||
|
||||
* gscanner.c, testglib.c, tests/hash-test.c: Some tiny changes to
|
||||
follow the above change.
|
||||
|
||||
2000-10-27 Tor Lillqvist <tml@iki.fi>
|
||||
|
||||
* makefile.{mingw,msc}.in (glib_OBJECTS): Add gmarkup.
|
||||
|
@ -1,3 +1,18 @@
|
||||
2000-10-30 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
||||
|
||||
* gcache.h, gcache.c, ghash.h, ghash.c, grel.c, grel.h, gtypes.h:
|
||||
Introduced new function type GEqualFunc to return TRUE for equal
|
||||
params. This is now used instead of GCompareFunc (which should
|
||||
work akin to strcmp) here. This kind of fixes Bug #14412. Note
|
||||
that technically GCompareFunc and GEqualFunc are still the same
|
||||
types, as gint == gboolean.
|
||||
|
||||
* ghash.h, gutils.c: g_int_equal and g_direct_equal now return
|
||||
gboolean to be really become GEqualFunc.
|
||||
|
||||
* gscanner.c, testglib.c, tests/hash-test.c: Some tiny changes to
|
||||
follow the above change.
|
||||
|
||||
2000-10-27 Tor Lillqvist <tml@iki.fi>
|
||||
|
||||
* makefile.{mingw,msc}.in (glib_OBJECTS): Add gmarkup.
|
||||
|
@ -1,3 +1,18 @@
|
||||
2000-10-30 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
||||
|
||||
* gcache.h, gcache.c, ghash.h, ghash.c, grel.c, grel.h, gtypes.h:
|
||||
Introduced new function type GEqualFunc to return TRUE for equal
|
||||
params. This is now used instead of GCompareFunc (which should
|
||||
work akin to strcmp) here. This kind of fixes Bug #14412. Note
|
||||
that technically GCompareFunc and GEqualFunc are still the same
|
||||
types, as gint == gboolean.
|
||||
|
||||
* ghash.h, gutils.c: g_int_equal and g_direct_equal now return
|
||||
gboolean to be really become GEqualFunc.
|
||||
|
||||
* gscanner.c, testglib.c, tests/hash-test.c: Some tiny changes to
|
||||
follow the above change.
|
||||
|
||||
2000-10-27 Tor Lillqvist <tml@iki.fi>
|
||||
|
||||
* makefile.{mingw,msc}.in (glib_OBJECTS): Add gmarkup.
|
||||
|
6
gcache.c
6
gcache.c
@ -77,7 +77,7 @@ g_cache_new (GCacheNewFunc value_new_func,
|
||||
GCacheDestroyFunc key_destroy_func,
|
||||
GHashFunc hash_key_func,
|
||||
GHashFunc hash_value_func,
|
||||
GCompareFunc key_compare_func)
|
||||
GEqualFunc key_equal_func)
|
||||
{
|
||||
GRealCache *cache;
|
||||
|
||||
@ -87,14 +87,14 @@ g_cache_new (GCacheNewFunc value_new_func,
|
||||
g_return_val_if_fail (key_destroy_func != NULL, NULL);
|
||||
g_return_val_if_fail (hash_key_func != NULL, NULL);
|
||||
g_return_val_if_fail (hash_value_func != NULL, NULL);
|
||||
g_return_val_if_fail (key_compare_func != NULL, NULL);
|
||||
g_return_val_if_fail (key_equal_func != NULL, NULL);
|
||||
|
||||
cache = g_new (GRealCache, 1);
|
||||
cache->value_new_func = value_new_func;
|
||||
cache->value_destroy_func = value_destroy_func;
|
||||
cache->key_dup_func = key_dup_func;
|
||||
cache->key_destroy_func = key_destroy_func;
|
||||
cache->key_table = g_hash_table_new (hash_key_func, key_compare_func);
|
||||
cache->key_table = g_hash_table_new (hash_key_func, key_equal_func);
|
||||
cache->value_table = g_hash_table_new (hash_value_func, NULL);
|
||||
|
||||
return (GCache*) cache;
|
||||
|
2
gcache.h
2
gcache.h
@ -45,7 +45,7 @@ GCache* g_cache_new (GCacheNewFunc value_new_func,
|
||||
GCacheDestroyFunc key_destroy_func,
|
||||
GHashFunc hash_key_func,
|
||||
GHashFunc hash_value_func,
|
||||
GCompareFunc key_compare_func);
|
||||
GEqualFunc key_equal_func);
|
||||
void g_cache_destroy (GCache *cache);
|
||||
gpointer g_cache_insert (GCache *cache,
|
||||
gpointer key);
|
||||
|
12
ghash.c
12
ghash.c
@ -50,7 +50,7 @@ struct _GHashTable
|
||||
gint nnodes;
|
||||
GHashNode **nodes;
|
||||
GHashFunc hash_func;
|
||||
GCompareFunc key_compare_func;
|
||||
GEqualFunc key_equal_func;
|
||||
};
|
||||
|
||||
|
||||
@ -71,7 +71,7 @@ static GHashNode *node_free_list = NULL;
|
||||
|
||||
GHashTable*
|
||||
g_hash_table_new (GHashFunc hash_func,
|
||||
GCompareFunc key_compare_func)
|
||||
GEqualFunc key_equal_func)
|
||||
{
|
||||
GHashTable *hash_table;
|
||||
guint i;
|
||||
@ -80,7 +80,7 @@ g_hash_table_new (GHashFunc hash_func,
|
||||
hash_table->size = HASH_TABLE_MIN_SIZE;
|
||||
hash_table->nnodes = 0;
|
||||
hash_table->hash_func = hash_func ? hash_func : g_direct_hash;
|
||||
hash_table->key_compare_func = key_compare_func;
|
||||
hash_table->key_equal_func = key_equal_func;
|
||||
hash_table->nodes = g_new (GHashNode*, hash_table->size);
|
||||
|
||||
for (i = 0; i < hash_table->size; i++)
|
||||
@ -114,11 +114,11 @@ g_hash_table_lookup_node (GHashTable *hash_table,
|
||||
|
||||
/* Hash table lookup needs to be fast.
|
||||
* We therefore remove the extra conditional of testing
|
||||
* whether to call the key_compare_func or not from
|
||||
* whether to call the key_equal_func or not from
|
||||
* the inner loop.
|
||||
*/
|
||||
if (hash_table->key_compare_func)
|
||||
while (*node && !(*hash_table->key_compare_func) ((*node)->key, key))
|
||||
if (hash_table->key_equal_func)
|
||||
while (*node && !(*hash_table->key_equal_func) ((*node)->key, key))
|
||||
node = &(*node)->next;
|
||||
else
|
||||
while (*node && (*node)->key != key)
|
||||
|
6
ghash.h
6
ghash.h
@ -40,7 +40,7 @@ typedef gboolean (*GHRFunc) (gpointer key,
|
||||
/* Hash tables
|
||||
*/
|
||||
GHashTable* g_hash_table_new (GHashFunc hash_func,
|
||||
GCompareFunc key_compare_func);
|
||||
GEqualFunc key_equal_func);
|
||||
void g_hash_table_destroy (GHashTable *hash_table);
|
||||
void g_hash_table_insert (GHashTable *hash_table,
|
||||
gpointer key,
|
||||
@ -72,7 +72,7 @@ gboolean g_str_equal (gconstpointer v,
|
||||
gconstpointer v2);
|
||||
guint g_str_hash (gconstpointer v);
|
||||
|
||||
gint g_int_equal (gconstpointer v,
|
||||
gboolean g_int_equal (gconstpointer v,
|
||||
gconstpointer v2) G_GNUC_CONST;
|
||||
guint g_int_hash (gconstpointer v) G_GNUC_CONST;
|
||||
|
||||
@ -83,7 +83,7 @@ guint g_int_hash (gconstpointer v) G_GNUC_CONST;
|
||||
* same effect as passing g_direct_hash().
|
||||
*/
|
||||
guint g_direct_hash (gconstpointer v) G_GNUC_CONST;
|
||||
gint g_direct_equal (gconstpointer v,
|
||||
gboolean g_direct_equal (gconstpointer v,
|
||||
gconstpointer v2) G_GNUC_CONST;
|
||||
|
||||
G_END_DECLS
|
||||
|
@ -77,7 +77,7 @@ g_cache_new (GCacheNewFunc value_new_func,
|
||||
GCacheDestroyFunc key_destroy_func,
|
||||
GHashFunc hash_key_func,
|
||||
GHashFunc hash_value_func,
|
||||
GCompareFunc key_compare_func)
|
||||
GEqualFunc key_equal_func)
|
||||
{
|
||||
GRealCache *cache;
|
||||
|
||||
@ -87,14 +87,14 @@ g_cache_new (GCacheNewFunc value_new_func,
|
||||
g_return_val_if_fail (key_destroy_func != NULL, NULL);
|
||||
g_return_val_if_fail (hash_key_func != NULL, NULL);
|
||||
g_return_val_if_fail (hash_value_func != NULL, NULL);
|
||||
g_return_val_if_fail (key_compare_func != NULL, NULL);
|
||||
g_return_val_if_fail (key_equal_func != NULL, NULL);
|
||||
|
||||
cache = g_new (GRealCache, 1);
|
||||
cache->value_new_func = value_new_func;
|
||||
cache->value_destroy_func = value_destroy_func;
|
||||
cache->key_dup_func = key_dup_func;
|
||||
cache->key_destroy_func = key_destroy_func;
|
||||
cache->key_table = g_hash_table_new (hash_key_func, key_compare_func);
|
||||
cache->key_table = g_hash_table_new (hash_key_func, key_equal_func);
|
||||
cache->value_table = g_hash_table_new (hash_value_func, NULL);
|
||||
|
||||
return (GCache*) cache;
|
||||
|
@ -45,7 +45,7 @@ GCache* g_cache_new (GCacheNewFunc value_new_func,
|
||||
GCacheDestroyFunc key_destroy_func,
|
||||
GHashFunc hash_key_func,
|
||||
GHashFunc hash_value_func,
|
||||
GCompareFunc key_compare_func);
|
||||
GEqualFunc key_equal_func);
|
||||
void g_cache_destroy (GCache *cache);
|
||||
gpointer g_cache_insert (GCache *cache,
|
||||
gpointer key);
|
||||
|
12
glib/ghash.c
12
glib/ghash.c
@ -50,7 +50,7 @@ struct _GHashTable
|
||||
gint nnodes;
|
||||
GHashNode **nodes;
|
||||
GHashFunc hash_func;
|
||||
GCompareFunc key_compare_func;
|
||||
GEqualFunc key_equal_func;
|
||||
};
|
||||
|
||||
|
||||
@ -71,7 +71,7 @@ static GHashNode *node_free_list = NULL;
|
||||
|
||||
GHashTable*
|
||||
g_hash_table_new (GHashFunc hash_func,
|
||||
GCompareFunc key_compare_func)
|
||||
GEqualFunc key_equal_func)
|
||||
{
|
||||
GHashTable *hash_table;
|
||||
guint i;
|
||||
@ -80,7 +80,7 @@ g_hash_table_new (GHashFunc hash_func,
|
||||
hash_table->size = HASH_TABLE_MIN_SIZE;
|
||||
hash_table->nnodes = 0;
|
||||
hash_table->hash_func = hash_func ? hash_func : g_direct_hash;
|
||||
hash_table->key_compare_func = key_compare_func;
|
||||
hash_table->key_equal_func = key_equal_func;
|
||||
hash_table->nodes = g_new (GHashNode*, hash_table->size);
|
||||
|
||||
for (i = 0; i < hash_table->size; i++)
|
||||
@ -114,11 +114,11 @@ g_hash_table_lookup_node (GHashTable *hash_table,
|
||||
|
||||
/* Hash table lookup needs to be fast.
|
||||
* We therefore remove the extra conditional of testing
|
||||
* whether to call the key_compare_func or not from
|
||||
* whether to call the key_equal_func or not from
|
||||
* the inner loop.
|
||||
*/
|
||||
if (hash_table->key_compare_func)
|
||||
while (*node && !(*hash_table->key_compare_func) ((*node)->key, key))
|
||||
if (hash_table->key_equal_func)
|
||||
while (*node && !(*hash_table->key_equal_func) ((*node)->key, key))
|
||||
node = &(*node)->next;
|
||||
else
|
||||
while (*node && (*node)->key != key)
|
||||
|
@ -40,7 +40,7 @@ typedef gboolean (*GHRFunc) (gpointer key,
|
||||
/* Hash tables
|
||||
*/
|
||||
GHashTable* g_hash_table_new (GHashFunc hash_func,
|
||||
GCompareFunc key_compare_func);
|
||||
GEqualFunc key_equal_func);
|
||||
void g_hash_table_destroy (GHashTable *hash_table);
|
||||
void g_hash_table_insert (GHashTable *hash_table,
|
||||
gpointer key,
|
||||
@ -72,7 +72,7 @@ gboolean g_str_equal (gconstpointer v,
|
||||
gconstpointer v2);
|
||||
guint g_str_hash (gconstpointer v);
|
||||
|
||||
gint g_int_equal (gconstpointer v,
|
||||
gboolean g_int_equal (gconstpointer v,
|
||||
gconstpointer v2) G_GNUC_CONST;
|
||||
guint g_int_hash (gconstpointer v) G_GNUC_CONST;
|
||||
|
||||
@ -83,7 +83,7 @@ guint g_int_hash (gconstpointer v) G_GNUC_CONST;
|
||||
* same effect as passing g_direct_hash().
|
||||
*/
|
||||
guint g_direct_hash (gconstpointer v) G_GNUC_CONST;
|
||||
gint g_direct_equal (gconstpointer v,
|
||||
gboolean g_direct_equal (gconstpointer v,
|
||||
gconstpointer v2) G_GNUC_CONST;
|
||||
|
||||
G_END_DECLS
|
||||
|
@ -85,7 +85,7 @@ tuple_hash (gint fields)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static GCompareFunc
|
||||
static GEqualFunc
|
||||
tuple_equal (gint fields)
|
||||
{
|
||||
switch (fields)
|
||||
@ -150,7 +150,7 @@ void
|
||||
g_relation_index (GRelation *relation,
|
||||
gint field,
|
||||
GHashFunc hash_func,
|
||||
GCompareFunc key_compare_func)
|
||||
GEqualFunc key_equal_func)
|
||||
{
|
||||
GRealRelation *rel = (GRealRelation *) relation;
|
||||
|
||||
@ -158,7 +158,7 @@ g_relation_index (GRelation *relation,
|
||||
|
||||
g_return_if_fail (rel->count == 0 && rel->hashed_tuple_tables[field] == NULL);
|
||||
|
||||
rel->hashed_tuple_tables[field] = g_hash_table_new (hash_func, key_compare_func);
|
||||
rel->hashed_tuple_tables[field] = g_hash_table_new (hash_func, key_equal_func);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -67,7 +67,7 @@ void g_relation_destroy (GRelation *relation);
|
||||
void g_relation_index (GRelation *relation,
|
||||
gint field,
|
||||
GHashFunc hash_func,
|
||||
GCompareFunc key_compare_func);
|
||||
GEqualFunc key_equal_func);
|
||||
void g_relation_insert (GRelation *relation,
|
||||
...);
|
||||
gint g_relation_delete (GRelation *relation,
|
||||
|
@ -127,7 +127,7 @@ static inline
|
||||
GScannerKey* g_scanner_lookup_internal (GScanner *scanner,
|
||||
guint scope_id,
|
||||
const gchar *symbol);
|
||||
static gint g_scanner_key_equal (gconstpointer v1,
|
||||
static gboolean g_scanner_key_equal (gconstpointer v1,
|
||||
gconstpointer v2);
|
||||
static guint g_scanner_key_hash (gconstpointer v);
|
||||
static void g_scanner_get_token_ll (GScanner *scanner,
|
||||
@ -346,7 +346,7 @@ g_scanner_warn (GScanner *scanner,
|
||||
}
|
||||
}
|
||||
|
||||
static gint
|
||||
static gboolean
|
||||
g_scanner_key_equal (gconstpointer v1,
|
||||
gconstpointer v2)
|
||||
{
|
||||
|
@ -69,6 +69,8 @@ typedef const void *gconstpointer;
|
||||
|
||||
typedef gint (*GCompareFunc) (gconstpointer a,
|
||||
gconstpointer b);
|
||||
typedef gboolean (*GEqualFunc) (gconstpointer a,
|
||||
gconstpointer b);
|
||||
typedef void (*GDestroyNotify) (gpointer data);
|
||||
typedef void (*GFunc) (gpointer data,
|
||||
gpointer user_data);
|
||||
|
@ -917,14 +917,14 @@ g_direct_hash (gconstpointer v)
|
||||
return GPOINTER_TO_UINT (v);
|
||||
}
|
||||
|
||||
gint
|
||||
gboolean
|
||||
g_direct_equal (gconstpointer v1,
|
||||
gconstpointer v2)
|
||||
{
|
||||
return v1 == v2;
|
||||
}
|
||||
|
||||
gint
|
||||
gboolean
|
||||
g_int_equal (gconstpointer v1,
|
||||
gconstpointer v2)
|
||||
{
|
||||
|
6
grel.c
6
grel.c
@ -85,7 +85,7 @@ tuple_hash (gint fields)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static GCompareFunc
|
||||
static GEqualFunc
|
||||
tuple_equal (gint fields)
|
||||
{
|
||||
switch (fields)
|
||||
@ -150,7 +150,7 @@ void
|
||||
g_relation_index (GRelation *relation,
|
||||
gint field,
|
||||
GHashFunc hash_func,
|
||||
GCompareFunc key_compare_func)
|
||||
GEqualFunc key_equal_func)
|
||||
{
|
||||
GRealRelation *rel = (GRealRelation *) relation;
|
||||
|
||||
@ -158,7 +158,7 @@ g_relation_index (GRelation *relation,
|
||||
|
||||
g_return_if_fail (rel->count == 0 && rel->hashed_tuple_tables[field] == NULL);
|
||||
|
||||
rel->hashed_tuple_tables[field] = g_hash_table_new (hash_func, key_compare_func);
|
||||
rel->hashed_tuple_tables[field] = g_hash_table_new (hash_func, key_equal_func);
|
||||
}
|
||||
|
||||
void
|
||||
|
2
grel.h
2
grel.h
@ -67,7 +67,7 @@ void g_relation_destroy (GRelation *relation);
|
||||
void g_relation_index (GRelation *relation,
|
||||
gint field,
|
||||
GHashFunc hash_func,
|
||||
GCompareFunc key_compare_func);
|
||||
GEqualFunc key_equal_func);
|
||||
void g_relation_insert (GRelation *relation,
|
||||
...);
|
||||
gint g_relation_delete (GRelation *relation,
|
||||
|
@ -127,7 +127,7 @@ static inline
|
||||
GScannerKey* g_scanner_lookup_internal (GScanner *scanner,
|
||||
guint scope_id,
|
||||
const gchar *symbol);
|
||||
static gint g_scanner_key_equal (gconstpointer v1,
|
||||
static gboolean g_scanner_key_equal (gconstpointer v1,
|
||||
gconstpointer v2);
|
||||
static guint g_scanner_key_hash (gconstpointer v);
|
||||
static void g_scanner_get_token_ll (GScanner *scanner,
|
||||
@ -346,7 +346,7 @@ g_scanner_warn (GScanner *scanner,
|
||||
}
|
||||
}
|
||||
|
||||
static gint
|
||||
static gboolean
|
||||
g_scanner_key_equal (gconstpointer v1,
|
||||
gconstpointer v2)
|
||||
{
|
||||
|
2
gtypes.h
2
gtypes.h
@ -69,6 +69,8 @@ typedef const void *gconstpointer;
|
||||
|
||||
typedef gint (*GCompareFunc) (gconstpointer a,
|
||||
gconstpointer b);
|
||||
typedef gboolean (*GEqualFunc) (gconstpointer a,
|
||||
gconstpointer b);
|
||||
typedef void (*GDestroyNotify) (gpointer data);
|
||||
typedef void (*GFunc) (gpointer data,
|
||||
gpointer user_data);
|
||||
|
4
gutils.c
4
gutils.c
@ -917,14 +917,14 @@ g_direct_hash (gconstpointer v)
|
||||
return GPOINTER_TO_UINT (v);
|
||||
}
|
||||
|
||||
gint
|
||||
gboolean
|
||||
g_direct_equal (gconstpointer v1,
|
||||
gconstpointer v2)
|
||||
{
|
||||
return v1 == v2;
|
||||
}
|
||||
|
||||
gint
|
||||
gboolean
|
||||
g_int_equal (gconstpointer v1,
|
||||
gconstpointer v2)
|
||||
{
|
||||
|
@ -238,8 +238,8 @@ my_hash (gconstpointer key)
|
||||
return (guint) *((const gint*) key);
|
||||
}
|
||||
|
||||
static gint
|
||||
my_hash_compare (gconstpointer a,
|
||||
static gboolean
|
||||
my_hash_equal (gconstpointer a,
|
||||
gconstpointer b)
|
||||
{
|
||||
return *((const gint*) a) == *((const gint*) b);
|
||||
@ -617,7 +617,7 @@ main (int argc,
|
||||
|
||||
g_print ("checking hash tables...");
|
||||
|
||||
hash_table = g_hash_table_new (my_hash, my_hash_compare);
|
||||
hash_table = g_hash_table_new (my_hash, my_hash_equal);
|
||||
for (i = 0; i < 10000; i++)
|
||||
{
|
||||
array[i] = i;
|
||||
|
@ -84,8 +84,8 @@ my_hash (gconstpointer key)
|
||||
return (guint) *((const gint*) key);
|
||||
}
|
||||
|
||||
static gint
|
||||
my_hash_compare (gconstpointer a,
|
||||
static gboolean
|
||||
my_hash_equal (gconstpointer a,
|
||||
gconstpointer b)
|
||||
{
|
||||
return *((const gint*) a) == *((const gint*) b);
|
||||
@ -160,11 +160,9 @@ static guint honeyman_hash(gconstpointer key)
|
||||
}
|
||||
|
||||
|
||||
static gint second_hash_cmp (gconstpointer a, gconstpointer b)
|
||||
static gboolean second_hash_cmp (gconstpointer a, gconstpointer b)
|
||||
{
|
||||
gint rc = (strcmp (a, b) == 0);
|
||||
|
||||
return rc;
|
||||
return (strcmp (a, b) == 0);
|
||||
}
|
||||
|
||||
|
||||
@ -336,7 +334,7 @@ main (int argc,
|
||||
GHashTable *hash_table;
|
||||
gint i;
|
||||
|
||||
hash_table = g_hash_table_new (my_hash, my_hash_compare);
|
||||
hash_table = g_hash_table_new (my_hash, my_hash_equal);
|
||||
for (i = 0; i < 10000; i++)
|
||||
{
|
||||
array[i] = i;
|
||||
|
@ -238,8 +238,8 @@ my_hash (gconstpointer key)
|
||||
return (guint) *((const gint*) key);
|
||||
}
|
||||
|
||||
static gint
|
||||
my_hash_compare (gconstpointer a,
|
||||
static gboolean
|
||||
my_hash_equal (gconstpointer a,
|
||||
gconstpointer b)
|
||||
{
|
||||
return *((const gint*) a) == *((const gint*) b);
|
||||
@ -617,7 +617,7 @@ main (int argc,
|
||||
|
||||
g_print ("checking hash tables...");
|
||||
|
||||
hash_table = g_hash_table_new (my_hash, my_hash_compare);
|
||||
hash_table = g_hash_table_new (my_hash, my_hash_equal);
|
||||
for (i = 0; i < 10000; i++)
|
||||
{
|
||||
array[i] = i;
|
||||
|
Loading…
x
Reference in New Issue
Block a user