Skip to content

Commit

Permalink
make Vectore == comparable
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Suda committed Nov 15, 2017
1 parent 5acc529 commit 5c17f89
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions Lib/Vector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,25 @@ class Vector
DEALLOC_KNOWN(this,sz,"Vector");
} // deallocate

bool operator==(const Vector& v) const
{
CALL("Vector::operator==");

if(length()!=v.length()) {
return false;
}
size_t sz = length();
for(size_t i=0; i!=sz; ++i) {
if((*this)[i]!=v[i]) {
return false;
}
}
return true;
}

bool operator!=(const Vector& o) const
{ return !((*this)==o); }

/**
* Convert the vector to its string representation. To use this function,
* elements must have a toString() function too.
Expand Down

0 comments on commit 5c17f89

Please sign in to comment.