STL list的insert push_front push_back成员函数实现
/*stl_list.h文件中*/
iterator insert(iterator position, const T& x) { link_type tmp = create_node(x); tmp->next = position.node; tmp->prev = position.node->prev; (link_type(position.node->prev))->next = tmp; position.node->prev = tmp; return tmp; }
void push_front(const T& x) { insert(begin(), x); } void push_back(const T& x) { insert(end(), x); }