diff options
Diffstat (limited to 'sets.c')
-rw-r--r-- | sets.c | 41 |
1 files changed, 41 insertions, 0 deletions
@@ -0,0 +1,41 @@ +#include "sets.h" + +/* + GENERIC FUNCTION FOR ALL KIND OF SETS +*/ + +set singleton(int n, int x) { + set k = empty_set(n); + set_add_ip(x, k); + return k; +} + +set set_union(const set a, const set b) { + set q = copy_set(a); + set_union_ip(q, b); + return q; +} + +set set_inter(const set a, const set b) { + set q = copy_set(a); + set_inter_ip(q, b); + return q; +} + +set set_diff(const set a, const set b) { + set q = copy_set(a); + set_diff_ip(q, b); + return q; +} + +set set_add(int x, const set s) { + set q = copy_set(s); + set_add_ip(x, q); + return q; +} + +set set_remove(int x, const set s) { + set q = copy_set(s); + set_remove_ip(x, q); + return q; +} |