本文整理汇总了C++中item_map_t::insert方法的典型用法代码示例。如果您正苦于以下问题:C++ item_map_t::insert方法的具体用法?C++ item_map_t::insert怎么用?C++ item_map_t::insert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类item_map_t
的用法示例。
在下文中一共展示了item_map_t::insert方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: remove
void item::remove() {
//Remove the entry in map that points to current tuple
item_map_t::iterator item_map_iter;
item_map_iter=item_map.find(make_tuple(i_id));
item_map.erase(item_map_iter);
//Move last tuple in vector in the place of the deleted tuple
//If current tuple is not the last tuple,
if(tuple_id != count - 1) {
//Move content of last tuple to fields in this tuple
item item_vect_last_iter;
item_vect_last_iter=item_vect.at(count - 1);
i_id = item_vect_last_iter.i_id;
i_im_id = item_vect_last_iter.i_im_id;
strcpy(i_name, item_vect_last_iter.i_name);
i_price = item_vect_last_iter.i_price;
strcpy(i_data, item_vect_last_iter.i_data);
//Remove the entry for the last tuple in map, and insert a new one with new tuple_id
item_map_t::iterator item_map_iter;
item_map_iter=item_map.find(make_tuple(i_id));
if(item_map_iter != item_map.end())
item_map.erase(item_map_iter);
item_map.insert(make_pair(make_tuple(i_id), tuple_id));;
//Call remove on the last entry of the vector
item_vect_last_iter.remove();
}
else { //if the tuple is the last tuple in the vector
count--;
item_vect.pop_back();
}
//item_vect.erase(tuple_id);
}
示例2: insert
void item::insert() {
tuple_id = count;
item_vect.push_back(*this);
item_map.insert(make_pair(make_tuple(i_id), count));
count++;
}