summaryrefslogtreecommitdiff
path: root/sets.h
blob: 930314d79f4837cc50b2d8620bf600feda57d101 (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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*
 * Projet d'Algorithmique et Programmation
 * Alex AUVOLAT, Mendes OULAMARA
 * 2013-2014
 * 
 * Sujet : Algorithme de Bron-Kerbosch pour Maximum-Clique
 * (cf maxclique.pdf)
 * */

#ifndef SET
#define SET
#include <stdbool.h>

#ifdef BITSETS
struct set{
    int N;
    unsigned long long* tab;
};

typedef struct set set;
#endif

#ifdef LINKEDLISTS
struct set_elt {
    int value;
    struct set_elt *next;
};
typedef struct {
    struct set_elt *first, *last;
	int size;	// number of elements
} t_set_descriptor;

typedef t_set_descriptor *set;
#endif

#ifdef TREAPS
// TODO
typedef void* set;
#endif


set empty_set(int size);
set singleton(int size, int x);
set copy_set(const set s);
void delete_set(set a);

void set_union_ip(set a, const set b); 
void set_inter_ip(set a, const set b);
void set_diff_ip(set a, const set b);

set set_union(const set a, const set b);
set set_inter(const set a, const set b);
set set_diff(const set a, const set b);

bool is_set_empty(const set s);
bool set_mem(int x, const set s);

int elt_of_set(const set s);

set set_add(int x, const set s);
void set_add_ip(int x, set s);

set set_remove(int x, const set s);
void set_remove_ip(int x, set s);

#endif