@Test public void testRemove() throws Exception { Value victim = new Value(); Double[] testValues = new Double[]{1.0, -1.0, 2.0, 2.1, 0.0, 53.0, -27.5}; for (Double value : testValues) { victim.add(value); } double originalValue = victim.getValue(); double originalSum = victim.getSum(); long originalCount = victim.getCount(); Double[] newValues = new Double[] {2.1, -27.0, 2.1, 0.0 }; double newValueSum = 0.0; long newValueCount = newValues.length; for (Double value : newValues) { newValueSum += value; victim.add(value); } double appendedSum = originalSum + newValueSum; long appendedCount = originalCount + newValueCount; double appendedAverage = appendedSum / appendedCount; assertEquals("Appended sum should match.", appendedSum, victim.getSum(), EPSILON); assertEquals("Appended value (average) should match", appendedAverage, victim.getValue(), EPSILON); assertTrue("Appended count should match.", appendedCount == victim.getCount()); for (Double value : newValues) { victim.remove(value); } assertEquals("After remove, value should equal original value.", originalValue, victim.getValue(), EPSILON); assertEquals("After remove, sum should equal original sum.", originalSum,victim.getSum(), EPSILON); assertTrue("After remove, count should equal original count.", originalCount == victim.getCount()); }
public final void remove(final double value) { sum -= value; count--; }
Value { public final void remove(final double value) { sum -= value; count--; } }
Value { public final void remove(final double value) { sum -= value; count--; }  }
Value { public final void remove(final double value) { sum -= value; count--; }  final double getValue(); final double getSum(); final long getCount(); final void add(final double value); final void addInterpolated(final double value); final boolean valueIsInterpolated(); final void remove(final double value); }
Value { public final void remove(final double value) { sum -= value; count--; }  final double getValue(); final double getSum(); final long getCount(); final void add(final double value); final void addInterpolated(final double value); final boolean valueIsInterpolated(); final void remove(final double value);  }