push_front
语法:
1 |
void push_front( const TYPE &val ); |
push_front()函数将val连接到链表的头部。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
源代码 /** * @brief Add data to the front of the %list. * @param x Data to be added. * * This is a typical stack operation. The function creates an * element at the front 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_front(const value_type& __x) { this->_M_insert(begin(), __x); } |
测试代码
测试结果
10
9 8 7 6 5 4 3 2 1 0