telepathy-glib Reference Manual | ||||
---|---|---|---|---|
Top | Description |
#include <telepathy-glib/intset.h> TpIntSet; void (*TpIntFunc) (guint i
,gpointer userdata
); TpIntSet * tp_intset_sized_new (guint size
); TpIntSet * tp_intset_new (void
); TpIntSet * tp_intset_new_containing (guint element
); void tp_intset_destroy (TpIntSet *set
); void tp_intset_clear (TpIntSet *set
); void tp_intset_add (TpIntSet *set
,guint element
); gboolean tp_intset_remove (TpIntSet *set
,guint element
); gboolean tp_intset_is_member (const TpIntSet *set
,guint element
); void tp_intset_foreach (const TpIntSet *set
,TpIntFunc func
,gpointer userdata
); GArray * tp_intset_to_array (const TpIntSet *set
); TpIntSet * tp_intset_from_array (const GArray *array
); guint tp_intset_size (const TpIntSet *set
); gboolean tp_intset_is_equal (const TpIntSet *left
,const TpIntSet *right
); TpIntSet * tp_intset_copy (const TpIntSet *orig
); TpIntSet * tp_intset_intersection (const TpIntSet *left
,const TpIntSet *right
); TpIntSet * tp_intset_union (const TpIntSet *left
,const TpIntSet *right
); TpIntSet * tp_intset_difference (const TpIntSet *left
,const TpIntSet *right
); TpIntSet * tp_intset_symmetric_difference (const TpIntSet *left
,const TpIntSet *right
); gchar * tp_intset_dump (const TpIntSet *set
); #define TP_INTSET_ITER_INIT (set) TpIntSetIter; #define tp_intset_iter_init (iter, set) gboolean tp_intset_iter_next (TpIntSetIter *iter
); #define tp_intset_iter_reset (iter)
A TpIntSet is a set of unsigned integers, implemented as a dynamically-allocated bitfield.
void (*TpIntFunc) (guint i
,gpointer userdata
);
A callback function acting on unsigned integers.
|
The relevant integer |
|
Opaque user data |
TpIntSet * tp_intset_sized_new (guint size
);
Allocate an integer set just large enough to store the given number of bits, rounded up as necessary.
The set will still expand automatically if you store larger integers; this is just an optimization to avoid wasting memory (if the set is too large) or time (if the set is too small and needs reallocation).
|
1 more than the largest integer you expect to store |
Returns : |
a new, empty integer set to be destroyed with tp_intset_destroy()
|
TpIntSet * tp_intset_new (void
);
Allocate a new integer set with a default memory allocation.
Returns : |
a new, empty integer set to be destroyed with tp_intset_destroy()
|
TpIntSet * tp_intset_new_containing (guint element
);
Allocate a new integer set containing the given integer.
|
integer to add to a new set |
Returns : |
a new integer set containing element , to be destroyed with
tp_intset_destroy()
since 0.7.26
|
void tp_intset_destroy (TpIntSet *set
);
Free all memory used by the set.
|
set |
void tp_intset_add (TpIntSet *set
,guint element
);
Add an integer into a TpIntSet.
|
set |
|
integer to add |
gboolean tp_intset_remove (TpIntSet *set
,guint element
);
Remove an integer from a TpIntSet
|
set |
|
integer to add |
Returns : |
TRUE if element was previously in set
|
gboolean tp_intset_is_member (const TpIntSet *set
,guint element
);
Tests if element
is a member of set
|
set |
|
integer to test |
Returns : |
TRUE if element is in set
|
void tp_intset_foreach (const TpIntSet *set
,TpIntFunc func
,gpointer userdata
);
Call func
(element, userdata
) for each element of set
.
|
set |
|
TpIntFunc to use to iterate the set
|
|
user data to pass to each call of func
|
GArray * tp_intset_to_array (const TpIntSet *set
);
|
set to convert |
Returns : |
a GArray of guint (which must be freed by the caller) containing
the same integers as set .
|
TpIntSet * tp_intset_from_array (const GArray *array
);
|
An array of guint |
Returns : |
A set containing the same integers as array .
|
guint tp_intset_size (const TpIntSet *set
);
|
A set of integers |
Returns : |
The number of integers in set
|
gboolean tp_intset_is_equal (const TpIntSet *left
,const TpIntSet *right
);
|
A set of integers |
|
A set of integers |
Returns : |
TRUE if left and right contain the same bits
|
TpIntSet * tp_intset_copy (const TpIntSet *orig
);
|
A set of integers |
Returns : |
A set containing the same integers as orig , to be freed with
tp_intset_destroy() by the caller
|
TpIntSet * tp_intset_intersection (const TpIntSet *left
,const TpIntSet *right
);
|
The left operand |
|
The right operand |
Returns : |
The set of those integers which are in both left and right
(analogous to the bitwise operation left & right), to be freed with
tp_intset_destroy() by the caller
|
TpIntSet * tp_intset_union (const TpIntSet *left
,const TpIntSet *right
);
|
The left operand |
|
The right operand |
Returns : |
The set of those integers which are in either left or right
(analogous to the bitwise operation left | right), to be freed with
tp_intset_destroy() by the caller
|
TpIntSet * tp_intset_difference (const TpIntSet *left
,const TpIntSet *right
);
|
The left operand |
|
The right operand |
Returns : |
The set of those integers which are in left and not in right
(analogous to the bitwise operation left & (~right)), to be freed with
tp_intset_destroy() by the caller
|
TpIntSet * tp_intset_symmetric_difference (const TpIntSet *left
,const TpIntSet *right
);
|
The left operand |
|
The right operand |
Returns : |
The set of those integers which are in either left or right
but not both (analogous to the bitwise operation left ^ right), to be freed
with tp_intset_destroy() by the caller
|
gchar * tp_intset_dump (const TpIntSet *set
);
|
An integer set |
Returns : |
a string which the caller must free with g_free, listing the
numbers in set in a human-readable format
|
#define TP_INTSET_ITER_INIT(set) { (set), (guint)(-1) }
A suitable static initializer for a TpIntSetIter, to be used as follows:
1 2 3 4 5 6 |
void do_something (const TpIntSet *intset) { TpIntSetIter iter = TP_INTSET_ITER_INIT (intset); /* ... do something with iter ... */ } |
|
A set of integers |
typedef struct { const TpIntSet *set; guint element; } TpIntSetIter;
A structure representing iteration over a set of integers. Must be
initialized with either TP_INTSET_ITER_INIT()
or tp_intset_iter_init()
.
const TpIntSet * |
The set iterated over. |
guint |
Must be (guint)(-1) before iteration starts. Set to the next
element in the set by tp_intset_iter_next() ; undefined after
tp_intset_iter_next() returns FALSE .
|
#define tp_intset_iter_init(iter, set) tp_intset_iter_init_inline (iter, set)
Reset the iterator iter
to the beginning and make it iterate over set
.
|
An integer set iterator to be initialized. |
|
An integer set to be used by that iterator |
gboolean tp_intset_iter_next (TpIntSetIter *iter
);
If there are integers in (iter->set
) higher than (iter->element
), set
(iter->element) to the next one and return TRUE
. Otherwise return FALSE
.
Usage:
1 2 3 4 5 |
TpIntSetIter iter = TP_INTSET_INIT (intset); while (tp_intset_iter_next (&iter)) { printf ("%u is in the intset\n", iter.element); } |
|
An iterator originally initialized with TP_INTSET_INIT(set) |
Returns : |
TRUE if (iter->element ) has been advanced
|