Search in sources :

Example 11 with IntSet

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

the class IntOpenHashSetTest method addAll.

@Test
public void addAll() {
    IntSet intSet = PrimitiveSets.newIntOpenHashSet();
    IntSet otherSet = PrimitiveSets.newIntOpenHashSet();
    otherSet.add(0);
    otherSet.add(5);
    otherSet.add(10);
    intSet.addAll(otherSet);
    assertEquals("Integer set size should be 3.", 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 12 with IntSet

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

the class IntOpenHashSetTest method containsAll.

@Test
public void containsAll() {
    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);
    assertTrue("First set should contain all elements from second set.", intSet.containsAll(otherSet));
    assertTrue("Second set should contain all elements from first set.", otherSet.containsAll(intSet));
}
Also used : IntSet(com.b2international.collections.ints.IntSet) Test(org.junit.Test)

Example 13 with IntSet

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

the class IntOpenHashSetTest method retainAll_superset.

@Test
public void retainAll_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.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 14 with IntSet

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

the class IntOpenHashSetTest method equals_false.

@Test
public void equals_false() {
    IntSet intSet = PrimitiveSets.newIntOpenHashSet();
    IntSet otherSet = PrimitiveSets.newIntOpenHashSet();
    intSet.add(0);
    intSet.add(5);
    intSet.add(10);
    otherSet.add(0);
    otherSet.add(1);
    otherSet.add(2);
    assertFalse("First set should not be equal to second set.", intSet.equals(otherSet));
    assertFalse("Second set should not be equal to first set.", otherSet.equals(intSet));
}
Also used : IntSet(com.b2international.collections.ints.IntSet) Test(org.junit.Test)

Example 15 with IntSet

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

the class IntOpenHashSetTest method create_empty_collection.

@Test
public void create_empty_collection() {
    IntSet intSet = PrimitiveSets.newIntOpenHashSet(PrimitiveLists.newIntArrayList());
    assertTrue("Integer set should be empty.", intSet.isEmpty());
}
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