update comparison operators for Iterator/Cursor

This commit is contained in:
Josh Holtrop 2016-10-26 20:43:39 -04:00
parent 523eba81f5
commit 8432e7f4b7

View File

@ -78,6 +78,16 @@ public:
{
return valid() && (offset < piece->length);
}
bool operator==(const Iterator & other) const
{
return (other.piece == piece) && (other.offset == offset);
}
bool operator!=(const Iterator & other) const
{
return !(*this == other);
}
};
struct Cursor
@ -110,10 +120,14 @@ public:
bool check_go_left(int n);
bool check_go_right(int n, bool allow_on_eol);
bool operator==(const Cursor & c)
bool operator==(const Cursor & c) const
{
return (c.line == line) && (c.column == column);
}
bool operator!=(const Cursor & c) const
{
return !(*this == c);
}
void warp_to_inserted_piece(Piece * piece);
protected: