Advice on appropriate datastructure
Hi everyone,
I've got a bunch of related tables I'm retreiving data from, and end result is I end up with a bunch of (key,value) pairs for an object. So one object might have:
total, 10
tax1, 2
and another object might have these values:
total, 20
tax1, 4
tax2, 3
In the end, I want to sum up all the common fields in my returned objects so I've got something like:
total, 30
tax1, 6
tax2, 3
And I want to display this final info in a form. The question is, what is the best datastructure to store everything in? I thought of a 2-dimensional array, but then I end up going through a lot of loops to add everything up later (checking key fields, adding up value fields if equal, etc). Then I thought maybe an extended hashtable class with the add() method overridden, but I'm not sure how to do that.
Any suggestions?