該函式的精確實現可以搜尋編程範本這本書,這裡給出大概的實現
template<class Iter>
Iter _unique(Iter F1,Iter L1)
{
queue<Iter> Q;
Iter T=_find_adjacent_mismatch1(F1,L1);
while(T!=L1)
{
Q.push(T);
T=_find_adjacent_mismatch1(T,L1);
}
Q.push(L1);
Iter CD=Q.front();
Iter CR=Q.front();
Q.pop();
while(CR!=L1)
{
while(++CR!=Q.front())
*CD=*CR,++CD;
Q.pop();
}
return CD;
}