I have a collection of objects. Each object is described by ~4 parameters (let’s say two integers and two strings). How can I implement this collection in C++ to be able to quickly find subsets of these objects by specifying search-criterias, i.e. “find all object with first parameter equal to 1”, or “search all objects with second parameter equal to ‘foo’ ” (lookup is always performed using one-parameter query: parameter=value). Should I have 4 std::maps, so that each parameter based lookup is performed in O(logn) ? What if I add another parameter and another?
Are there any existing solutions for this problem?
You should try Boost Multi Index, which is meant for just this kind of thing.