- Where Developers Learn, Share, & Build Careers
I have a function, it is said inside a loop, it generates a set of integers for each loop For example: Results for Loop: 1: And this Function can generate duplication results, for example, result 2 and result 3 are identical. I should put these results inside a data structure, but can not be repetitive, if the result 2 is the same result 3, then one of them should be kept, how to get it If the limit of items is quite low, then you can use a bitmap as a mean of calculation As if you want to represent the set of integer in the range of 1 to 32, then all the 32-bit integers used as a bitmap are required: etc. If the range is large, then use the array of bytes, where each bit indicates that the value in this condition is present in the set: {1 2}
Result for loop 2: {1 1 1}
Results for loop 3: {2 1 1 3} Results for loop 4:
{3 1 3 2}
C ?
00000001 00000001 00000000 00000000 - set {8, 16} ^ 8 16
# MAXVAL 1024 Typedf Unsigned four bitmap_t []; Byte bitmap [1 + MAXVAL / CHAR_BIT] = {0}; // CHAR_BIT is defined in the range H. and a byte is equal to the calculation of bits in zero dot (bitmap_t bitmap, unsigned volts) (value) (value
Comments
Post a Comment