use of com.b2international.collections.ints.IntSet in project snow-owl by b2ihealthcare.
the class IntOpenHashSetTest method iterator.
@Test
public void iterator() {
IntSet intSet = PrimitiveSets.newIntOpenHashSet();
intSet.add(0);
intSet.add(5);
intSet.add(10);
IntIterator itr = intSet.iterator();
int[] values = new int[3];
for (int i = 0; i < 3; i++) {
assertTrue("Iterator should indicate that the next value is available.", itr.hasNext());
values[i] = itr.next();
}
assertFalse("Iterator should indicate that there are no more elements.", itr.hasNext());
Arrays.sort(values);
assertEquals("Iterator should return first element.", 0, values[0]);
assertEquals("Iterator should return second element.", 5, values[1]);
assertEquals("Iterator should return third element.", 10, values[2]);
}
use of com.b2international.collections.ints.IntSet in project snow-owl by b2ihealthcare.
the class IntOpenHashSetTest method add.
@Test
public void add() {
IntSet intSet = PrimitiveSets.newIntOpenHashSet();
intSet.add(0);
intSet.add(5);
intSet.add(10);
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));
}
use of com.b2international.collections.ints.IntSet in project snow-owl by b2ihealthcare.
the class IntOpenHashSetTest method removeAll_null.
@Test(expected = NullPointerException.class)
public void removeAll_null() {
IntSet intSet = PrimitiveSets.newIntOpenHashSet();
intSet.add(0);
intSet.add(5);
intSet.add(10);
intSet.removeAll(null);
}
use of com.b2international.collections.ints.IntSet in project snow-owl by b2ihealthcare.
the class IntOpenHashSetTest method create_collection.
@Test
public void create_collection() {
IntSet intSet = PrimitiveSets.newIntOpenHashSet(PrimitiveLists.newIntArrayList(0, 5, 10, 5));
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));
}
use of com.b2international.collections.ints.IntSet in project snow-owl by b2ihealthcare.
the class IntOpenHashSetTest method toArray.
@Test
public void toArray() {
IntSet intSet = PrimitiveSets.newIntOpenHashSet();
intSet.add(0);
intSet.add(5);
intSet.add(10);
int[] array = intSet.toArray();
Arrays.sort(array);
assertArrayEquals("Array should contain all stored elements.", new int[] { 0, 5, 10 }, array);
}
Aggregations