unordered_multimap - 迭代 find() 的结果会产生具有不同值的元素
本文介绍了unordered_multimap - 迭代 find() 的结果会产生具有不同值的元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
C++ 中的多重映射似乎很奇怪,我想知道为什么
The multimap in C++ seems to work really odd, i would like to know why
这是输出:
为什么当我明确要求'a'时,输出仍然包含以b为键的任何内容?这是编译器还是 stl 错误?
why does the output still contain anything with b as the key when I am explicitly asking for 'a'? Is this a compiler or stl bug?
推荐答案
find
实现后,返回与 multimap 中的键匹配的第一个元素的迭代器(与任何其他 map 一样).您可能正在寻找 equal_range
:
find
, as implemented, returns an iterator for the first element which matches the key in the multimap (as with any other map). You're likely looking for equal_range
:
这篇关于unordered_multimap - 迭代 find() 的结果会产生具有不同值的元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!