LongHashSet extends AbstractSet<Long> implements Serializable { @Override public boolean add(final Long value) { return add(value.longValue()); } LongHashSet();  LongHashSet(final int proposedCapacity);  LongHashSet(final int proposedCapacity, final float loadFactor); float loadFactor(); int capacity(); int resizeThreshold(); @Override boolean add(final Long value); boolean add(final long value); @Override boolean remove(final Object value); boolean remove(final long value); void compact(); @Override boolean contains(final Object value); boolean contains(final long value); @Override int size(); @Override boolean isEmpty(); @Override void clear(); @Override boolean addAll(final Collection<? extends Long> coll); @Override boolean removeAll(final Collection<?> coll); @Override LongIterator iterator(); @Override String toString(); @SuppressWarnings("unchecked") @Override T[] toArray(final T[] a); @Override Object[] toArray(); boolean containsAll(final LongHashSet other); @Override boolean equals(final Object other); @Override int hashCode(); static final int DEFAULT_INITIAL_CAPACITY; static final float DEFAULT_LOAD_FACTOR; }
@Test public void addingAnElementTwiceDoesNothing() { Assert.assertTrue(testSet.add(1L)); Assert.assertFalse(testSet.add(1L)); }
@Test public void setsWithTheDifferentSizesAreNotEqual() { final LongHashSet other = new LongHashSet(100); addTwoElements(testSet); other.add(1001L); Assert.assertNotEquals(testSet, other); }
@Test public void setsWithTheDifferentValuesAreNotEqual() { final LongHashSet other = new LongHashSet(100); addTwoElements(testSet); other.add(2L); other.add(1001L); Assert.assertNotEquals(testSet, other); }
@Test public void consecutiveValuesShouldBeCorrectlyStored() { for (long i = 0; i < 10_000; i++) { testSet.add(i); } assertThat(testSet, hasSize(10_000)); int distinctElements = 0; for (final long ignore : testSet) { distinctElements++; } assertThat(distinctElements, is(10_000)); }