Skip to content

Commit 97e7073

Browse files
committed
Improved the XYZPoint equals method.
1 parent ecc3fe3 commit 97e7073

File tree

1 file changed

+7
-1
lines changed
  • src/com/jwetherell/algorithms/data_structures

1 file changed

+7
-1
lines changed

src/com/jwetherell/algorithms/data_structures/KdTree.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,13 @@ public boolean equals(Object obj) {
652652
return false;
653653

654654
XYZPoint xyzPoint = (XYZPoint) obj;
655-
return compareTo(xyzPoint) == 0;
655+
if (Double.compare(this.x, xyzPoint.x)!=0)
656+
return false;
657+
if (Double.compare(this.y, xyzPoint.y)!=0)
658+
return false;
659+
if (Double.compare(this.z, xyzPoint.z)!=0)
660+
return false;
661+
return true;
656662
}
657663

658664
/**

0 commit comments

Comments
 (0)