I have a data structure that contains several different types of data like so:
1 2 3 4 5 6 7 8 9
|
struct Tool
{
const int toolID;
const QString toolName;
const QString categoryName;
int outcomeID;
}
typedef boost::shared_ptr<Tool> ToolPtr;
|
I'm struggling to decide what container to use for the job.
I originally settled on std::vector, following this guide at the bottom of the page
http://linuxsoftware.co.nz/cppcontainers.html
because my data set is small (no more than 40 Tools), and because no tools will be removed or added.
Through many points of the application the tools need to be accessed by different means, and I find myself written way too many loops and using std::find/lower_bound/upper_bound all over the place.
The tools are retrieved from a database at program startup.
About 50% of the time they need to be grouped together by outcomeID and shown in a table.
About 25% of the time they are grouped by categoryName in a tree structure,
where the category will contain only the tools with that categoryName AND as long as they have a particular outcome Id.
As the program grows I'm seeing that I also need to access get the tools by the toolID frequently as well.
I'm trying to figure out what container is best for all of these cases, or if perhaps I should re-arrange the data structure.