I have to find if there are doubles in my list<SnakeParts>
and set alive to false if there are doubles
I tried with the unique()
function of the list
and added an operator==()
to my class.
now when I execute the unique function I doesn't filter out the doubles. and after some debugging I found out that the ==
comparator only get's exececuted as many times as there are objects in my list I used the following code:
list<SnakePart> uniquelist = m_snakeParts;
uniquelist.unique();
if (m_snakeParts.size() != uniquelist.size()){
alive = false;
}
operator:
bool SnakePart::operator==(const SnakePart& snakePart) const{
return (x == snakePart.x && y == snakePart.y );
}
but that doesn't work. so what am I doing wrong, or is there another way I could do this?