Search in sources :

Example 21 with BooleanHashBag

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

the class ImmutableObjectBooleanSingletonMapTest method reject.

@Override
@Test
public void reject() {
    Assert.assertEquals(this.classUnderTest(), this.classUnderTest().reject((object1, value3) -> false));
    Assert.assertEquals(this.getEmptyMap(), this.classUnderTest().reject((object, value2) -> true));
    Assert.assertEquals(new BooleanHashBag(), this.classUnderTest().reject(value1 -> true).toBag());
    Assert.assertEquals(BooleanHashBag.newBagWith(true), this.classUnderTest().reject(value -> false).toBag());
}
Also used : 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) ObjectBooleanHashMap(org.eclipse.collections.impl.map.mutable.primitive.ObjectBooleanHashMap) 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 22 with BooleanHashBag

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

the class AbstractMutableBooleanCollectionTestCase method retainAll.

@Test
public void retainAll() {
    MutableBooleanCollection collection = this.classUnderTest();
    Assert.assertFalse(collection.retainAll(this.newMutableCollectionWith(true, false)));
    Assert.assertTrue(collection.retainAll(this.newMutableCollectionWith(true)));
    Assert.assertEquals(this.newMutableCollectionWith(true, true), collection);
    Assert.assertTrue(collection.retainAll(this.newMutableCollectionWith(false, false)));
    Assert.assertEquals(this.newMutableCollectionWith(), collection);
    MutableBooleanCollection list = this.classUnderTest();
    Assert.assertFalse(list.retainAll(BooleanArrayList.newListWith(false, false, true)));
    MutableBooleanCollection booleanArrayList = this.newWith(false, false);
    Assert.assertFalse(booleanArrayList.retainAll(new BooleanArrayList(false)));
    Assert.assertEquals(this.newMutableCollectionWith(false, false), booleanArrayList);
    Assert.assertTrue(booleanArrayList.retainAll(new BooleanArrayList(true)));
    Assert.assertEquals(this.newMutableCollectionWith(), booleanArrayList);
    Assert.assertTrue(list.retainAll(new BooleanArrayList(false)));
    Assert.assertEquals(this.newMutableCollectionWith(false), list);
    Assert.assertTrue(list.retainAll(new BooleanArrayList()));
    Assert.assertEquals(this.newMutableCollectionWith(), list);
    Assert.assertFalse(list.retainAll(BooleanArrayList.newListWith(true, false)));
    Assert.assertEquals(this.newMutableCollectionWith(), list);
    MutableBooleanCollection list1 = this.newWith(true, false, true, true);
    Assert.assertFalse(list1.retainAll(BooleanArrayList.newListWith(false, false, true)));
    Assert.assertTrue(list1.retainAll(BooleanArrayList.newListWith(false, false)));
    Verify.assertSize(1, list1);
    Assert.assertFalse(list1.contains(true));
    Assert.assertEquals(this.newMutableCollectionWith(false), list1);
    Assert.assertTrue(list1.retainAll(BooleanArrayList.newListWith(true, true)));
    Assert.assertEquals(this.newMutableCollectionWith(), list1);
    MutableBooleanCollection list2 = this.newWith(true, false, true, false, true);
    Assert.assertTrue(list2.retainAll(new BooleanHashBag()));
    Assert.assertEquals(this.newMutableCollectionWith(), list2);
}
Also used : MutableBooleanCollection(org.eclipse.collections.api.collection.primitive.MutableBooleanCollection) BooleanArrayList(org.eclipse.collections.impl.list.mutable.primitive.BooleanArrayList) BooleanHashBag(org.eclipse.collections.impl.bag.mutable.primitive.BooleanHashBag) Test(org.junit.Test)

Example 23 with BooleanHashBag

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

the class ImmutableEmptySortedBagTest method collectBoolean_target.

@Override
@Test
public void collectBoolean_target() {
    ImmutableSortedBag<Integer> bag = this.classUnderTest();
    Assert.assertEquals(new BooleanArrayList(), bag.collectBoolean(each -> false, new BooleanArrayList()));
    ImmutableSortedBag<Integer> bag2 = this.classUnderTest();
    Assert.assertEquals(new BooleanHashBag(), bag2.collectBoolean(each -> false, new BooleanHashBag()));
}
Also used : Maps(org.eclipse.collections.impl.factory.Maps) CharHashBag(org.eclipse.collections.impl.bag.mutable.primitive.CharHashBag) SortedBags(org.eclipse.collections.impl.factory.SortedBags) ObjectIntPair(org.eclipse.collections.api.tuple.primitive.ObjectIntPair) Verify(org.eclipse.collections.impl.test.Verify) MutableList(org.eclipse.collections.api.list.MutableList) MutableSortedMap(org.eclipse.collections.api.map.sorted.MutableSortedMap) ImmutableSortedSet(org.eclipse.collections.api.set.sorted.ImmutableSortedSet) DoubleArrayList(org.eclipse.collections.impl.list.mutable.primitive.DoubleArrayList) HashBag(org.eclipse.collections.impl.bag.mutable.HashBag) Functions(org.eclipse.collections.impl.block.factory.Functions) ShortArrayList(org.eclipse.collections.impl.list.mutable.primitive.ShortArrayList) ShortHashBag(org.eclipse.collections.impl.bag.mutable.primitive.ShortHashBag) Comparators(org.eclipse.collections.impl.block.factory.Comparators) SortedMaps(org.eclipse.collections.impl.factory.SortedMaps) DoubleHashBag(org.eclipse.collections.impl.bag.mutable.primitive.DoubleHashBag) IntArrayList(org.eclipse.collections.impl.list.mutable.primitive.IntArrayList) UnifiedMap(org.eclipse.collections.impl.map.mutable.UnifiedMap) ByteArrayList(org.eclipse.collections.impl.list.mutable.primitive.ByteArrayList) ByteHashBag(org.eclipse.collections.impl.bag.mutable.primitive.ByteHashBag) CharArrayList(org.eclipse.collections.impl.list.mutable.primitive.CharArrayList) BooleanHashBag(org.eclipse.collections.impl.bag.mutable.primitive.BooleanHashBag) FloatArrayList(org.eclipse.collections.impl.list.mutable.primitive.FloatArrayList) MutableSortedSet(org.eclipse.collections.api.set.sorted.MutableSortedSet) Lists(org.eclipse.collections.impl.factory.Lists) PartitionSortedBag(org.eclipse.collections.api.partition.bag.sorted.PartitionSortedBag) LongArrayList(org.eclipse.collections.impl.list.mutable.primitive.LongArrayList) ImmutableSortedBag(org.eclipse.collections.api.bag.sorted.ImmutableSortedBag) Stacks(org.eclipse.collections.impl.factory.Stacks) LongHashBag(org.eclipse.collections.impl.bag.mutable.primitive.LongHashBag) FastList(org.eclipse.collections.impl.list.mutable.FastList) Iterables(org.eclipse.collections.impl.factory.Iterables) BooleanArrayList(org.eclipse.collections.impl.list.mutable.primitive.BooleanArrayList) TreeBag(org.eclipse.collections.impl.bag.sorted.mutable.TreeBag) PrimitiveTuples(org.eclipse.collections.impl.tuple.primitive.PrimitiveTuples) NoSuchElementException(java.util.NoSuchElementException) Pair(org.eclipse.collections.api.tuple.Pair) MutableCollection(org.eclipse.collections.api.collection.MutableCollection) PrimitiveFunctions(org.eclipse.collections.impl.block.factory.PrimitiveFunctions) Predicates(org.eclipse.collections.impl.block.factory.Predicates) Predicates2(org.eclipse.collections.impl.block.factory.Predicates2) SortedSets(org.eclipse.collections.impl.factory.SortedSets) TreeSortedMap(org.eclipse.collections.impl.map.sorted.mutable.TreeSortedMap) Test(org.junit.Test) PartitionImmutableSortedBag(org.eclipse.collections.api.partition.bag.sorted.PartitionImmutableSortedBag) ImmutableList(org.eclipse.collections.api.list.ImmutableList) Comparator(java.util.Comparator) FloatHashBag(org.eclipse.collections.impl.bag.mutable.primitive.FloatHashBag) Assert(org.junit.Assert) Collections(java.util.Collections) IntHashBag(org.eclipse.collections.impl.bag.mutable.primitive.IntHashBag) BooleanArrayList(org.eclipse.collections.impl.list.mutable.primitive.BooleanArrayList) 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