### Question:
StatisticsSetImplementation implements StatisticsSet { public synchronized void add(ImmutableStatisticsSet operand) { final StatisticsSetImplementation operandImplementation = (StatisticsSetImplementation)operand; final boolean[] isVarianceIndex = new boolean[m_doubleData.length]; for (LongSampleIndex index : m_statisticsIndexMap.getLongSampleIndicies()) { final LongIndex sumIndex = index.getSumIndex(); final LongIndex countIndex = index.getCountIndex(); final DoubleIndex varianceIndex = index.getVarianceIndex(); setValue(varianceIndex, calculateVariance(getValue(sumIndex), getValue(countIndex), getValue(varianceIndex), operand.getValue(sumIndex), operand.getValue(countIndex), operand.getValue(varianceIndex))); isVarianceIndex[varianceIndex.getValue()] = true; } for (DoubleSampleIndex index : m_statisticsIndexMap.getDoubleSampleIndicies()) { final DoubleIndex sumIndex = index.getSumIndex(); final LongIndex countIndex = index.getCountIndex(); final DoubleIndex varianceIndex = index.getVarianceIndex(); setValue(varianceIndex, calculateVariance(getValue(sumIndex), getValue(countIndex), getValue(varianceIndex), operand.getValue(sumIndex), operand.getValue(countIndex), operand.getValue(varianceIndex))); isVarianceIndex[varianceIndex.getValue()] = true; } final long[] longData = operandImplementation.m_longData; for (int i = 0; i < longData.length; i++) { m_longData[i] += longData[i]; } final double[] doubleData = operandImplementation.m_doubleData; for (int i = 0; i < doubleData.length; i++) { if (!isVarianceIndex[i]) { m_doubleData[i] += doubleData[i]; } } m_zero = false; if (operand.isComposite()) { setIsComposite(); } } StatisticsSetImplementation(StatisticsIndexMap statisticsIndexMap);   StatisticsSetImplementation(StatisticsIndexMap statisticsIndexMap,
                              ObjectInput in, Serialiser serialiser); synchronized void reset(); synchronized StatisticsSet snapshot(); synchronized long getValue(LongIndex index); synchronized double getValue(DoubleIndex index); synchronized void setValue(LongIndex index, long value); synchronized void setValue(DoubleIndex index, double value); synchronized void addValue(LongIndex index, long value); synchronized void addValue(DoubleIndex index, double value); synchronized void addSample(LongSampleIndex index, long value); synchronized void addSample(DoubleSampleIndex index, double value); synchronized void reset(LongSampleIndex index); synchronized void reset(DoubleSampleIndex index); long getSum(LongSampleIndex index); double getSum(DoubleSampleIndex index); long getCount(SampleIndex index); double getVariance(SampleIndex index); synchronized void add(ImmutableStatisticsSet operand); synchronized boolean isZero(); synchronized boolean isComposite(); synchronized void setIsComposite(); synchronized boolean equals(Object o); int hashCode(); synchronized String toString();  }### Answer:
@Test public void testAdd() throws Exception { final StatisticsSetImplementation statistics0 = new StatisticsSetImplementation(m_indexMap); final StatisticsSetImplementation statistics1 = new StatisticsSetImplementation(m_indexMap); assertTrue(statistics1.isZero()); assertFalse(statistics1.isComposite()); statistics0.add(statistics1); assertEquals(statistics0, statistics1); assertFalse(statistics0.isZero()); assertTrue(statistics1.isZero()); assertFalse(statistics1.isComposite()); statistics0.addValue(m_longIndex0, 100); statistics0.addValue(m_doubleIndex2, -5.5); statistics0.setIsComposite(); statistics1.add(statistics0); assertEquals(statistics0, statistics1); assertTrue(statistics1.isComposite()); statistics1.add(statistics0); assertTrue(!statistics0.equals(statistics1)); statistics0.add(statistics0); assertEquals(statistics0, statistics1); assertEquals(200, statistics0.getValue(m_longIndex0)); assertDoublesEqual(-11d, statistics0.getValue(m_doubleIndex2)); }