相关疑难解决方法(0)

std :: lower_bound对于std :: vector比std :: map :: find慢

我编写了一个类来充当顺序容器(std::vector/ std::queue/ std::list)的包装器std::map,以便在使用少量小对象时具有a的接口.鉴于已有的算法,编码非常简单.这段代码显然是从我的完整代码高度修剪,但显示问题.

template <class key_, 
          class mapped_, 
          class traits_ = std::less<key_>,
          class undertype_ = std::vector<std::pair<key_,mapped_> >
         >
class associative
{
public:
    typedef traits_ key_compare;
    typedef key_ key_type;
    typedef mapped_ mapped_type;
    typedef std::pair<const key_type, mapped_type> value_type;
    typedef typename undertype_::allocator_type allocator_type;
    typedef typename allocator_type::template rebind<value_type>::other value_allocator_type;
    typedef typename undertype_::const_iterator const_iterator;

    class value_compare {
        key_compare pred_;
    public:
        inline value_compare(key_compare pred=key_compare()) : pred_(pred) {}
        inline bool operator()(const value_type& left, const value_type& right) const {return pred_(left.first,right.first);} …
Run Code Online (Sandbox Code Playgroud)

c++ algorithm performance vector map

15
推荐指数
1
解决办法
4729
查看次数

标签 统计

algorithm ×1

c++ ×1

map ×1

performance ×1

vector ×1