C++0x issue: Constant time insertion into std::set

后端 未结 4 1427
生来不讨喜
生来不讨喜 2021-02-20 04:21

According to this page, I can achieve constant time insertion if I use

iterator std::set::insert ( iterator position, const value_type& x );
<
4条回答
  •  逝去的感伤
    2021-02-20 05:02

    It is not totally clear if the position should be pointing before or after the insertion point. Some implementations work with either.

    On the other hand, if you want different behavior for different containers, why don't you just write two overloads for your function, one for containers with a push_back function and one for std::set.

提交回复
热议问题