push_back
语法:
1 |
void push_back( const TYPE &val ); |
push_back()将val连接到链表的最后。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
源代码 /** * @brief Add data to the end of the %list. * @param x Data to be added. * * This is a typical stack operation. The function creates an * element at the end of the %list and assigns the given data to * it. Due to the nature of a %list this operation can be done * in constant time, and does not invalidate iterators and * references. */ void push_back(const value_type& __x) { this->_M_insert(end(), __x); } |
测试代码
测试结果
10
0 1 2 3 4 5 6 7 8 9