### Question:
StatisticsSetImplementation implements StatisticsSet { public synchronized StatisticsSet snapshot() { final StatisticsSetImplementation result = new StatisticsSetImplementation(m_statisticsIndexMap); if (!m_zero) { synchronized (result) { System.arraycopy(m_longData, 0, result.m_longData, 0, result.m_longData.length); System.arraycopy(m_doubleData, 0, result.m_doubleData, 0, result.m_doubleData.length); System.arraycopy(m_transientLongData, 0, result.m_transientLongData, 0, result.m_transientLongData.length); result.m_zero = false; result.m_composite = m_composite; } } return result; } 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 testSnapshot() throws Exception { final StatisticsSetImplementation original = new StatisticsSetImplementation(m_indexMap); original.addValue(m_longIndex0, 10); original.setValue(m_doubleIndex2, 3); original.setIsComposite(); final StatisticsSet snapshot = original.snapshot(); assertDoublesEqual(3d, snapshot.getValue(m_doubleIndex2)); assertEquals(0, snapshot.getValue(m_longIndex1)); assertEquals(10, snapshot.getValue(m_longIndex0)); assertTrue(original.isComposite()); assertDoublesEqual(3d, original.getValue(m_doubleIndex2)); assertEquals(0, original.getValue(m_longIndex1)); assertEquals(10, original.getValue(m_longIndex0)); original.addValue(m_longIndex0, 5); original.addValue(m_doubleIndex0, 20); snapshot.addValue(m_longIndex0, 1); assertDoublesEqual(3d, snapshot.getValue(m_doubleIndex2)); assertEquals(0, snapshot.getValue(m_longIndex1)); assertEquals(11, snapshot.getValue(m_longIndex0)); assertDoublesEqual(3d, original.getValue(m_doubleIndex2)); assertDoublesEqual(20d, original.getValue(m_doubleIndex0)); assertEquals(0, original.getValue(m_longIndex1)); assertEquals(15, original.getValue(m_longIndex0)); original.reset(); final StatisticsSet snapshot2 = original.snapshot(); assertTrue(snapshot2.isZero()); }