Reputation: 6773
I have such a map:
std::map<time_t, int>
There is one value (int) per day (time_t). Some days may have the same value and therefore may not be unique. I need to perform a calculation for each unique int value from this map.
What is the quickest (least CPU usage) way to retrieve them?
Upvotes: 5
Views: 3340
Reputation: 5494
Do you have memory constraints? If not, I would keep an std::set (or whichever hash_set is available in your environment) listing the unique integers.
If you absolutely cannot allocate more memory, maybe you should consider using a different data structure in the first place.
Upvotes: 3