summaryrefslogtreecommitdiff
path: root/telepathy-glib/intset.h
blob: 30fd3016515bf90892b2ec2eaa0678a71141c775 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
/* tp-intset.h - Headers for a Glib-link set of integers
 *
 * Copyright © 2005-2010 Collabora Ltd. <http://www.collabora.co.uk/>
 * Copyright © 2005-2006 Nokia Corporation
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License
 * as published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA
 *
 */

#ifndef __TP_INTSET_H__
#define __TP_INTSET_H__

#include <glib-object.h>

G_BEGIN_DECLS

#define TP_TYPE_INTSET (tp_intset_get_type ())
GType tp_intset_get_type (void);

typedef struct _TpIntset TpIntset;

/* See fdo#30134 for the reasoning behind the rename of TpIntSet to TpIntset */

/**
 * TpIntSet: (skip)
 *
 * Before 0.11.UNRELEASED, this was the name for <type>TpIntset</type>, but it's
 * now just a backwards compatibility typedef.
 */
typedef TpIntset TpIntSet;

typedef void (*TpIntFunc) (guint i, gpointer userdata);

TpIntset *tp_intset_new (void) G_GNUC_WARN_UNUSED_RESULT;
TpIntset *tp_intset_sized_new (guint size) G_GNUC_WARN_UNUSED_RESULT;
TpIntset *tp_intset_new_containing (guint element) G_GNUC_WARN_UNUSED_RESULT;
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)
  G_GNUC_WARN_UNUSED_RESULT;

void tp_intset_foreach (const TpIntset *set, TpIntFunc func,
    gpointer userdata);
GArray *tp_intset_to_array (const TpIntset *set) G_GNUC_WARN_UNUSED_RESULT;
TpIntset *tp_intset_from_array (const GArray *array) G_GNUC_WARN_UNUSED_RESULT;

gboolean tp_intset_is_empty (const TpIntset *set) G_GNUC_WARN_UNUSED_RESULT;
guint tp_intset_size (const TpIntset *set) G_GNUC_WARN_UNUSED_RESULT;

gboolean tp_intset_is_equal (const TpIntset *left, const TpIntset *right)
  G_GNUC_WARN_UNUSED_RESULT;

TpIntset *tp_intset_copy (const TpIntset *orig) G_GNUC_WARN_UNUSED_RESULT;
TpIntset *tp_intset_intersection (const TpIntset *left, const TpIntset *right)
  G_GNUC_WARN_UNUSED_RESULT;
TpIntset *tp_intset_union (const TpIntset *left, const TpIntset *right)
  G_GNUC_WARN_UNUSED_RESULT;
TpIntset *tp_intset_difference (const TpIntset *left, const TpIntset *right)
  G_GNUC_WARN_UNUSED_RESULT;
TpIntset *tp_intset_symmetric_difference (const TpIntset *left,
    const TpIntset *right) G_GNUC_WARN_UNUSED_RESULT;

gchar *tp_intset_dump (const TpIntset *set) G_GNUC_WARN_UNUSED_RESULT;

typedef struct {
    const TpIntset *set;
    guint element;
} TpIntsetIter;

/**
 * TpIntSetIter: (skip)
 *
 * Before 0.11.UNRELEASED, this was the name for <type>TpIntsetIter</type>, but
 * it's now just a backwards compatibility typedef.
 */
typedef TpIntsetIter TpIntSetIter;

#define TP_INTSET_ITER_INIT(set) { (set), (guint)(-1) }

#define tp_intset_iter_init(iter, set) tp_intset_iter_init_inline (iter, set)
static inline void
tp_intset_iter_init_inline (TpIntsetIter *iter, const TpIntset *set)
{
  g_return_if_fail (iter != NULL);
  iter->set = set;
  iter->element = (guint)(-1);
}

#define tp_intset_iter_reset(iter) tp_intset_iter_reset_inline (iter)
static inline void
tp_intset_iter_reset_inline (TpIntsetIter *iter)
{
  g_return_if_fail (iter != NULL);
  g_return_if_fail (iter->set != NULL);
  iter->element = (guint)(-1);
}

gboolean tp_intset_iter_next (TpIntsetIter *iter);

typedef struct {
    /*<private>*/
    gpointer _dummy[16];
} TpIntsetFastIter;

/**
 * TpIntSetFastIter: (skip)
 *
 * Before 0.11.UNRELEASED, this was the name for <type>TpIntsetFastIter</type>,
 * but it's now just a backwards compatibility typedef.
 */
typedef TpIntsetFastIter TpIntSetFastIter;

void tp_intset_fast_iter_init (TpIntsetFastIter *iter,
    const TpIntset *set);

gboolean tp_intset_fast_iter_next (TpIntsetFastIter *iter,
    guint *output);

G_END_DECLS

#endif /*__TP_INTSET_H__*/