I have my unordered_map set up as:
unordered_map<int, deque<my_struct>> table;
When I read values to my program, I usually do:
table[int].push_back(obj);
What I want to be able to do is if I'm given 2 integer variables, I want to be able to find the number of keys that occur between the two.
So if in my table I have code like
table[49].push_back(obj);
table[59].push_back(obj);
table[60].push_back(obj);
If I execute my search function(which I'm currently trying to write) to look between the key values of 45 and 65, I should have 3 results.
I'm not exactly sure how to go about it in an efficient manner. Any ideas would be helpful. Than you.
unordered_map-- the notion of "things between" is inherently nonsense (it implies there's an order we can use to count between other things!). Any value you obtain may vary between compilers, and can change as you insert items into theunordered_map. If you use amapit's at least a sensible question.