pop_back
语法:
1 |
void pop_back(); |
pop_back()函数删除链表的最后一个元素。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
源代码 /** * @brief Removes last 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 last element's data * is needed, it should be retrieved before pop_back() is called. */ void pop_back() { this->_M_erase(this->_M_impl._M_node._M_prev); } |
测试代码
测试结果
9 8 7 6 5 4 3 2 1 0
0 1 2 3 4 5 6 7 8 9
0