SlidingWindowCounter implements Serializable { public Map<T, Long> getCountsThenAdvanceWindow() { Map<T, Long> counts = objCounter.getCounts(); objCounter.wipeZeros(); objCounter.wipeSlot(tailSlot); advanceHead(); return counts; } SlidingWindowCounter(int windowLengthInSlots); void incrementCount(T obj); Map<T, Long> getCountsThenAdvanceWindow();  }
@Test public void newInstanceShouldHaveEmptyCounts() { SlidingWindowCounter<Object> counter = new SlidingWindowCounter<Object>(ANY_WINDOW_LENGTH_IN_SLOTS); Map<Object, Long> counts = counter.getCountsThenAdvanceWindow(); assertThat(counts).isEmpty(); }