Search in sources :

Example 1 with ObjectBooleanToObjectFunction

use of org.eclipse.collections.api.block.function.primitive.ObjectBooleanToObjectFunction in project eclipse-collections by eclipse.

the class AbstractBooleanSetTestCase method injectInto.

@Override
@Test
public void injectInto() {
    ObjectBooleanToObjectFunction<MutableInteger, MutableInteger> function = (object, value) -> object.add(value ? 1 : 0);
    Assert.assertEquals(new MutableInteger(1), BooleanHashSet.newSetWith(true, false, true).injectInto(new MutableInteger(0), function));
    Assert.assertEquals(new MutableInteger(1), BooleanHashSet.newSetWith(true).injectInto(new MutableInteger(0), function));
    Assert.assertEquals(new MutableInteger(0), BooleanHashSet.newSetWith(false).injectInto(new MutableInteger(0), function));
    Assert.assertEquals(new MutableInteger(0), new BooleanHashSet().injectInto(new MutableInteger(0), function));
}
Also used : BooleanToObjectFunction(org.eclipse.collections.api.block.function.primitive.BooleanToObjectFunction) Arrays(java.util.Arrays) BooleanIterator(org.eclipse.collections.api.iterator.BooleanIterator) BooleanHashBag(org.eclipse.collections.impl.bag.mutable.primitive.BooleanHashBag) Test(org.junit.Test) BooleanPredicates(org.eclipse.collections.impl.block.factory.primitive.BooleanPredicates) Verify(org.eclipse.collections.impl.test.Verify) MutableBooleanCollection(org.eclipse.collections.api.collection.primitive.MutableBooleanCollection) MutableSet(org.eclipse.collections.api.set.MutableSet) MutableBooleanSet(org.eclipse.collections.api.set.primitive.MutableBooleanSet) BooleanArrayList(org.eclipse.collections.impl.list.mutable.primitive.BooleanArrayList) ObjectBooleanToObjectFunction(org.eclipse.collections.api.block.function.primitive.ObjectBooleanToObjectFunction) AbstractMutableBooleanCollectionTestCase(org.eclipse.collections.impl.collection.mutable.primitive.AbstractMutableBooleanCollectionTestCase) NoSuchElementException(java.util.NoSuchElementException) LazyBooleanIterable(org.eclipse.collections.api.LazyBooleanIterable) Assert(org.junit.Assert) MutableInteger(org.eclipse.collections.impl.math.MutableInteger) UnifiedSet(org.eclipse.collections.impl.set.mutable.UnifiedSet) Before(org.junit.Before) MutableInteger(org.eclipse.collections.impl.math.MutableInteger) Test(org.junit.Test)

Example 2 with ObjectBooleanToObjectFunction

use of org.eclipse.collections.api.block.function.primitive.ObjectBooleanToObjectFunction in project eclipse-collections by eclipse.

the class ImmutableBooleanHashSetTest method injectInto.

@Override
@Test
public void injectInto() {
    ObjectBooleanToObjectFunction<MutableInteger, MutableInteger> function = (object, value) -> object.add(value ? 1 : 0);
    Assert.assertEquals(new MutableInteger(1), BooleanHashSet.newSetWith(true, false, true).injectInto(new MutableInteger(0), function));
    Assert.assertEquals(new MutableInteger(1), BooleanHashSet.newSetWith(true).injectInto(new MutableInteger(0), function));
    Assert.assertEquals(new MutableInteger(0), BooleanHashSet.newSetWith(false).injectInto(new MutableInteger(0), function));
    Assert.assertEquals(new MutableInteger(0), new BooleanHashSet().injectInto(new MutableInteger(0), function));
}
Also used : BooleanToObjectFunction(org.eclipse.collections.api.block.function.primitive.BooleanToObjectFunction) AbstractImmutableBooleanCollectionTestCase(org.eclipse.collections.impl.collection.immutable.primitive.AbstractImmutableBooleanCollectionTestCase) Arrays(java.util.Arrays) BooleanIterator(org.eclipse.collections.api.iterator.BooleanIterator) BooleanHashBag(org.eclipse.collections.impl.bag.mutable.primitive.BooleanHashBag) Test(org.junit.Test) ImmutableBooleanSet(org.eclipse.collections.api.set.primitive.ImmutableBooleanSet) BooleanPredicates(org.eclipse.collections.impl.block.factory.primitive.BooleanPredicates) Verify(org.eclipse.collections.impl.test.Verify) ImmutableBooleanCollection(org.eclipse.collections.api.collection.primitive.ImmutableBooleanCollection) MutableSet(org.eclipse.collections.api.set.MutableSet) MutableBooleanSet(org.eclipse.collections.api.set.primitive.MutableBooleanSet) BooleanArrayList(org.eclipse.collections.impl.list.mutable.primitive.BooleanArrayList) ObjectBooleanToObjectFunction(org.eclipse.collections.api.block.function.primitive.ObjectBooleanToObjectFunction) NoSuchElementException(java.util.NoSuchElementException) LazyBooleanIterable(org.eclipse.collections.api.LazyBooleanIterable) Assert(org.junit.Assert) MutableInteger(org.eclipse.collections.impl.math.MutableInteger) UnifiedSet(org.eclipse.collections.impl.set.mutable.UnifiedSet) Before(org.junit.Before) MutableInteger(org.eclipse.collections.impl.math.MutableInteger) Test(org.junit.Test)

Aggregations

Arrays (java.util.Arrays)2 NoSuchElementException (java.util.NoSuchElementException)2 LazyBooleanIterable (org.eclipse.collections.api.LazyBooleanIterable)2 BooleanToObjectFunction (org.eclipse.collections.api.block.function.primitive.BooleanToObjectFunction)2 ObjectBooleanToObjectFunction (org.eclipse.collections.api.block.function.primitive.ObjectBooleanToObjectFunction)2 BooleanIterator (org.eclipse.collections.api.iterator.BooleanIterator)2 MutableSet (org.eclipse.collections.api.set.MutableSet)2 MutableBooleanSet (org.eclipse.collections.api.set.primitive.MutableBooleanSet)2 BooleanHashBag (org.eclipse.collections.impl.bag.mutable.primitive.BooleanHashBag)2 BooleanPredicates (org.eclipse.collections.impl.block.factory.primitive.BooleanPredicates)2 BooleanArrayList (org.eclipse.collections.impl.list.mutable.primitive.BooleanArrayList)2 MutableInteger (org.eclipse.collections.impl.math.MutableInteger)2 UnifiedSet (org.eclipse.collections.impl.set.mutable.UnifiedSet)2 Verify (org.eclipse.collections.impl.test.Verify)2 Assert (org.junit.Assert)2 Before (org.junit.Before)2 Test (org.junit.Test)2 ImmutableBooleanCollection (org.eclipse.collections.api.collection.primitive.ImmutableBooleanCollection)1 MutableBooleanCollection (org.eclipse.collections.api.collection.primitive.MutableBooleanCollection)1 ImmutableBooleanSet (org.eclipse.collections.api.set.primitive.ImmutableBooleanSet)1