c++ - 如何找到将元素插入到 std::map 中的位置而不实际插入它

标签 c++ dictionary std stdmap c++-standard-library

有没有一种方法可以轻松找到将元素插入到 std::map 中的迭代器,而无需实际插入元素?

最佳答案

你能做的最好的事情就是使用:

<强> std::map::upper_bound()
<强> std::map::lower_bound()
获取 key 大于或大于或等于特定 key 值的迭代器位置。

关于c++ - 如何找到将元素插入到 std::map 中的位置而不实际插入它,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9273129/

相关文章:

python - 删除项目后重命名字典键的更好方法?

javascript - 按键数组过滤 javascript map 对象

c++ - 使用 find_if() 函数

c++ - C++ 中的可移植标准语法原子操作库

c++ - 在 Eclipse C++ 中找不到 -l<库

c++ - boost asio 计时器 : run 2 timers

python - 将路径列表转换为python中的字典

c++ - std::sort 使用继承的仿函数

c++ - 将 list 嵌入到 exe 文件

c++ - OpenCV,均衡图像轮廓直方图