Looking at the code in omumap.h, the searches done in an OMUMap basically actually compare the key addresses (void*).
What's the point of sorting keys by their addresses, unless OMUMap is willing to represent some kind of unordered map?
If so, that means, unless you're able to cast a key into an int (or whatever fits a void*), you don't have an ordered map?
If so, that means there is no efficient way to search a key in an OMUMap, and you have to revert to sequentially browsing it with an iterator?
Did I just figure it out?
NOTICE: developerWorks Community will be offline May 29-30, 2015 while we upgrade to the latest version of IBM Connections. For more information, read our upgrade FAQ.
This topic has been locked.
1 reply Latest Post - 2012-10-02T08:22:24Z by BoudewijnDijkstra
Pinned topic OMUMap searches
Answered question This question has been answered.
Unanswered question This question has not been answered yet.
Updated on 2012-10-02T08:22:24Z at 2012-10-02T08:22:24Z by BoudewijnDijkstra
BoudewijnDijkstra 270001WHJF20 PostsACCEPTED ANSWER
Re: OMUMap searches2012-10-02T08:22:24Z in response to MaitreBart
- Sorting by address is the easiest way to sort without requiring the key type to have comparison functions. Also, it is not unordered; the ordering is predictable, controllable and stable.
- If you can't cast a key type to void*, you should use the key pointer type and you will still have an ordered map. If you want the keys to be in a specific order, then you should consider using a different container type.
- If you bothered to look at the code in detail, you would have seen that it uses binary search to find keys. If that is too inefficient for you, then use a hash map.