Search in sources :

Example 46 with BooleanArrayList

use of org.eclipse.collections.impl.list.mutable.primitive.BooleanArrayList 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 47 with BooleanArrayList

use of org.eclipse.collections.impl.list.mutable.primitive.BooleanArrayList in project eclipse-collections by eclipse.

the class AbstractMutableBooleanCollectionTestCase method addAllIterable.

@Test
public void addAllIterable() {
    MutableBooleanCollection collection = this.classUnderTest();
    Assert.assertFalse(collection.addAll(this.newMutableCollectionWith()));
    Assert.assertTrue(collection.addAll(this.newMutableCollectionWith(false, true, false)));
    Assert.assertEquals(this.newMutableCollectionWith(true, false, true, false, true, false), collection);
    Assert.assertTrue(collection.addAll(this.newMutableCollectionWith(true, false, true, false, true)));
    Assert.assertEquals(this.newMutableCollectionWith(true, false, true, false, true, false, true, false, true, false, true), collection);
    MutableBooleanCollection emptyCollection = this.newWith();
    Assert.assertTrue(emptyCollection.addAll(BooleanArrayList.newListWith(true, false, true, false, true)));
    Assert.assertFalse(emptyCollection.addAll(new BooleanArrayList()));
    Assert.assertEquals(this.newMutableCollectionWith(true, false, true, false, true), emptyCollection);
}
Also used : MutableBooleanCollection(org.eclipse.collections.api.collection.primitive.MutableBooleanCollection) BooleanArrayList(org.eclipse.collections.impl.list.mutable.primitive.BooleanArrayList) Test(org.junit.Test)

Example 48 with BooleanArrayList

use of org.eclipse.collections.impl.list.mutable.primitive.BooleanArrayList in project eclipse-collections by eclipse.

the class AbstractBooleanIterableTestCase method booleanIterator.

@Test
public void booleanIterator() {
    BooleanArrayList list = BooleanArrayList.newListWith(true, false, true);
    BooleanIterator iterator = this.classUnderTest().booleanIterator();
    for (int i = 0; i < 3; i++) {
        Assert.assertTrue(iterator.hasNext());
        Assert.assertTrue(list.remove(iterator.next()));
    }
    Verify.assertEmpty(list);
    Assert.assertFalse(iterator.hasNext());
}
Also used : BooleanArrayList(org.eclipse.collections.impl.list.mutable.primitive.BooleanArrayList) BooleanIterator(org.eclipse.collections.api.iterator.BooleanIterator) Test(org.junit.Test)

Example 49 with BooleanArrayList

use of org.eclipse.collections.impl.list.mutable.primitive.BooleanArrayList 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

BooleanArrayList (org.eclipse.collections.impl.list.mutable.primitive.BooleanArrayList)49 Test (org.junit.Test)35 MutableBooleanCollection (org.eclipse.collections.api.collection.primitive.MutableBooleanCollection)11 BooleanIterable (org.eclipse.collections.api.BooleanIterable)7 MutableBooleanList (org.eclipse.collections.api.list.primitive.MutableBooleanList)6 MutableBooleanSet (org.eclipse.collections.api.set.primitive.MutableBooleanSet)3 BooleanHashBag (org.eclipse.collections.impl.bag.mutable.primitive.BooleanHashBag)3 ByteArrayList (org.eclipse.collections.impl.list.mutable.primitive.ByteArrayList)3 CharArrayList (org.eclipse.collections.impl.list.mutable.primitive.CharArrayList)3 DoubleArrayList (org.eclipse.collections.impl.list.mutable.primitive.DoubleArrayList)3 FloatArrayList (org.eclipse.collections.impl.list.mutable.primitive.FloatArrayList)3 IntArrayList (org.eclipse.collections.impl.list.mutable.primitive.IntArrayList)3 LongArrayList (org.eclipse.collections.impl.list.mutable.primitive.LongArrayList)3 ShortArrayList (org.eclipse.collections.impl.list.mutable.primitive.ShortArrayList)3 ArrayList (java.util.ArrayList)2 Collections (java.util.Collections)2 Comparator (java.util.Comparator)2 NoSuchElementException (java.util.NoSuchElementException)2 ImmutableSortedBag (org.eclipse.collections.api.bag.sorted.ImmutableSortedBag)2 MutableCollection (org.eclipse.collections.api.collection.MutableCollection)2