开发者

C++ making Hash of Arrays

I have a problem 开发者_如何学Cwith the creation of a hash of arrays. I need a Single Key - Multi Data system:

multimap <Type, vector<type> > var;

But how I can add elements to the vector?

Example: key = 3;

Now I need to append some elements into the vector whose key is 3.

Creating a temp-vector not an answer because I don't know when I need to input element into the vector with the current key.

sorry, understand my problem. i need fast-access struct, that will be operate with ~50,000 words with length ~20 each. and i need something like tree. also, have question: how quick STL-structures, like vector,map,multimap and other?


What's wrong with std::map <KeyType, std::vector<SomeType> >, or some other collection as the value type? This gives you control over how to operate on the value collection. A multimap to me seems like a low-level form of std::map <KeyType, std::list<SomeType> >, but with none of the flexibility of a list.


To find the answer to your question you can look at the slides under point 6. at this site https://ece.uwaterloo.ca/~ece250/Lectures/Slides/

Hope that helps!

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜