Delete the specified element in the vector

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/jacken123456/article/details/102694736

Delete the specified element in the vector, we generally remove elements using an iterator to traverse response;

Delete elements in the vector using the erase () function, be sure to note the point is that, after deleting the vector has been changed, subsequent related operations must take into account the impact caused by the deletion.

To delete an element, you should do:

zl::material_InventoryVec& MainWnd::removeLockBox(zl::material_InventoryVec& vec)
{
    int count = vec.size();
    for(int i = 0; i < count; ++i)
    {
        int32_t status;
        zl::CCabinetManager::Instance()->GetLockerStatus(vec[0].box_no,status);
        if((status>>5) & 0x01 == 0x01)
        {
            vec.erase(vec.begin());
        }
    }
    return vec;
}

 

Guess you like

Origin blog.csdn.net/jacken123456/article/details/102694736