gpt4 book ai didi

c++ - 为什么没有 boost::intrusive::map?

转载 作者:太空狗 更新时间:2023-10-29 19:58:16 25 4
gpt4 key购买 nike

boost 文档 ( http://www.boost.org/doc/libs/1_55_0/doc/html/intrusive.html ) 指出侵入式容器是为 list 实现的(单链/双链),setmultiset .我找不到 map 的实现。是有更深层次的原因,还是只是等待实现?

最佳答案

这是因为 map<Key, Value>实际上是 set<std::pair<Key const, Value>> Boost.Intrusive 和 Boost.MultiIndex 集允许您使用值成员之一作为键。换句话说,不需要map。如果find可以接受一个可比较的键,而不是整个值来搜索 which has been a long-standing unresolved issue with std::map and std::set :

The associative container lookup functions (find, lower_bound, upper_bound, equal_range) only take an argument of key_type, requiring users to construct (either implicitly or explicitly) an object of the key_type to do the lookup. This may be expensive, e.g. constructing a large object to search in a set when the comparator function only looks at one field of the object. There is strong desire among users to be able to search using other types which are comparable with the key_type.

关于c++ - 为什么没有 boost::intrusive::map?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23633397/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com