LightWeightLinkedSet extends LightWeightHashSet<T> { @Override @SuppressWarnings("unchecked") public <U> U[] toArray(U[] a) { if (a == null) { throw new NullPointerException("Input array can not be null"); } if (a.length < size) { a = (U[]) java.lang.reflect.Array .newInstance(a.getClass().getComponentType(), size); } int currentIndex = 0; DoubleLinkedElement<T> current = head; while (current != null) { T curr = current.element; a[currentIndex++] = (U) curr; current = current.after; } return a; } 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 testOther() { LOG.info("Test other"); assertTrue(set.addAll(list)); Integer[] array = set.toArray(new Integer[0]); assertEquals(NUM, array.length); for (Integer anArray : array) { assertTrue(list.contains(anArray)); } assertEquals(NUM, set.size()); Object[] array2 = set.toArray(); assertEquals(NUM, array2.length); for (Object anArray2 : array2) { assertTrue(list.contains((Integer) anArray2)); } LOG.info("Test capacity - DONE"); }