S
Suma
A newbie question :
I have a vector of objects(pointers) . I have a function which
overloads the less than operator . I can sort the objects without a
problem. However when I pass the same function as an arg to the unique
function, I still see the duplicate objects.
Shouldnt unique be aple to operate with just the less_than overload-
since if both the predicates constant1 < constant2 and constan2 <
constant1 return false implies equality?
What am i assuming wrongly?
Pseudo code
Input:
class CPerson
{
int age;
int salary
}
bool less_than(CPerson* p1,CPerson*p2)
{
}
vector<CPerson*> oArray;
..
..
..
sort(oArray.begin(),oArray.end(),less_than())
iterator new = unique(oArray.begin(),oArray.end(),less_than())
begin to new is not unique
I have a vector of objects(pointers) . I have a function which
overloads the less than operator . I can sort the objects without a
problem. However when I pass the same function as an arg to the unique
function, I still see the duplicate objects.
Shouldnt unique be aple to operate with just the less_than overload-
since if both the predicates constant1 < constant2 and constan2 <
constant1 return false implies equality?
What am i assuming wrongly?
Pseudo code
Input:
class CPerson
{
int age;
int salary
}
bool less_than(CPerson* p1,CPerson*p2)
{
}
vector<CPerson*> oArray;
..
..
..
sort(oArray.begin(),oArray.end(),less_than())
iterator new = unique(oArray.begin(),oArray.end(),less_than())
begin to new is not unique