### Question:
LightWeightLinkedSet extends LightWeightHashSet<T> { @Override public Iterator<T> iterator() { return new LinkedSetIterator(); } 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();  }### Answer:
@Test public void testOneElementBasic() { LOG.info("Test one element basic"); set.add(list.get(0)); assertEquals(1, set.size()); assertFalse(set.isEmpty()); Iterator<Integer> iter = set.iterator(); assertTrue(iter.hasNext()); assertEquals(list.get(0), iter.next()); assertFalse(iter.hasNext()); LOG.info("Test one element basic - DONE"); }
@Test public void testMultiBasic() { LOG.info("Test multi element basic"); for (Integer i : list) { assertTrue(set.add(i)); } assertEquals(list.size(), set.size()); for (Integer i : list) { assertTrue(set.contains(i)); } for (Integer i : list) { assertFalse(set.add(i)); } for (Integer i : list) { assertTrue(set.contains(i)); } Iterator<Integer> iter = set.iterator(); int num = 0; while (iter.hasNext()) { assertEquals(list.get(num++), iter.next()); } assertEquals(list.size(), num); LOG.info("Test multi element basic - DONE"); }
@Test public void testRemoveMulti() { LOG.info("Test remove multi"); for (Integer i : list) { assertTrue(set.add(i)); } for (int i = 0; i < NUM / 2; i++) { assertTrue(set.remove(list.get(i))); } for (int i = 0; i < NUM / 2; i++) { assertFalse(set.contains(list.get(i))); } for (int i = NUM / 2; i < NUM; i++) { assertTrue(set.contains(list.get(i))); } Iterator<Integer> iter = set.iterator(); int num = NUM / 2; while (iter.hasNext()) { assertEquals(list.get(num++), iter.next()); } assertEquals(num, NUM); LOG.info("Test remove multi - DONE"); }
@Test public void testRemoveAll() { LOG.info("Test remove all"); for (Integer i : list) { assertTrue(set.add(i)); } for (int i = 0; i < NUM; i++) { assertTrue(set.remove(list.get(i))); } for (int i = 0; i < NUM; i++) { assertFalse(set.contains(list.get(i))); } Iterator<Integer> iter = set.iterator(); assertFalse(iter.hasNext()); assertTrue(set.isEmpty()); LOG.info("Test remove all - DONE"); }