开发者

Looking for a stl multimap like container that allows looking for a key by value

I'm i开发者_如何转开发n need to lookup the key from a particular element. It doesn't have to be very fast, but it should be better that iterating through all values.

In particular, this is my problem space:

  1. multiple values per key
  2. very fast lookup by key
  3. insertion/deletion speed not important
  4. key lookup from value that does better than O(n)

Does anyone know a datastructure that's useful in this situation, or would it be better to just have a map and a multimap side by side?

Solved. I actually ended up requesting the user give the key too. From an oo standpoint a horrible solution, but from a performance standpoint way faster. Dince the method I need the lookup for has a value parameter, the user can store the key next to the value.


Try Boost.Multi-Index.


Boost.MultiIndex is what you need.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜