Search in sources :

Example 11 with LongIterator

use of com.b2international.collections.longs.LongIterator in project snow-owl by b2ihealthcare.

the class LongTarjan method run.

public List<LongSet> run(final LongCollection ids) {
    for (final LongIterator itr = ids.iterator(); itr.hasNext(); ) /* empty */
    {
        final long currentId = itr.next();
        indexMap.put(currentId, -1);
    }
    for (final LongIterator itr = ids.iterator(); itr.hasNext(); ) /* empty */
    {
        final long currentId = itr.next();
        if (indexMap.get(currentId) == -1) {
            visit(currentId, ids);
        }
    }
    if (currentSize() > 0) {
        flushBatch();
    }
    return components;
}
Also used : LongIterator(com.b2international.collections.longs.LongIterator)

Example 12 with LongIterator

use of com.b2international.collections.longs.LongIterator in project snow-owl by b2ihealthcare.

the class LongOpenHashSetTest method iterator.

@Test
public void iterator() {
    LongSet longSet = PrimitiveSets.newLongOpenHashSet();
    longSet.add(0L);
    longSet.add(5L);
    longSet.add(10L);
    LongIterator itr = longSet.iterator();
    long[] values = new long[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.", 0L, values[0]);
    assertEquals("Iterator should return second element.", 5L, values[1]);
    assertEquals("Iterator should return third element.", 10L, values[2]);
}
Also used : LongSet(com.b2international.collections.longs.LongSet) LongIterator(com.b2international.collections.longs.LongIterator) Test(org.junit.Test)

Example 13 with LongIterator

use of com.b2international.collections.longs.LongIterator in project snow-owl by b2ihealthcare.

the class EmptyLongListTest method iterator_empty.

@Test
public void iterator_empty() {
    LongList emptyList = LongCollections.emptyList();
    LongIterator itr = emptyList.iterator();
    assertFalse("Iterator should indicate that there are no elements.", itr.hasNext());
}
Also used : LongList(com.b2international.collections.longs.LongList) LongIterator(com.b2international.collections.longs.LongIterator) Test(org.junit.Test)

Example 14 with LongIterator

use of com.b2international.collections.longs.LongIterator in project snow-owl by b2ihealthcare.

the class LongSets method toStringArray.

/**
 * Returns with an array containing all long values as a string.
 * @param collection the collection of primitive longs.
 * @return an array of strings.
 */
public static String[] toStringArray(final LongCollection collection) {
    checkNotNull(collection, "Long collection argument cannot be null.");
    final String[] ids = new String[collection.size()];
    int i = 0;
    for (final LongIterator iterator = collection.iterator(); iterator.hasNext(); ) /*nothing*/
    {
        ids[i++] = Long.toString(iterator.next());
    }
    return ids;
}
Also used : AbstractLongIterator(com.b2international.collections.longs.AbstractLongIterator) LongIterator(com.b2international.collections.longs.LongIterator)

Example 15 with LongIterator

use of com.b2international.collections.longs.LongIterator in project snow-owl by b2ihealthcare.

the class EquivalentConceptSetConverter method toResource.

@Override
protected EquivalentConceptSet toResource(final EquivalentConceptSetDocument entry) {
    final EquivalentConceptSet resource = new EquivalentConceptSet();
    resource.setClassificationId(entry.getClassificationId());
    resource.setUnsatisfiable(entry.isUnsatisfiable());
    final List<SnomedConcept> items = newArrayList();
    for (final LongIterator itr = entry.getConceptIds().iterator(); itr.hasNext(); ) /* empty */
    {
        items.add(new SnomedConcept(Long.toString(itr.next())));
    }
    final SnomedConcepts equivalentConcepts = new SnomedConcepts(items, null, items.size(), items.size());
    resource.setEquivalentConcepts(equivalentConcepts);
    return resource;
}
Also used : SnomedConcepts(com.b2international.snowowl.snomed.core.domain.SnomedConcepts) EquivalentConceptSet(com.b2international.snowowl.snomed.reasoner.domain.EquivalentConceptSet) SnomedConcept(com.b2international.snowowl.snomed.core.domain.SnomedConcept) LongIterator(com.b2international.collections.longs.LongIterator)

Aggregations

LongIterator (com.b2international.collections.longs.LongIterator)17 LongSet (com.b2international.collections.longs.LongSet)9 LongList (com.b2international.collections.longs.LongList)5 Test (org.junit.Test)5 PrimitiveMaps (com.b2international.collections.PrimitiveMaps)2 PrimitiveSets (com.b2international.collections.PrimitiveSets)2 AbstractLongIterator (com.b2international.collections.longs.AbstractLongIterator)2 LongCollection (com.b2international.collections.longs.LongCollection)2 LongKeyMap (com.b2international.collections.longs.LongKeyMap)2 LongSets (com.b2international.commons.collect.LongSets)2 Concepts (com.b2international.snowowl.snomed.common.SnomedConstants.Concepts)2 RelationshipValue (com.b2international.snowowl.snomed.core.domain.RelationshipValue)2 ConcreteDomainFragment (com.b2international.snowowl.snomed.datastore.ConcreteDomainFragment)2 StatementFragment (com.b2international.snowowl.snomed.datastore.StatementFragment)2 StatementFragmentWithDestination (com.b2international.snowowl.snomed.datastore.StatementFragmentWithDestination)2 StatementFragmentWithValue (com.b2international.snowowl.snomed.datastore.StatementFragmentWithValue)2 PropertyChain (com.b2international.snowowl.snomed.datastore.index.taxonomy.PropertyChain)2 ReasonerTaxonomy (com.b2international.snowowl.snomed.datastore.index.taxonomy.ReasonerTaxonomy)2 INormalFormGenerator (com.b2international.snowowl.snomed.reasoner.classification.INormalFormGenerator)2 ReasonerTaxonomyInferrer (com.b2international.snowowl.snomed.reasoner.classification.ReasonerTaxonomyInferrer)2