summaryrefslogtreecommitdiff
path: root/sets.c
blob: b5745762d182958116c31f4cf4d19215306f324c (plain) (blame)
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
#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;
}