I have a 'sorting' problem and I can't wrap my head around it to properly set up the logic.
The program I'm working on takes one file (binary format) and converts it to another. The input file has data in the following format: it's a 2d array. At the beginning of every row there is a flag that indicates which variables are present in this row and then the variable values.
ex: 3 variables: A, B AND C
111 1 2 3
011 2 3
I have code that allows the user to select which variables he'd like to view. So if the user says I want to see variable B only, I make a mask = 010, and then when I read in the flag I check if the bit is on in the mask as well, then I copy the variable somewhere and do other stuff to it. I also keep track of which variables the user selected in an array, so in this case it would have one element: B
Now, the problems arise when the user selects the same variable to be viewed twice. So the selected items array has two items, say: B B.
The mask is still made as 010, because that's the only variable to be copied. But I need to some how allow it to check again, if the variable is selected twice.
I'm not looking for code, just sujestions on how to straten out the logic.
Oh, I hope this makes sense.
Thanks for the input in advance.