Vector.erase(Iterator) causes bad memory access

前端 未结 4 640
借酒劲吻你
借酒劲吻你 2020-12-03 19:49

I am trying to do a Z-Index reordering of videoObjects stored in a vector. The plan is to identify the videoObject which is going to b

4条回答
  •  没有蜡笔的小新
    2020-12-03 20:03

    Beware, erasing elements one by one from a vector has quadratic complexity. STL to the rescue!

    #include 
    #include 
    
    videoObjects.erase(
        std::remove_if(
            std::bind2nd(
                std::mem_fun_ref(&videoObject::isInside),
                ofPoint(tcur.getX(), tcur.getY())
            ),
        ),
        videoObjects.end()
    );
    

提交回复
热议问题