public <E extends SamplingEntry> Iterable<E> getRandomSamples(int sampleCount) {
        if (sampleCount < 0) {
            throw new IllegalArgumentException("Sample count cannot be a negative value.");
        }
        if (sampleCount == 0 || size() == 0) {
            return Collections.emptyList();
        }
        return new LazySamplingEntryIterableIterator<>(sampleCount);
    }
@Test
    public void testIteratorContract() {
        final int entryCount = 100;
        final int sampleCount = 30;

        map = new SampleableConcurrentHashMap<>(100);

        for (int i = 0; i < entryCount; i++) {
            map.put(i, i);
        }

        Iterable<SampleableConcurrentHashMap.SamplingEntry<Integer, Integer>> samples = map.getRandomSamples(sampleCount);

        Iterator<SampleableConcurrentHashMap.SamplingEntry<Integer, Integer>> iterator = samples.iterator();

        // hasNext should not consume the items
        for (int i = 0; i < entryCount * 2; i++) {
            assertTrue(iterator.hasNext());
        }

        Set<Integer> set = new HashSet<>();
        // should return unique samples
        for (int i = 0; i < sampleCount; i++) {
            set.add(iterator.next().key);
        }
        assertEquals(30, set.size());

        assertFalse(iterator.hasNext());
    }