0001 template <typename T> LNP<T> ListNode<T>::insertPred(const T& e) { 0002 LNP<T> x = new ListNode(e, pred, this); //创建新节点(pred或为head) 0003 pred->succ = x; pred = x; return x; //列表接纳新节点(操作次序不可颠倒) 0004 } //insertPred:紧靠当前节点之前,将e插入列表:O(1) 0005 0006 template <typename T> LNP<T> ListNode<T>::insertSucc(const T& e) { 0007 LNP<T> x = new ListNode(e, this, succ); //创建新节点(succ或为tail) 0008 succ->pred = x; succ = x; return x; //列表接纳新节点(操作次序不可颠倒) 0009 } //insertSucc:紧随当前节点之后,将e插入列表:O(1)