F
fgh.vbn.rty
Here's the problem. Say I have:
vector<int> vint;
enum {R=0, O, Y, G, B, I, V} colors;
I know that vint always has <= 10000 elements in the range [0, 9999]
with no repetitions.
I want to create an object called ColoredInt taking one element from
vint and one element from colors. There can be multiple "Red integers"
but the same integer cannot have multiple colors.
Next I want to create a collection of ColoredInts (say "Bundle") that
can be something like vector<ColoredInt> or map or something like
that.
And finally I have a collection of Bundle objects say vector<Bundle>
Bundles.
The input to my program is a Bundle. I need to check if any of the
Bundles is equivalent to the incoming Bundle. If it is then I do
nothing and if it's not then I update my collection of Bundles.
What's the best way to represent ColoredInt? Right now I am using
ColoredInt as a string representing the num/color combo as "123_R" for
instance. And I'm using set<string> for Bundle (to keep the sorted
order during equivalence checking) but it seems very inefficient.
Is there a more efficient representation for this type of data?
vector<int> vint;
enum {R=0, O, Y, G, B, I, V} colors;
I know that vint always has <= 10000 elements in the range [0, 9999]
with no repetitions.
I want to create an object called ColoredInt taking one element from
vint and one element from colors. There can be multiple "Red integers"
but the same integer cannot have multiple colors.
Next I want to create a collection of ColoredInts (say "Bundle") that
can be something like vector<ColoredInt> or map or something like
that.
And finally I have a collection of Bundle objects say vector<Bundle>
Bundles.
The input to my program is a Bundle. I need to check if any of the
Bundles is equivalent to the incoming Bundle. If it is then I do
nothing and if it's not then I update my collection of Bundles.
What's the best way to represent ColoredInt? Right now I am using
ColoredInt as a string representing the num/color combo as "123_R" for
instance. And I'm using set<string> for Bundle (to keep the sorted
order during equivalence checking) but it seems very inefficient.
Is there a more efficient representation for this type of data?