Search in sources :

Example 31 with IntSet

use of com.b2international.collections.ints.IntSet in project snow-owl by b2ihealthcare.

the class IntOpenHashSetTest method create_zero_size.

@Test
public void create_zero_size() {
    IntSet intSet = PrimitiveSets.newIntOpenHashSetWithExpectedSize(0);
    assertTrue("Integer set should be empty.", intSet.isEmpty());
}
Also used : IntSet(com.b2international.collections.ints.IntSet) Test(org.junit.Test)

Example 32 with IntSet

use of com.b2international.collections.ints.IntSet in project snow-owl by b2ihealthcare.

the class IntOpenHashSetTest method retainAll_same.

@Test
public void retainAll_same() {
    IntSet intSet = PrimitiveSets.newIntOpenHashSet();
    IntSet otherSet = PrimitiveSets.newIntOpenHashSet();
    intSet.add(0);
    intSet.add(5);
    intSet.add(10);
    otherSet.add(0);
    otherSet.add(5);
    otherSet.add(10);
    intSet.retainAll(otherSet);
    assertEquals("Three elements should remain after retaining.", 3, intSet.size());
    assertTrue("Integer set should contain element 0.", intSet.contains(0));
    assertTrue("Integer set should contain element 5.", intSet.contains(5));
    assertTrue("Integer set should contain element 10.", intSet.contains(10));
}
Also used : IntSet(com.b2international.collections.ints.IntSet) Test(org.junit.Test)

Example 33 with IntSet

use of com.b2international.collections.ints.IntSet in project snow-owl by b2ihealthcare.

the class IntOpenHashSetTest method retainAll.

@Test
public void retainAll() {
    IntSet intSet = PrimitiveSets.newIntOpenHashSet();
    IntSet otherSet = PrimitiveSets.newIntOpenHashSet();
    intSet.add(0);
    intSet.add(5);
    intSet.add(10);
    otherSet.add(0);
    otherSet.add(10);
    intSet.retainAll(otherSet);
    assertEquals("Two elements should remain after retaining.", 2, intSet.size());
    assertTrue("Integer set should contain element 0.", intSet.contains(0));
    assertTrue("Integer set should contain element 10.", intSet.contains(10));
}
Also used : IntSet(com.b2international.collections.ints.IntSet) Test(org.junit.Test)

Example 34 with IntSet

use of com.b2international.collections.ints.IntSet in project snow-owl by b2ihealthcare.

the class IntOpenHashSetTest method removeAll_superset.

@Test
public void removeAll_superset() {
    IntSet intSet = PrimitiveSets.newIntOpenHashSet();
    IntSet otherSet = PrimitiveSets.newIntOpenHashSet();
    intSet.add(0);
    intSet.add(5);
    intSet.add(10);
    otherSet.add(0);
    otherSet.add(5);
    otherSet.add(10);
    otherSet.add(30);
    intSet.removeAll(otherSet);
    assertTrue("Integer set should be empty after removing all elements.", intSet.isEmpty());
}
Also used : IntSet(com.b2international.collections.ints.IntSet) Test(org.junit.Test)

Example 35 with IntSet

use of com.b2international.collections.ints.IntSet in project snow-owl by b2ihealthcare.

the class IntOpenHashSetTest method removeAll.

@Test
public void removeAll() {
    IntSet intSet = PrimitiveSets.newIntOpenHashSet();
    IntSet otherSet = PrimitiveSets.newIntOpenHashSet();
    intSet.add(0);
    intSet.add(5);
    intSet.add(10);
    otherSet.add(0);
    otherSet.add(10);
    intSet.removeAll(otherSet);
    assertEquals("Only one element should remain after removing the others.", 1, intSet.size());
    assertTrue("Integer set should contain element 5.", intSet.contains(5));
}
Also used : IntSet(com.b2international.collections.ints.IntSet) Test(org.junit.Test)

Aggregations

IntSet (com.b2international.collections.ints.IntSet)43 Test (org.junit.Test)38 IntIterator (com.b2international.collections.ints.IntIterator)4 PrimitiveSets (com.b2international.collections.PrimitiveSets)2 Comparator (java.util.Comparator)2 List (java.util.List)2 LongSet (com.b2international.collections.longs.LongSet)1 Preconditions.checkArgument (com.google.common.base.Preconditions.checkArgument)1 Preconditions.checkNotNull (com.google.common.base.Preconditions.checkNotNull)1 Preconditions.checkState (com.google.common.base.Preconditions.checkState)1 ImmutableList (com.google.common.collect.ImmutableList)1 Lists.newArrayList (com.google.common.collect.Lists.newArrayList)1 AbstractSet (java.util.AbstractSet)1 Iterator (java.util.Iterator)1 Objects (java.util.Objects)1