对vector和map容器的删除元素操作_javca

 

/**
* 删除头部元素
* 切割map到指定的个数
* @param map
* @param i
* @return
*/
map PublicCardFrameDetection::cutmap(map map, int i) {
int map_num = map.size();
if (map_num > i){
auto iter = map.begin();
map.erase(iter);
return cutmap (map,i);
} else if (map_num == i){
return map;
}
}


/**
* 弹出尾部元素
* 切割列表为指定元素
* @param mats
* @param i
* @return
*/
vector PublicCardFrameDetection::splitList(vector mats, int i) {
int list_num = mats.size();
if (list_num > i){
mats.pop_back();
return splitList(mats,i);
} else if (list_num == i) {
return mats;
}
}

 

Talk is cheap. Show me the code