Skip to content

Instantly share code, notes, and snippets.

@spitz-dan-l
Last active August 29, 2015 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spitz-dan-l/5cfdf625ede28d66f568 to your computer and use it in GitHub Desktop.
Save spitz-dan-l/5cfdf625ede28d66f568 to your computer and use it in GitHub Desktop.
public boolean compare(Grid<T> grid2) {
if(this.row != grid2.row || this.col != grid2.col) {
return false;
}
for(Grid<T>.Element tmpElem : this.elements()) {
Grid<T>.Element tmpElem2 = grid2.getElement(tmpElem.pos());
T v1 = tmpElem.value();
T v2 = tmpElem2.value();
System.out.print("Grid1: " + v1);
System.out.println(" Grid2: " + v2);
if (v1 == null || v2 == null){
if (v1 != v2){
return false;
} else {
continue;
}
}
if (!v1.equals(v2)){
return false;
}
}
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment