use of com.b2international.collections.longs.LongIterator in project snow-owl by b2ihealthcare.
the class LongSets method transform.
/**
* Transforms the given {@link LongCollection} into a collection of object based on the {@link InverseLongFunction function} argument.
* @param fromCollection the collection of primitive long values to transform.
* @param function the function for the transformation.
* @return the transformed collection of long values.
*/
public static <T> Collection<T> transform(final LongCollection fromCollection, final InverseLongFunction<? extends T> function) {
checkNotNull(fromCollection, "fromCollection");
checkNotNull(function, "function");
@SuppressWarnings("unchecked") final Collection<T> toCollection = (Collection<T>) (fromCollection instanceof LongSet ? Sets.newHashSetWithExpectedSize(fromCollection.size()) : Lists.newArrayListWithExpectedSize(fromCollection.size()));
for (final LongIterator itr = fromCollection.iterator(); itr.hasNext(); ) /**/
{
toCollection.add(function.apply(itr.next()));
}
return toCollection;
}
use of com.b2international.collections.longs.LongIterator in project snow-owl by b2ihealthcare.
the class LongTarjan method visit.
private void visit(final long currentId, final LongCollection ids) {
indexMap.put(currentId, index);
lowLinkMap.put(currentId, index);
index++;
idStack.add(currentId);
final LongCollection followers = getFollowers.apply(currentId);
for (final LongIterator itr = followers.iterator(); itr.hasNext(); ) /* empty */
{
final long currentFollowerId = itr.next();
if (!indexMap.containsKey(currentFollowerId)) {
continue;
}
if (indexMap.get(currentFollowerId) == -1) {
visit(currentFollowerId, ids);
final int newLowLink = Math.min(lowLinkMap.get(currentId), lowLinkMap.get(currentFollowerId));
lowLinkMap.put(currentId, newLowLink);
} else if (idStack.contains(currentFollowerId)) {
final int newLowLink = Math.min(lowLinkMap.get(currentId), indexMap.get(currentFollowerId));
lowLinkMap.put(currentId, newLowLink);
}
}
if (lowLinkMap.get(currentId) == indexMap.get(currentId)) {
long sccMember = removeLast();
if (currentId == sccMember) {
addToCurrent(sccMember);
if (currentSize() >= batchSize) {
flushBatch();
}
} else {
addToCurrent(sccMember);
do {
sccMember = removeLast();
addToCurrent(sccMember);
} while (currentId != sccMember);
if (currentSize() >= batchSize) {
flushBatch();
}
}
}
}
use of com.b2international.collections.longs.LongIterator in project snow-owl by b2ihealthcare.
the class EmptyLongListTest method iterator_overrun.
@Test(expected = NoSuchElementException.class)
public void iterator_overrun() {
LongList emptyList = LongCollections.emptyList();
LongIterator itr = emptyList.iterator();
itr.next();
}
use of com.b2international.collections.longs.LongIterator in project snow-owl by b2ihealthcare.
the class LongOpenHashSetTest method iterator_empty.
@Test
public void iterator_empty() {
LongSet longSet = PrimitiveSets.newLongOpenHashSet();
LongIterator itr = longSet.iterator();
assertFalse("Iterator should indicate that there are no elements.", itr.hasNext());
}
use of com.b2international.collections.longs.LongIterator in project snow-owl by b2ihealthcare.
the class LongOpenHashSetTest method iterator_overrun.
@Test(expected = NoSuchElementException.class)
public void iterator_overrun() {
LongSet longSet = PrimitiveSets.newLongOpenHashSet();
LongIterator itr = longSet.iterator();
itr.next();
}
Aggregations