Search in sources :

Example 21 with IntSet

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

the class NormalFormGroup method fillNumbers.

public void fillNumbers() {
    final IntSet numbersUsed = PrimitiveSets.newIntOpenHashSetWithExpectedSize(unionGroups.size());
    this.unionGroups.stream().filter(unionGroup -> unionGroup.getUnionGroupNumber() > 0).forEachOrdered(unionGroup -> numbersUsed.add(unionGroup.getUnionGroupNumber()));
    int unionGroupNumber = 1;
    for (final NormalFormUnionGroup unionGroup : unionGroups) {
        if (unionGroup.getUnionGroupNumber() == NormalFormUnionGroup.UNKOWN_GROUP) {
            while (numbersUsed.contains(unionGroupNumber)) {
                unionGroupNumber++;
            }
            unionGroup.setUnionGroupNumber(unionGroupNumber);
            unionGroupNumber++;
        }
    }
}
Also used : Objects(java.util.Objects) Preconditions.checkArgument(com.google.common.base.Preconditions.checkArgument) List(java.util.List) PrimitiveSets(com.b2international.collections.PrimitiveSets) ImmutableList(com.google.common.collect.ImmutableList) Preconditions.checkNotNull(com.google.common.base.Preconditions.checkNotNull) Comparator(java.util.Comparator) Preconditions.checkState(com.google.common.base.Preconditions.checkState) IntSet(com.b2international.collections.ints.IntSet) IntSet(com.b2international.collections.ints.IntSet)

Example 22 with IntSet

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

the class IntOpenHashSetTest method retainAll_empty_set.

@Test
public void retainAll_empty_set() {
    IntSet intSet = PrimitiveSets.newIntOpenHashSet();
    IntSet otherSet = PrimitiveSets.newIntOpenHashSet();
    intSet.add(0);
    intSet.add(5);
    intSet.add(10);
    intSet.retainAll(otherSet);
    assertTrue("Integer set should be empty after retaining an empty set.", intSet.isEmpty());
}
Also used : IntSet(com.b2international.collections.ints.IntSet) Test(org.junit.Test)

Example 23 with IntSet

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

the class IntOpenHashSetTest method equals_true.

@Test
public void equals_true() {
    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 be equal to second set.", intSet.equals(otherSet));
    assertTrue("Second set should be equal to first set.", otherSet.equals(intSet));
}
Also used : IntSet(com.b2international.collections.ints.IntSet) Test(org.junit.Test)

Example 24 with IntSet

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

the class IntOpenHashSetTest method create.

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

Example 25 with IntSet

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

the class IntOpenHashSetTest method trimToSize.

@Test
public void trimToSize() {
    IntSet intSet = PrimitiveSets.newIntOpenHashSet();
    intSet.trimToSize();
}
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