core/containers/set: Return status of set_insert() and set_remove()
I use this status indicator in the playlist code fairly often, so let's return it directly rather than needing to code around it. Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
5a30a63904
commit
e8d7576704
|
@ -34,14 +34,14 @@ static inline void set_deinit(struct set *set)
|
|||
g_hash_table_destroy(set->s_set);
|
||||
}
|
||||
|
||||
static inline void set_insert(struct set *set, unsigned int value)
|
||||
static inline bool set_insert(struct set *set, unsigned int value)
|
||||
{
|
||||
g_hash_table_add(set->s_set, GUINT_TO_POINTER(value));
|
||||
return g_hash_table_add(set->s_set, GUINT_TO_POINTER(value));
|
||||
}
|
||||
|
||||
static inline void set_remove(struct set *set, unsigned int value)
|
||||
static inline bool set_remove(struct set *set, unsigned int value)
|
||||
{
|
||||
g_hash_table_remove(set->s_set, GUINT_TO_POINTER(value));
|
||||
return g_hash_table_remove(set->s_set, GUINT_TO_POINTER(value));
|
||||
}
|
||||
|
||||
static inline void set_clear(struct set *set)
|
||||
|
|
|
@ -14,8 +14,8 @@ void test_set()
|
|||
|
||||
/* Insert N items. */
|
||||
for (i = 0; i < N; i++) {
|
||||
set_insert(&set, i);
|
||||
set_insert(&set, i);
|
||||
test_loop_equal(set_insert(&set, i), (bool)true, i);
|
||||
test_loop_equal(set_insert(&set, i), (bool)false, i);
|
||||
test_loop_equal(set_size(&set), i + 1, i);
|
||||
test_loop_equal(set_has(&set, i), (bool)true, i);
|
||||
} test_loop_passed();
|
||||
|
@ -25,8 +25,8 @@ void test_set()
|
|||
|
||||
/* Remove even items. */
|
||||
for (i = 0; i < N; i += 2) {
|
||||
set_remove(&set, i);
|
||||
set_remove(&set, i);
|
||||
test_loop_equal(set_remove(&set, i), (bool)true, i);
|
||||
test_loop_equal(set_remove(&set, i), (bool)false, i);
|
||||
test_loop_equal(set_has(&set, i), (bool)false, i);
|
||||
} test_loop_passed();
|
||||
test_equal(set_size(&set), N / 2);
|
||||
|
|
Loading…
Reference in New Issue