use of com.b2international.collections.ints.IntIterator 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());
}
use of com.b2international.collections.ints.IntIterator 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.IntIterator in project snow-owl by b2ihealthcare.
the class IntOpenHashSetTest method iterator_overrun.
@Test(expected = NoSuchElementException.class)
public void iterator_overrun() {
IntSet intSet = PrimitiveSets.newIntOpenHashSet();
IntIterator itr = intSet.iterator();
itr.next();
}
use of com.b2international.collections.ints.IntIterator in project snow-owl by b2ihealthcare.
the class PrimitiveSets method newBitSet.
public static BitSet newBitSet(IntCollection source) {
if (source == null) {
return newBitSet();
} else {
final BitSet bitSet = newBitSetWithExpectedSize(source.size());
final IntIterator iter = source.iterator();
while (iter.hasNext()) {
bitSet.set(iter.next());
}
return bitSet;
}
}
use of com.b2international.collections.ints.IntIterator in project snow-owl by b2ihealthcare.
the class InternalSctIdMultimap method get.
@Override
public LongSet get(final long key) {
final int internalId = internalIdMap.getInternalId(key);
if (internalId == InternalIdMap.NO_INTERNAL_ID) {
return PrimitiveSets.newLongOpenHashSet();
}
final IntSet values = internalIdMultimap.get(internalId);
if (values == null) {
return PrimitiveSets.newLongOpenHashSet();
} else {
final LongSet sctIdValues = PrimitiveSets.newLongOpenHashSetWithExpectedSize(values.size());
for (final IntIterator itr = values.iterator(); itr.hasNext(); ) /*empty*/
{
final int valueInternalId = itr.next();
final long valueSctId = internalIdMap.getSctId(valueInternalId);
sctIdValues.add(valueSctId);
}
return sctIdValues;
}
}
Aggregations