summaryrefslogtreecommitdiff
path: root/glib/gbsearcharray.h
diff options
context:
space:
mode:
authorTim Janik <timj@gtk.org>2001-03-18 04:44:38 +0000
committerTim Janik <timj@src.gnome.org>2001-03-18 04:44:38 +0000
commit45fb71949a0c0e27fe8d0948b345334f61a5c924 (patch)
tree1044cb22a18c41a892fc7a1d31362d59c0f0ad82 /glib/gbsearcharray.h
parent1d5b01bb5286277859d354a46c99fcee0a56113a (diff)
downloadglib-45fb71949a0c0e27fe8d0948b345334f61a5c924.tar.gz
removed archaic gpointer derived_data; relict and added a GData member
Wed Mar 14 18:46:54 2001 Tim Janik <timj@gtk.org> * gscanner.[hc]: removed archaic gpointer derived_data; relict and added a GData member instead. * glist.[hc]: added g_list_remove_all(). * gslist.[hc]: added g_slist_remove_all(). Sat Mar 17 23:18:36 2001 Tim Janik <timj@gtk.org> * gobject.c (g_object_get_property): minor bug-fix. * gbsearcharray.[hc]: provide a macro for static initialization and functions g_bsearch_array_new() and g_bsearch_array_destroy() for dynamic allocations. * gboxed.c: introduce G_TYPE_GSTRING, boxed type for GString. * gclosure.[hc]: naming corrections. Fri Mar 9 16:42:08 2001 Tim Janik <timj@gtk.org> * gvaluetypes.[hc]: moved g_strdup_value_contents() into this file as a public function (was static in gobject.c before). it's a bit odd to have that function here, especially since it requires extra includes, but then it doesn't very well fit somewhere else either. * gparamspecs.c: added default/max/min checks to param spec creation functions.
Diffstat (limited to 'glib/gbsearcharray.h')
-rw-r--r--glib/gbsearcharray.h23
1 files changed, 16 insertions, 7 deletions
diff --git a/glib/gbsearcharray.h b/glib/gbsearcharray.h
index dc23ffd20..e4b9201e9 100644
--- a/glib/gbsearcharray.h
+++ b/glib/gbsearcharray.h
@@ -35,23 +35,27 @@ typedef gint (*GBSearchCompareFunc) (gconstpointer bsearch_node1,
gconstpointer bsearch_node2);
typedef enum
{
- G_BSEARCH_ALIGN_POWER2 = 1 << 0,
- G_BSEARCH_DEFER_SHRINK = 1 << 1
-} GBSearchFlags;
+ G_BSEARCH_ARRAY_ALIGN_POWER2 = 1 << 0,
+ G_BSEARCH_ARRAY_DEFER_SHRINK = 1 << 1
+} GBSearchArrayFlags;
/* --- structures --- */
struct _GBSearchArray
{
- GBSearchCompareFunc cmp_func;
- guint16 sizeof_node;
+ GBSearchCompareFunc cmp_nodes;
guint16 flags;
+ guint16 sizeof_node;
guint n_nodes;
gpointer nodes;
};
/* --- prototypes --- */
+GBSearchArray* g_bsearch_array_new (guint16 sizeof_node,
+ GBSearchCompareFunc node_cmp_func,
+ GBSearchArrayFlags flags);
+void g_bsearch_array_destroy (GBSearchArray *barray);
gpointer g_bsearch_array_insert (GBSearchArray *barray,
gconstpointer key_node,
gboolean replace_existing);
@@ -70,6 +74,11 @@ guint g_bsearch_array_get_index (GBSearchArray *barray,
gpointer node_in_array);
+/* initialization of static arrays */
+#define G_STATIC_BSEARCH_ARRAY_INIT(sizeof_node, cmp_nodes, flags) \
+ { (cmp_nodes), (flags), (sizeof_node), 0, NULL }
+
+
/* --- implementation details --- */
#if defined (G_CAN_INLINE) || defined (__G_BSEARCHARRAY_C__)
G_INLINE_FUNC gpointer
@@ -78,7 +87,7 @@ g_bsearch_array_lookup (GBSearchArray *barray,
{
if (barray->n_nodes > 0)
{
- GBSearchCompareFunc cmp_func = barray->cmp_func;
+ GBSearchCompareFunc cmp_nodes = barray->cmp_nodes;
gint sizeof_node = barray->sizeof_node;
guint n_nodes = barray->n_nodes;
guint8 *nodes = (guint8 *) barray->nodes;
@@ -92,7 +101,7 @@ g_bsearch_array_lookup (GBSearchArray *barray,
i = (n_nodes + 1) >> 1;
check = nodes + i * sizeof_node;
- cmp = cmp_func (key_node, check);
+ cmp = cmp_nodes (key_node, check);
if (cmp == 0)
return check;
else if (cmp > 0)