summaryrefslogtreecommitdiff
path: root/sets.c
diff options
context:
space:
mode:
Diffstat (limited to 'sets.c')
-rw-r--r--sets.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/sets.c b/sets.c
new file mode 100644
index 0000000..b574576
--- /dev/null
+++ b/sets.c
@@ -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;
+}