STL标準模板库的函式 unique

unique(STL标準模板库的函式)这是c++模板的一个函式 , 在algorithm头档案中 , 有两个版本的函式声明template<class _FwdIt> inline
_FwdIt unique(_FwdIt _First, _FwdIt _Last)
template<class _FwdIt,
class _Pr> inline
_FwdIt _Unique(_FwdIt _First, _FwdIt _Last, _Pr _Pred)
【STL标準模板库的函式 unique】前一个是当序列的相邻的数据相同时 , 删除相邻相同的数字 , 第二个使用仿函式来替代数列的数字相同这一概念
该函式的精确实现可以搜寻编程範本这本书 , 这里给出大概的实现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;}