core/set: Add a function for clearing sets

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
Anna Schumaker 2015-11-07 12:34:45 -05:00
parent 09c87e14aa
commit 82a74dd5ec
2 changed files with 8 additions and 0 deletions

View File

@ -39,6 +39,11 @@ static inline void set_remove(struct set *set, unsigned int value)
g_hash_table_remove(set->s_set, GUINT_TO_POINTER(value));
}
static inline void set_clear(struct set *set)
{
g_hash_table_remove_all(set->s_set);
}
static inline bool set_has(const struct set *set, unsigned int value)
{
return g_hash_table_contains(set->s_set, GUINT_TO_POINTER(value));

View File

@ -37,6 +37,9 @@ void test_set()
i += 2;
} test_loop_passed();
set_clear(&set);
test_equal(set_size(&set), 0);
set_deinit(&set);
}