LightWeightLinkedSet extends LightWeightHashSet<T> { @Override public List<T> pollN(int n) { if (n >= size) { return pollAll(); } List<T> retList = new ArrayList<>(n); while (n-- > 0 && head != null) { T curr = head.element; this.removeElem(curr); retList.add(curr); } shrinkIfNecessary(); return retList; } LightWeightLinkedSet(int initCapacity, float maxLoadFactor,
      float minLoadFactor);  LightWeightLinkedSet(); T pollFirst(); @Override List<T> pollN(int n); @Override List<T> pollAll(); @Override @SuppressWarnings("unchecked") U[] toArray(U[] a); @Override Iterator<T> iterator(); @Override void clear();  }
@Test public void testPollNOne() { LOG.info("Test pollN one"); set.add(list.get(0)); List<Integer> l = set.pollN(10); assertEquals(1, l.size()); assertEquals(list.get(0), l.get(0)); LOG.info("Test pollN one - DONE"); }
@Test public void testPollNMulti() { LOG.info("Test pollN multi"); set.addAll(list); List<Integer> l = set.pollN(10); assertEquals(10, l.size()); for (int i = 0; i < 10; i++) { assertEquals(list.get(i), l.get(i)); } l = set.pollN(1000); assertEquals(NUM - 10, l.size()); for (int i = 10; i < NUM; i++) { assertEquals(list.get(i), l.get(i - 10)); } assertTrue(set.isEmpty()); assertEquals(0, set.size()); LOG.info("Test pollN multi - DONE"); }