|  |  |  | telepathy-glib Reference Manual |  | 
|---|---|---|---|---|
#include <telepathy-glib/intset.h>
                    TpIntSet;
void                (*TpIntFunc)                        (guint i,
                                                         gpointer userdata);
TpIntSet*           tp_intset_sized_new                 (guint size);
TpIntSet*           tp_intset_new                       (void);
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;
gboolean            tp_intset_iter_next                 (TpIntSetIter *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() | 
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 : | TRUEifelementwas previously inset | 
gboolean tp_intset_is_member (const TpIntSet *set, guint element);
Tests if element is a member of set
| 
 | set | 
| 
 | integer to test | 
| Returns : | TRUEifelementis inset | 
void tp_intset_foreach (const TpIntSet *set, TpIntFunc func, gpointer userdata);
Call func(element, userdata) for each element of set.
| 
 | set | 
| 
 | TpIntFuncto 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 : | TRUEifleftandrightcontain 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 withtp_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 leftandright(analogous to the bitwise operation left & right), to be freed withtp_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 leftorright(analogous to the bitwise operation left | right), to be freed withtp_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 leftand not inright(analogous to the bitwise operation left & (~right)), to be freed withtp_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 leftorrightbut not both (analogous to the bitwise operation left ^ right), to be freed
withtp_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 setin 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:
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 aftertp_intset_iter_next()returnsFALSE. | 
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:
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 : | TRUEif (iter->element) has been advanced |