@Override public int hashCode() { return super.hashCode(); // Ignore the existence of the parent field. Only 2 equal points with different parent will exist at a given time anyway. }
/** * Calculates and returns a hash code value from the value of each component of this frame point 3D. * * @return the hash code value for this frame point 3D. */ @Override public int hashCode() { return point.hashCode(); } }
/** * Calculates and returns a hash code value from the value of each component of this line segment * 3D. * * @return the hash code value for this line segment 3D. */ @Override public int hashCode() { long bits = 31L * firstEndpoint.hashCode() + secondEndpoint.hashCode(); return (int) (bits ^ bits >> 32); } }
/** * Calculates and returns a hash code value from the value of each component of this line 3D. * * @return the hash code value for this line 3D. */ @Override public int hashCode() { long bits = 31L * point.hashCode() + direction.hashCode(); return (int) (bits ^ bits >> 32); } }
/** * Calculates and returns a hash code value from the value of each component of this pose 3D. * * @return the hash code value for this pose 3D. */ @Override public int hashCode() { long bits = 31L * position.hashCode() + orientation.hashCode(); return (int) (bits ^ bits >> 32); } }
@Test public void testHashCode() throws Exception { Random random = new Random(621541L); Point3D tuple1 = createEmptyTuple(); tuple1.setX(random.nextDouble()); tuple1.setY(random.nextDouble()); tuple1.setZ(random.nextDouble()); int newHashCode, previousHashCode; newHashCode = tuple1.hashCode(); assertEquals(newHashCode, tuple1.hashCode()); previousHashCode = tuple1.hashCode(); for (int i = 0; i < ITERATIONS; i++) { tuple1.setElement(i % 3, random.nextDouble()); newHashCode = tuple1.hashCode(); assertNotEquals(newHashCode, previousHashCode); previousHashCode = newHashCode; } }
@Test public void testHashCode() throws Exception { Random random = new Random(763); for (int i = 0; i < ITERATIONS; i++) { Point3D expected = EuclidCoreRandomTools.nextPoint3D(random, -1.0e15, 1.0e15); FramePoint3D actual = new FramePoint3D(worldFrame, expected); assertEquals(expected.hashCode(), actual.hashCode()); } }