
#include "set.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>


int main()
{
	while(1) {

	set_t* set_u = set_new();
	set_t* set_i = set_new();
	set_t* set_d = set_new();
	set_t* set_a = set_new();
	set_t* set_b = set_new();
	void* elm;

   // set_a={A,B,C} 
	set_add(set_a, "A");
	set_add(set_a, "B");
	set_add(set_a, "C");

   // set_b={C,D,E}
	set_add(set_b, "C");
	set_add(set_b, "D");
	set_add(set_b, "E");

	// Union entre A y B
	set_union(set_u, set_a, set_b);
	
	// Interseccion entre A y B
	set_intersection(set_i, set_a, set_b);

	// Diferencia entre A y B
	set_difference(set_d, set_a, set_b);

	// Resultados
	printf ("\nA = {");
	list_begin(set_a); while((elm=list_next(set_a))) printf("%s, ", (char*)elm);
	printf ("\b\b}\n");

	printf ("B = {");
	list_begin(set_b); while((elm=list_next(set_b))) printf("%s, ", (char*)elm);
	printf ("\b\b}\n\n");

	printf ("A union B = {");
	list_begin(set_u); while((elm=list_next(set_u))) printf("%s, ", (char*)elm);
	printf ("\b\b}\n");

	printf ("A intersection B = {");
	list_begin(set_i); while((elm=list_next(set_i))) printf("%s, ", (char*)elm);
	printf ("\b\b}\n");

	printf ("A difference B = {");
	list_begin(set_d); while((elm=list_next(set_d))) printf("%s, ", (char*)elm);
	printf ("\b\b}\n\n");


	set_free(set_u, NULL); 
	set_free(set_i, NULL); 
	set_free(set_d, NULL); 
	set_free(set_a, NULL); 
	set_free(set_b, NULL); 
	
	}
	return 0;
}


