forked from AuroraMiddleware/gtk
set: Add a few useful functions
Allow to find out if a set is empty, and its min and max.
This commit is contained in:
parent
4fb50c7408
commit
06c34ce02f
32
gtk/gtkset.c
32
gtk/gtkset.c
@ -335,6 +335,38 @@ next_range:
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gtk_set_is_empty (GtkSet *set)
|
||||
{
|
||||
return set->ranges->len == 0;
|
||||
}
|
||||
|
||||
guint
|
||||
gtk_set_get_min (GtkSet *set)
|
||||
{
|
||||
Range *r;
|
||||
|
||||
if (gtk_set_is_empty (set))
|
||||
return 0;
|
||||
|
||||
r = &g_array_index (set->ranges, Range, 0);
|
||||
|
||||
return r->first;
|
||||
}
|
||||
|
||||
guint
|
||||
gtk_set_get_max (GtkSet *set)
|
||||
{
|
||||
Range *r;
|
||||
|
||||
if (gtk_set_is_empty (set))
|
||||
return 0;
|
||||
|
||||
r = &g_array_index (set->ranges, Range, set->ranges->len - 1);
|
||||
|
||||
return r->first + r->n_items;
|
||||
}
|
||||
|
||||
#if 0
|
||||
void
|
||||
gtk_set_dump (GtkSet *set)
|
||||
|
@ -67,4 +67,8 @@ void gtk_set_iter_init (GtkSetIter *iter,
|
||||
gboolean gtk_set_iter_next (GtkSetIter *iter,
|
||||
guint *item);
|
||||
|
||||
gboolean gtk_set_is_empty (GtkSet *set);
|
||||
guint gtk_set_get_min (GtkSet *set);
|
||||
guint gtk_set_get_max (GtkSet *set);
|
||||
|
||||
#endif /* __GTK_SET_H__ */
|
||||
|
Loading…
Reference in New Issue
Block a user