我在创建数组哈希时遇到问题。我需要一个单键多数据系统:
multimap <Type, vector<type> > var;
但是如何向向量添加元素?
示例: key = 3;
现在我需要将一些元素附加到键为 3 的向量中。
创建临时向量不是答案,因为我不知道何时需要将元素输入到向量与当前键。
抱歉,理解我的问题。我需要快速访问结构,它将使用大约 50,000 个单词进行操作,每个单词长度大约为 20。
我需要像树这样的东西。
另外,有个问题:
STL 结构(如矢量、贴图、多重贴图等)有多快?
I have a problem with 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?
发布评论
评论(2)
std::map 有什么问题吗? >
,或其他集合作为值类型?这使您可以控制如何操作值集合。对我来说,多重映射似乎是 std::mapWhat'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 ofstd::map <KeyType, std::list<SomeType> >
, but with none of the flexibility of a list.要找到问题的答案,您可以查看本网站第 6 点下的幻灯片 https ://ece.uwaterloo.ca/~ece250/Lectures/Slides/
希望有帮助!
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!