Search in sources :

Example 16 with BooleanHashBag

use of org.eclipse.collections.impl.bag.mutable.primitive.BooleanHashBag in project eclipse-collections by eclipse.

the class ImmutableBagTestCase method collectBooleanWithTarget.

@Override
@Test
public void collectBooleanWithTarget() {
    super.collectBooleanWithTarget();
    BooleanHashBag target = new BooleanHashBag();
    BooleanHashBag result = this.newBag().collectBoolean("4"::equals, target);
    Assert.assertSame("Target sent as parameter not returned", target, result);
    Assert.assertEquals(2, result.sizeDistinct());
    Assert.assertEquals(4, result.occurrencesOf(true));
    Assert.assertEquals(6, result.occurrencesOf(false));
}
Also used : BooleanHashBag(org.eclipse.collections.impl.bag.mutable.primitive.BooleanHashBag) Test(org.junit.Test)

Example 17 with BooleanHashBag

use of org.eclipse.collections.impl.bag.mutable.primitive.BooleanHashBag in project eclipse-collections by eclipse.

the class MapIterateTest method collectBooleanWithTarget.

@Test
public void collectBooleanWithTarget() {
    BooleanHashBag target = new BooleanHashBag();
    BooleanHashBag result = MapIterate.collectBoolean(MapIterateTest.newLittleMap(), PrimitiveFunctions.integerIsPositive(), target);
    Assert.assertEquals(BooleanHashBag.newBagWith(true, true), result.toBag());
    Assert.assertSame("Target sent as parameter was not returned as result", target, result);
}
Also used : BooleanHashBag(org.eclipse.collections.impl.bag.mutable.primitive.BooleanHashBag) Test(org.junit.Test)

Example 18 with BooleanHashBag

use of org.eclipse.collections.impl.bag.mutable.primitive.BooleanHashBag in project eclipse-collections by eclipse.

the class AbstractObjectBooleanMapTestCase method reject.

@Test
public void reject() {
    Assert.assertEquals(BooleanHashBag.newBagWith(false), this.classUnderTest().reject(BooleanPredicates.isTrue()).toBag());
    Assert.assertEquals(BooleanHashBag.newBagWith(true, true), this.classUnderTest().reject(BooleanPredicates.isFalse()).toBag());
    Assert.assertEquals(new BooleanHashBag(), this.classUnderTest().reject(BooleanPredicates.or(BooleanPredicates.isTrue(), BooleanPredicates.isFalse())).toBag());
    Assert.assertEquals(BooleanHashBag.newBagWith(true, true, false), this.classUnderTest().reject(BooleanPredicates.and(BooleanPredicates.isTrue(), BooleanPredicates.isFalse())).toBag());
    Assert.assertEquals(this.newWithKeysValues("1", true, "2", false), this.classUnderTest().reject((object, value) -> (Integer.parseInt(object) & 1) == 0 && value));
    Assert.assertEquals(this.newWithKeysValues("0", true, "1", true), this.classUnderTest().reject((object, value) -> (Integer.parseInt(object) & 1) == 0 && !value));
    Assert.assertEquals(this.newWithKeysValues("0", true, "1", true, "2", false), this.classUnderTest().reject((object, value) -> (Integer.parseInt(object) & 1) != 0 && !value));
}
Also used : Arrays(java.util.Arrays) UnifiedMap(org.eclipse.collections.impl.map.mutable.UnifiedMap) BooleanIterator(org.eclipse.collections.api.iterator.BooleanIterator) ObjectBooleanMap(org.eclipse.collections.api.map.primitive.ObjectBooleanMap) 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) ImmutableObjectBooleanMap(org.eclipse.collections.api.map.primitive.ImmutableObjectBooleanMap) FastList(org.eclipse.collections.impl.list.mutable.FastList) BooleanArrayList(org.eclipse.collections.impl.list.mutable.primitive.BooleanArrayList) NoSuchElementException(java.util.NoSuchElementException) Assert(org.junit.Assert) BooleanHashSet(org.eclipse.collections.impl.set.mutable.primitive.BooleanHashSet) BooleanHashBag(org.eclipse.collections.impl.bag.mutable.primitive.BooleanHashBag) Test(org.junit.Test)

Example 19 with BooleanHashBag

use of org.eclipse.collections.impl.bag.mutable.primitive.BooleanHashBag in project eclipse-collections by eclipse.

the class ImmutableObjectBooleanEmptyMapTest method select.

@Override
@Test
public void select() {
    Assert.assertEquals(this.classUnderTest(), this.classUnderTest().select((object, value1) -> true));
    Assert.assertEquals(new BooleanHashBag(), this.classUnderTest().select(value -> true).toBag());
}
Also used : ObjectBooleanHashMap(org.eclipse.collections.impl.map.mutable.primitive.ObjectBooleanHashMap) BooleanArrayList(org.eclipse.collections.impl.list.mutable.primitive.BooleanArrayList) BooleanIterator(org.eclipse.collections.api.iterator.BooleanIterator) ObjectBooleanMap(org.eclipse.collections.api.map.primitive.ObjectBooleanMap) BooleanHashBag(org.eclipse.collections.impl.bag.mutable.primitive.BooleanHashBag) Test(org.junit.Test) Verify(org.eclipse.collections.impl.test.Verify) NoSuchElementException(java.util.NoSuchElementException) ImmutableObjectBooleanMap(org.eclipse.collections.api.map.primitive.ImmutableObjectBooleanMap) Assert(org.junit.Assert) FastList(org.eclipse.collections.impl.list.mutable.FastList) BooleanHashSet(org.eclipse.collections.impl.set.mutable.primitive.BooleanHashSet) BooleanHashBag(org.eclipse.collections.impl.bag.mutable.primitive.BooleanHashBag) Test(org.junit.Test)

Example 20 with BooleanHashBag

use of org.eclipse.collections.impl.bag.mutable.primitive.BooleanHashBag in project eclipse-collections by eclipse.

the class ImmutableObjectBooleanEmptyMapTest method reject.

@Override
@Test
public void reject() {
    Assert.assertEquals(this.classUnderTest(), this.classUnderTest().reject((object, value1) -> false));
    Assert.assertEquals(new BooleanHashBag(), this.classUnderTest().reject(value -> false).toBag());
}
Also used : ObjectBooleanHashMap(org.eclipse.collections.impl.map.mutable.primitive.ObjectBooleanHashMap) BooleanArrayList(org.eclipse.collections.impl.list.mutable.primitive.BooleanArrayList) BooleanIterator(org.eclipse.collections.api.iterator.BooleanIterator) ObjectBooleanMap(org.eclipse.collections.api.map.primitive.ObjectBooleanMap) BooleanHashBag(org.eclipse.collections.impl.bag.mutable.primitive.BooleanHashBag) Test(org.junit.Test) Verify(org.eclipse.collections.impl.test.Verify) NoSuchElementException(java.util.NoSuchElementException) ImmutableObjectBooleanMap(org.eclipse.collections.api.map.primitive.ImmutableObjectBooleanMap) Assert(org.junit.Assert) FastList(org.eclipse.collections.impl.list.mutable.FastList) BooleanHashSet(org.eclipse.collections.impl.set.mutable.primitive.BooleanHashSet) BooleanHashBag(org.eclipse.collections.impl.bag.mutable.primitive.BooleanHashBag) Test(org.junit.Test)

Aggregations

BooleanHashBag (org.eclipse.collections.impl.bag.mutable.primitive.BooleanHashBag)23 Test (org.junit.Test)21 NoSuchElementException (java.util.NoSuchElementException)8 BooleanArrayList (org.eclipse.collections.impl.list.mutable.primitive.BooleanArrayList)8 Assert (org.junit.Assert)8 BooleanIterator (org.eclipse.collections.api.iterator.BooleanIterator)7 FastList (org.eclipse.collections.impl.list.mutable.FastList)7 Verify (org.eclipse.collections.impl.test.Verify)7 ImmutableObjectBooleanMap (org.eclipse.collections.api.map.primitive.ImmutableObjectBooleanMap)6 ObjectBooleanMap (org.eclipse.collections.api.map.primitive.ObjectBooleanMap)6 BooleanHashSet (org.eclipse.collections.impl.set.mutable.primitive.BooleanHashSet)6 BooleanPredicates (org.eclipse.collections.impl.block.factory.primitive.BooleanPredicates)4 UnifiedMap (org.eclipse.collections.impl.map.mutable.UnifiedMap)4 ObjectBooleanHashMap (org.eclipse.collections.impl.map.mutable.primitive.ObjectBooleanHashMap)3 Arrays (java.util.Arrays)2 MutableBooleanBag (org.eclipse.collections.api.bag.primitive.MutableBooleanBag)2 Collections (java.util.Collections)1 Comparator (java.util.Comparator)1 Iterator (java.util.Iterator)1 List (java.util.List)1