Search in sources :

Example 6 with IntSet

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

the class IntOpenHashSetTest method iterator_empty.

@Test
public void iterator_empty() {
    IntSet intSet = PrimitiveSets.newIntOpenHashSet();
    IntIterator itr = intSet.iterator();
    assertFalse("Iterator should indicate that there are no elements.", itr.hasNext());
}
Also used : IntIterator(com.b2international.collections.ints.IntIterator) IntSet(com.b2international.collections.ints.IntSet) Test(org.junit.Test)

Example 7 with IntSet

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

the class IntOpenHashSetTest method removeAll_same.

@Test
public void removeAll_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.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 8 with IntSet

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

the class IntOpenHashSetTest method containsAll_disjoint_set.

@Test
public void containsAll_disjoint_set() {
    IntSet intSet = PrimitiveSets.newIntOpenHashSet();
    IntSet otherSet = PrimitiveSets.newIntOpenHashSet();
    intSet.add(0);
    intSet.add(5);
    intSet.add(10);
    otherSet.add(-10);
    otherSet.add(0);
    otherSet.add(5);
    assertFalse("First set should not contain all elements from second set.", intSet.containsAll(otherSet));
    assertFalse("Second set should not contain all elements from first set.", otherSet.containsAll(intSet));
}
Also used : IntSet(com.b2international.collections.ints.IntSet) Test(org.junit.Test)

Example 9 with IntSet

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

the class IntOpenHashSetTest method containsAll_subset.

@Test
public void containsAll_subset() {
    IntSet intSet = PrimitiveSets.newIntOpenHashSet();
    IntSet otherSet = PrimitiveSets.newIntOpenHashSet();
    intSet.add(0);
    intSet.add(5);
    intSet.add(10);
    otherSet.add(0);
    otherSet.add(5);
    assertTrue("First set should contain all elements from second set.", intSet.containsAll(otherSet));
    assertFalse("Second set should not contain all elements from first set.", otherSet.containsAll(intSet));
}
Also used : IntSet(com.b2international.collections.ints.IntSet) Test(org.junit.Test)

Example 10 with IntSet

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

the class IntOpenHashSetTest method toString_empty.

@Test
public void toString_empty() {
    IntSet intSet = PrimitiveSets.newIntOpenHashSet();
    assertEquals("ToString output should be [] for the empty set.", "[]", intSet.toString());
}
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