data structure design
Posted on 2007-08-06
This question is 1/2 design, 1/2 java.
Suppose i have some variables, like this:
stooge (MOE, LARRY, CURLY)
height (TALL, MEDIUM, SHORT)
hair (BALD, HIRSUTE)
wealth (POOR, AVERAGE, RICH)
This indicates, for example, that the variable stooge can be of value MOE, LARRY or CURLY
(doesn't matter what type of data it is, just any primitive)
I have many many data records which might look like this:
I would then write some code like so:
if (i1 / i2+ < 100)
stooge = MOE;
else if (i1 / i2 == 100)
stooge = LARRY
stooge = CURLY
if (b == true) && (f < 10.0)
height = tall
else (b == true && (f == 10.0)
height = medium
height = short
The point is that, with each record I can determine a value for each of stooge, height, hair and wealth.
I need to count the number of occurrences of each possible combinations, e.g. I need to count how many
(MOE, TALL, BALD, POOR) occurences there are.
What is the best way to create a data structure for this?