I have a function, it is called inside a loop, it can generate a set of integer for each loop, for example:
result for loop 1: {1 1 1 2}
result for loop 2: {1 1 1 3}
result for loop 3: {2 1 1 3}
result for loop 4: {3 1 3 2}
and this function may generate duplication result, for example, result 2 and result 3 is the same. I need to put these results inside a data structure, but can not put the duplication, if the result 2 is the same as result 3, only one of them should be kept, how to achieve it in C?
If the range of items is small enough, you can use bitmaps as a mean of enumeration. E.g. if you want to represent set of integers in range from 1 to 32, all that is required is a 32-bit integer used as a bitmap:
etc.
If the range is larger, use array of bytes, where each bit represents whether value at this position is present in set: