pop_front
语法:
1 |
void pop_front(); |
pop_front()函数删除链表的第一个元素。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
源代码 /** * @brief Removes first element. * * This is a typical stack operation. It shrinks the %list by * one. Due to the nature of a %list this operation can be done * in constant time, and only invalidates iterators/references to * the element being removed. * * Note that no data is returned, and if the first element's data * is needed, it should be retrieved before pop_front() is * called. */ void pop_front() { this->_M_erase(begin()); } |
测试代码
测试结果
9 8 7 6 5 4 3 2 1 0
9 8 7 6 5 4 3 2 1 0
0