If I understand you correctly, you want to present a set of sets of numbers that, in my opinion, are not trivial.
The first point is the representation of a set of integers. The easiest way is to use a variable-sized array:
typedef struct { int size; int elems[1]; } intset;
than you can create a new set (with a fixed number of elements) with
intset *newset(int size) { intset *set; set = malloc(sizeof(intset) + sizeof(int)*(size-1)); if (set) set->size = size; return set; }
and save the elements with set->elems[0]=i1; ... set->elems[0]=i1; ...
Another option is to use bitmaps, but the implementation will depend on the nature of the integers to store (for example, are they within a fixed range? Do they usually appear in groups in a set?).
Once you have a set of integers, you will need a comparison function (to determine if two sets have the same elements). If you have selected an array to represent the set and you have saved this array, just check to see if the two sets are identical; if it is a bitmap, it will depend on how you implemented it.
Now, for a set of sets, you can select a (sorted) vector that you may need to change from time to time when inserting elements or a hash table. In the latter case, you need to write a hash function for your sets of integers (possibly using existing functions!).
As I said, this does not seem trivial to me, I am not surprised that Google did not help.
It is not very difficult, but you only need to make some decisions before proceeding.
Remo.D
source share