Search in sources :

Example 16 with LongIterable

use of org.eclipse.collections.api.LongIterable in project mapdb by jankotek.

the class LongLongHashMapValuesTest method reject.

@Override
@Test
public void reject() {
    LongIterable iterable = this.classUnderTest();
    Verify.assertSize(0, iterable.reject(LongPredicates.lessThan(4L)));
    Verify.assertSize(1, iterable.reject(LongPredicates.lessThan(3L)));
}
Also used : LongIterable(org.eclipse.collections.api.LongIterable) Test(org.junit.Test)

Example 17 with LongIterable

use of org.eclipse.collections.api.LongIterable in project mapdb by jankotek.

the class LongLongHashMapValuesTest method appendString.

@Override
@Test
public void appendString() {
    StringBuilder appendable = new StringBuilder();
    this.newWith().appendString(appendable);
    Assert.assertEquals("", appendable.toString());
    this.newWith().appendString(appendable, "/");
    Assert.assertEquals("", appendable.toString());
    this.newWith().appendString(appendable, "[", ", ", "]");
    Assert.assertEquals("[]", appendable.toString());
    StringBuilder appendable1 = new StringBuilder();
    this.newWith(1L).appendString(appendable1);
    Assert.assertEquals("1", appendable1.toString());
    StringBuilder appendable2 = new StringBuilder();
    LongIterable iterable = this.newWith(1L, 2L);
    iterable.appendString(appendable2);
    Assert.assertTrue("1, 2".equals(appendable2.toString()) || "2, 1".equals(appendable2.toString()));
    StringBuilder appendable3 = new StringBuilder();
    iterable.appendString(appendable3, "/");
    Assert.assertTrue("1/2".equals(appendable3.toString()) || "2/1".equals(appendable3.toString()));
    StringBuilder appendable5 = new StringBuilder();
    this.newWith(31L).appendString(appendable5);
    Assert.assertEquals("31", appendable5.toString());
    StringBuilder appendable6 = new StringBuilder();
    this.newWith(32L).appendString(appendable6);
    Assert.assertEquals("32", appendable6.toString());
    StringBuilder appendable7 = new StringBuilder();
    LongIterable iterable1 = this.newWith(0L, 31L);
    iterable1.appendString(appendable7);
    Assert.assertTrue(appendable7.toString(), "0, 31".equals(appendable7.toString()) || "31, 0".equals(appendable7.toString()));
    StringBuilder appendable8 = new StringBuilder();
    LongIterable iterable2 = this.newWith(31L, 32L);
    iterable2.appendString(appendable8, "/");
    Assert.assertTrue(appendable8.toString(), "31/32".equals(appendable8.toString()) || "32/31".equals(appendable8.toString()));
    StringBuilder appendable9 = new StringBuilder();
    LongIterable iterable4 = this.newWith(32L, 33L);
    iterable4.appendString(appendable9, "[", "/", "]");
    Assert.assertTrue(appendable9.toString(), "[32/33]".equals(appendable9.toString()) || "[33/32]".equals(appendable9.toString()));
    StringBuilder appendable10 = new StringBuilder();
    LongIterable iterable5 = this.newWith(0L, 1L);
    iterable5.appendString(appendable10);
    Assert.assertTrue(appendable10.toString(), "0, 1".equals(appendable10.toString()) || "1, 0".equals(appendable10.toString()));
    StringBuilder appendable11 = new StringBuilder();
    iterable5.appendString(appendable11, "/");
    Assert.assertTrue(appendable11.toString(), "0/1".equals(appendable11.toString()) || "1/0".equals(appendable11.toString()));
    StringBuilder appendable12 = new StringBuilder();
    iterable5.appendString(appendable12, "[", "/", "]");
    Assert.assertTrue(appendable12.toString(), "[0/1]".equals(appendable12.toString()) || "[1/0]".equals(appendable12.toString()));
}
Also used : LongIterable(org.eclipse.collections.api.LongIterable) Test(org.junit.Test)

Example 18 with LongIterable

use of org.eclipse.collections.api.LongIterable in project mapdb by jankotek.

the class LongLongHashMapValuesTest method collect.

@Override
@Test
public void collect() {
    LongToObjectFunction<Long> function = (long parameter) -> parameter - 1;
    Assert.assertEquals(this.newObjectCollectionWith(0L, 1L, 2L).toBag(), this.newWith(1L, 2L, 3L).collect(function).toBag());
    LongIterable iterable = this.newWith(1L, 2L, 3L);
    Assert.assertEquals(this.newObjectCollectionWith(0L, 1L, 2L).toBag(), iterable.collect(function).toBag());
    Assert.assertArrayEquals(this.newObjectCollectionWith().toArray(), this.newWith().collect(function).toArray());
    Assert.assertArrayEquals(this.newObjectCollectionWith(2L).toArray(), this.newWith(3L).collect(function).toArray());
}
Also used : LongIterable(org.eclipse.collections.api.LongIterable) Test(org.junit.Test)

Example 19 with LongIterable

use of org.eclipse.collections.api.LongIterable in project mapdb by jankotek.

the class LongLongHashMapValuesTest method makeString.

@Override
@Test
public void makeString() {
    Assert.assertEquals("1", this.newWith(1L).makeString("/"));
    Assert.assertEquals("31", this.newWith(31L).makeString());
    Assert.assertEquals("32", this.newWith(32L).makeString());
    Assert.assertEquals("", this.newWith().makeString());
    Assert.assertEquals("", this.newWith().makeString("/"));
    Assert.assertEquals("[]", this.newWith().makeString("[", ", ", "]"));
    LongIterable iterable1 = this.newWith(0L, 31L);
    Assert.assertTrue(iterable1.makeString(), iterable1.makeString().equals("0, 31") || iterable1.makeString().equals("31, 0"));
    LongIterable iterable2 = this.newWith(31L, 32L);
    Assert.assertTrue(iterable2.makeString("[", "/", "]"), iterable2.makeString("[", "/", "]").equals("[31/32]") || iterable2.makeString("[", "/", "]").equals("[32/31]"));
    LongIterable iterable3 = this.newWith(32L, 33L);
    Assert.assertTrue(iterable3.makeString("/"), iterable3.makeString("/").equals("32/33") || iterable3.makeString("/").equals("33/32"));
    LongIterable iterable4 = this.newWith(1L, 2L);
    Assert.assertTrue("1, 2".equals(iterable4.makeString()) || "2, 1".equals(iterable4.makeString()));
    Assert.assertTrue("1/2".equals(iterable4.makeString("/")) || "2/1".equals(iterable4.makeString("/")));
    Assert.assertTrue("[1/2]".equals(iterable4.makeString("[", "/", "]")) || "[2/1]".equals(iterable4.makeString("[", "/", "]")));
    LongIterable iterable5 = this.newWith(0L, 1L);
    Assert.assertTrue(iterable5.makeString(), iterable5.makeString().equals("0, 1") || iterable5.makeString().equals("1, 0"));
    Assert.assertTrue(iterable5.makeString("[", "/", "]"), iterable5.makeString("[", "/", "]").equals("[0/1]") || iterable5.makeString("[", "/", "]").equals("[1/0]"));
    Assert.assertTrue(iterable5.makeString("/"), iterable5.makeString("/").equals("0/1") || iterable5.makeString("/").equals("1/0"));
}
Also used : LongIterable(org.eclipse.collections.api.LongIterable) Test(org.junit.Test)

Example 20 with LongIterable

use of org.eclipse.collections.api.LongIterable in project mapdb by jankotek.

the class AbstractLongLongMapTestCase method reject_value.

@Test
public void reject_value() {
    LongLongMap map = this.newWithKeysValues(0L, 0L, 1L, 1L, 2L, 2L, 3L, 3L);
    LongIterable actual1 = map.reject(LongPredicates.lessThan(2L));
    Assert.assertEquals(LongBags.immutable.with(2L, 3L), actual1);
    LongIterable actual2 = map.reject(LongPredicates.greaterThan(1L));
    Assert.assertEquals(LongBags.immutable.with(0L, 1L), actual2);
}
Also used : LazyLongIterable(org.eclipse.collections.api.LazyLongIterable) LongIterable(org.eclipse.collections.api.LongIterable) ImmutableLongLongMap(org.eclipse.collections.api.map.primitive.ImmutableLongLongMap) LongLongMap(org.eclipse.collections.api.map.primitive.LongLongMap) Test(org.junit.Test)

Aggregations

LongIterable (org.eclipse.collections.api.LongIterable)29 Test (org.junit.Test)29 LazyLongIterable (org.eclipse.collections.api.LazyLongIterable)24 LongArrayList (org.eclipse.collections.impl.list.mutable.primitive.LongArrayList)6 LongIterator (org.eclipse.collections.api.iterator.LongIterator)5 Arrays (java.util.Arrays)4 NoSuchElementException (java.util.NoSuchElementException)4 RichIterable (org.eclipse.collections.api.RichIterable)4 LongToObjectFunction (org.eclipse.collections.api.block.function.primitive.LongToObjectFunction)4 LongHashBag (org.eclipse.collections.impl.bag.mutable.primitive.LongHashBag)4 LongPredicates (org.eclipse.collections.impl.block.factory.primitive.LongPredicates)4 LongHashSet (org.eclipse.collections.impl.set.mutable.primitive.LongHashSet)4 Verify (org.eclipse.collections.impl.test.Verify)4 Assert (org.junit.Assert)4 ImmutableLongLongMap (org.eclipse.collections.api.map.primitive.ImmutableLongLongMap)2 LongLongMap (org.eclipse.collections.api.map.primitive.LongLongMap)2