Search in sources :

Example 21 with LongSet

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

the class LongOpenHashSetTest method toArray.

@Test
public void toArray() {
    LongSet longSet = PrimitiveSets.newLongOpenHashSet();
    longSet.add(0L);
    longSet.add(5L);
    longSet.add(10L);
    long[] array = longSet.toArray();
    Arrays.sort(array);
    assertArrayEquals("Array should contain all stored elements.", new long[] { 0L, 5L, 10L }, array);
}
Also used : LongSet(com.b2international.collections.longs.LongSet) Test(org.junit.Test)

Example 22 with LongSet

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

the class LongOpenHashSetTest method create_zero_size_fill_factor.

@Test
public void create_zero_size_fill_factor() {
    LongSet longSet = PrimitiveSets.newLongOpenHashSetWithExpectedSize(0, 0.5d);
    assertTrue("Long set should be empty.", longSet.isEmpty());
}
Also used : LongSet(com.b2international.collections.longs.LongSet) Test(org.junit.Test)

Example 23 with LongSet

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

the class LongOpenHashSetTest method trimToSize.

@Test
public void trimToSize() {
    LongSet longSet = PrimitiveSets.newLongOpenHashSet();
    longSet.trimToSize();
}
Also used : LongSet(com.b2international.collections.longs.LongSet) Test(org.junit.Test)

Example 24 with LongSet

use of com.b2international.collections.longs.LongSet 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();
}
Also used : LongSet(com.b2international.collections.longs.LongSet) LongIterator(com.b2international.collections.longs.LongIterator) Test(org.junit.Test)

Example 25 with LongSet

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

the class LongTarjanTest method smallBatchSize.

@Test
public void smallBatchSize() throws Exception {
    final LongKeyLongMap followerMap = PrimitiveMaps.newLongKeyLongOpenHashMap();
    followerMap.put(1, 2);
    followerMap.put(2, 3);
    followerMap.put(3, 4);
    followerMap.put(4, 1);
    followerMap.put(5, 3);
    followerMap.put(6, 2);
    followerMap.put(7, 8);
    followerMap.put(8, 6);
    final LongTarjan tarjan = new LongTarjan(3, currentId -> LongCollections.singletonSet(followerMap.get(currentId)));
    final List<LongSet> actual = tarjan.run(followerMap.keySet());
    assertEquals(ImmutableList.of(PrimitiveSets.newLongOpenHashSet(1L, 2L, 3L, 4L), PrimitiveSets.newLongOpenHashSet(5L, 6L, 8L), PrimitiveSets.newLongOpenHashSet(7L)), actual);
}
Also used : LongSet(com.b2international.collections.longs.LongSet) LongKeyLongMap(com.b2international.collections.longs.LongKeyLongMap) LongTarjan(com.b2international.commons.graph.LongTarjan) Test(org.junit.Test)

Aggregations

LongSet (com.b2international.collections.longs.LongSet)63 Test (org.junit.Test)46 LongIterator (com.b2international.collections.longs.LongIterator)9 PrimitiveSets (com.b2international.collections.PrimitiveSets)3 LongList (com.b2international.collections.longs.LongList)3 Concepts (com.b2international.snowowl.snomed.common.SnomedConstants.Concepts)3 ImmutableList (com.google.common.collect.ImmutableList)3 Sets (com.google.common.collect.Sets)3 Collection (java.util.Collection)3 PrimitiveMaps (com.b2international.collections.PrimitiveMaps)2 IntIterator (com.b2international.collections.ints.IntIterator)2 LongKeyMap (com.b2international.collections.longs.LongKeyMap)2 LongSets (com.b2international.commons.collect.LongSets)2 CycleDetectedException (com.b2international.commons.exceptions.CycleDetectedException)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 List (java.util.List)2