SampleSet implements ISampleSet<T> { protected T removeMin() { if (tail == null) { return null; } size--; count -= tail.count; T minElement = tail.element; tail = tail.prev; if (tail != null) { tail.next = null; } sampleMap.remove(minElement); return minElement; } SampleSet();  SampleSet(int capacity);  SampleSet(int capacity, Random random); @Override CountEntry<T> peek(); @Override List<CountEntry<T>> peek(int k); @Override long put(T element); @Override long put(T element, long incrementCount); @Override T removeRandom(); @Override int size(); @Override long count();  }
@Test public void testRemoveMin() { assertNull(set.removeMin()); assertEquals(0, set.size()); assertEquals(0L, set.count()); set.put(e[0]); for (int i = 0; i < 2; i++) { set.put(e[1]); } for (int i = 0; i < 3; i++) { set.put(e[2]); } assertEquals(3, set.size()); assertEquals(6L, set.count()); assertEquals(e[0], set.removeMin()); assertEquals(2, set.size()); assertEquals(5L, set.count()); assertEquals(e[1], set.removeMin()); assertEquals(1, set.size()); assertEquals(3L, set.count()); assertEquals(e[2], set.removeMin()); assertEquals(0, set.size()); assertEquals(0L, set.count()); assertEquals(null, set.removeMin()); assertEquals(0, set.size()); assertEquals(0L, set.count()); }