0001 template <typename T> bool Skiplist<T>::remove(const T& e) { 0002 search(e); if ((_x == head) || (e != key(_x))) return false; //确保目标存在 0003 for (Rank h = height(_x) - 1; -1 != h; h--) { //自顶而下地 0004 Brick<T>& b = tower(_x)[h]; //对每一块砖 0005 tower(b.pred)[h].succ = b.succ; //恢复其前驱与 0006 tower(b.succ)[h].pred = b.pred; //后继之间的链接 0007 if (head == b.pred && b.succ == tail) //并及时地将空层 0008 { tower(head).remove(h); tower(tail).remove(h); } //清理掉 0009 } //for 0010 List::remove(_x); return true; //最后销毁整塔,便可收工 0011 } //remove