K
ken.carlino
Hi,
I have a function which check if there is duplicate entries in a STL
list:
bool hasDuplicateY() {
sort(_aList.begin(), _aList.end(), sort_y_comparator<A*>());
AList::iterator iter;
iter = adjacent_find ( _aList.begin(), _aList.end(), SameY());
if (iter == _aList.end())
return false;
else
return true;
}
bool SameY:
perator()( A* bd1, A* bd2)
{
return bd1->y == bd2->y;
}
template<class T> struct sort_y_comparator : public
binary_function<T,T,bool>
{
sort_y_comparator() {}
bool operator()(const T r1, const T r2) const
{
return (r1->y < r2->y);
}
};
But the above function always return true even if there is no
duplication in the list.
Can you please tell me what have I done wrong?
Thank you.
I have a function which check if there is duplicate entries in a STL
list:
bool hasDuplicateY() {
sort(_aList.begin(), _aList.end(), sort_y_comparator<A*>());
AList::iterator iter;
iter = adjacent_find ( _aList.begin(), _aList.end(), SameY());
if (iter == _aList.end())
return false;
else
return true;
}
bool SameY:
{
return bd1->y == bd2->y;
}
template<class T> struct sort_y_comparator : public
binary_function<T,T,bool>
{
sort_y_comparator() {}
bool operator()(const T r1, const T r2) const
{
return (r1->y < r2->y);
}
};
But the above function always return true even if there is no
duplication in the list.
Can you please tell me what have I done wrong?
Thank you.