0001 template <typename T> int List<T>::deduplicate() { 0002 int oldSize = _size; ListNodePosi<T> p = first(); 0003 for ( Rank r = 0; p != trailer; p = p->succ ) //O(n) 0004 if ( ListNodePosi<T> q = find(p->data, r, p) ) 0005 remove(q); //此时q与p雷同,但删除前者更为简明 0006 else r++; //r为无重前缀的长度 0007 return oldSize - _size; //删除元素总数 0008 }