Most efficient way of erasing/deleting multiple std::vector elements while retaining original order?

前端 未结 7 1444
隐瞒了意图╮
隐瞒了意图╮ 2020-12-23 17:37


i have a std::vector and a second container holding iterators or indexes (no keys, i want constant access to the element) to this vector for del

7条回答
  •  暖寄归人
    2020-12-23 18:33

    Elements of what? Maybe I'm taking your post to seriously but if you have a vector of 1000 elements why not mark the ones that are not valid anymore and do away with erasing in the first place. Obviously I'm making an assumption here that your elements are not demanding a lot of memory.

    I only bring this up because you seem to be concerned with speed. If the suggestions already given don't do the trick maybe this idea is worth a thought! In essence speed things up by not doing the operation in the first place.

提交回复
热议问题