LightWeightHashSet implements Collection<T> { public T getElement(final T key) { if (key == null) { throw new IllegalArgumentException("Null element is not supported."); } final int hashCode = key.hashCode(); final int index = getIndex(hashCode); return getContainedElem(index, key, hashCode); } @SuppressWarnings("unchecked")  LightWeightHashSet(int initCapacity, float maxLoadFactor,
      float minLoadFactor);  LightWeightHashSet();  LightWeightHashSet(int minCapacity); @Override boolean isEmpty(); int getCapacity(); @Override int size(); @SuppressWarnings("unchecked") @Override boolean contains(final Object key); T getElement(final T key); @Override boolean addAll(Collection<? extends T> toAdd); @Override boolean add(final T element); @Override @SuppressWarnings("unchecked") boolean remove(final Object key); List<T> pollN(int n); List<T> pollAll(); @SuppressWarnings("unchecked") T[] pollToArray(T[] array); @Override Iterator<T> iterator(); @Override String toString(); void printDetails(final PrintStream out); @Override @SuppressWarnings("unchecked") void clear(); @Override Object[] toArray(); @Override @SuppressWarnings("unchecked") U[] toArray(U[] a); @Override boolean containsAll(Collection<?> c); @Override boolean removeAll(Collection<?> c); @Override boolean retainAll(Collection<?> c);  }
@Test public void testGetElement() { LightWeightHashSet<TestObject> objSet = new LightWeightHashSet<>(); TestObject objA = new TestObject("object A"); TestObject equalToObjA = new TestObject("object A"); TestObject objB = new TestObject("object B"); objSet.add(objA); objSet.add(objB); assertSame(objA, objSet.getElement(objA)); assertSame(objA, objSet.getElement(equalToObjA)); assertSame(objB, objSet.getElement(objB)); assertNull(objSet.getElement(new TestObject("not in set"))); }