Search in sources :

Example 1 with BooleanArrayList

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

the class BooleanArrayStack method peek.

@Override
public BooleanList peek(int count) {
    this.checkPositiveValueForCount(count);
    this.checkSizeLessThanCount(count);
    if (count == 0) {
        return new BooleanArrayList(0);
    }
    MutableBooleanList subList = new BooleanArrayList(count);
    int index = this.delegate.size() - 1;
    for (int i = 0; i < count; i++) {
        subList.add(this.delegate.get(index - i));
    }
    return subList;
}
Also used : BooleanArrayList(org.eclipse.collections.impl.list.mutable.primitive.BooleanArrayList) MutableBooleanList(org.eclipse.collections.api.list.primitive.MutableBooleanList)

Example 2 with BooleanArrayList

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

the class TreeSortedSet method collectBoolean.

@Override
public MutableBooleanList collectBoolean(BooleanFunction<? super T> booleanFunction) {
    BooleanArrayList result = new BooleanArrayList(this.size());
    this.forEach(new CollectBooleanProcedure<>(booleanFunction, result));
    return result;
}
Also used : BooleanArrayList(org.eclipse.collections.impl.list.mutable.primitive.BooleanArrayList)

Example 3 with BooleanArrayList

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

the class AbstractMutableBooleanCollectionTestCase method containsAllIterable.

@Override
@Test
public void containsAllIterable() {
    super.containsAllIterable();
    MutableBooleanCollection emptyCollection = this.newWith();
    Assert.assertTrue(emptyCollection.containsAll(new BooleanArrayList()));
    Assert.assertFalse(emptyCollection.containsAll(BooleanArrayList.newListWith(true)));
    Assert.assertFalse(emptyCollection.containsAll(BooleanArrayList.newListWith(false)));
    emptyCollection.add(false);
    Assert.assertFalse(emptyCollection.containsAll(BooleanArrayList.newListWith(true)));
    Assert.assertTrue(emptyCollection.containsAll(BooleanArrayList.newListWith(false)));
}
Also used : MutableBooleanCollection(org.eclipse.collections.api.collection.primitive.MutableBooleanCollection) BooleanArrayList(org.eclipse.collections.impl.list.mutable.primitive.BooleanArrayList) Test(org.junit.Test)

Example 4 with BooleanArrayList

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

the class AbstractMutableBooleanCollectionTestCase method removeAll_iterable.

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

Example 5 with BooleanArrayList

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

the class BooleanListsTest method immutables.

@Test
public void immutables() {
    ImmutableBooleanListFactory listFactory = BooleanLists.immutable;
    Assert.assertEquals(new BooleanArrayList(), listFactory.of());
    Verify.assertInstanceOf(ImmutableBooleanList.class, listFactory.of());
    Assert.assertEquals(BooleanArrayList.newListWith(true), listFactory.of(true));
    Verify.assertInstanceOf(ImmutableBooleanList.class, listFactory.of(true));
    Assert.assertEquals(BooleanArrayList.newListWith(true, false), listFactory.of(true, false));
    Verify.assertInstanceOf(ImmutableBooleanList.class, listFactory.of(true, false));
    Assert.assertEquals(BooleanArrayList.newListWith(true, false, true), listFactory.of(true, false, true));
    Verify.assertInstanceOf(ImmutableBooleanList.class, listFactory.of(true, false, true));
    Assert.assertEquals(BooleanArrayList.newListWith(true, false, true, false), listFactory.of(true, false, true, false));
    Verify.assertInstanceOf(ImmutableBooleanList.class, listFactory.of(true, false, true, false));
    Assert.assertEquals(BooleanArrayList.newListWith(true, false, true, false, true), listFactory.of(true, false, true, false, true));
    Verify.assertInstanceOf(ImmutableBooleanList.class, listFactory.of(true, false, true, false, true));
    Assert.assertEquals(BooleanArrayList.newListWith(true, false, true, false, true, false), listFactory.of(true, false, true, false, true, false));
    Verify.assertInstanceOf(ImmutableBooleanList.class, listFactory.of(true, false, true, false, true, false));
    Assert.assertEquals(BooleanArrayList.newListWith(true, false, true, false, true, false, true), listFactory.of(true, false, true, false, true, false, true));
    Verify.assertInstanceOf(ImmutableBooleanList.class, listFactory.of(true, false, true, false, true, false, true));
    Assert.assertEquals(BooleanArrayList.newListWith(true, false, true, false, true, false, true, true), listFactory.of(true, false, true, false, true, false, true, true));
    Verify.assertInstanceOf(ImmutableBooleanList.class, listFactory.of(true, false, true, false, true, false, true, true));
    Assert.assertEquals(BooleanArrayList.newListWith(true, false, true, false, true, false, true, true, true), listFactory.of(true, false, true, false, true, false, true, true, true));
    Verify.assertInstanceOf(ImmutableBooleanList.class, listFactory.of(true, false, true, false, true, false, true, true, true));
    Assert.assertEquals(BooleanArrayList.newListWith(true, false, true, false, true, false, true, true, true, false), listFactory.of(true, false, true, false, true, false, true, true, true, false));
    Verify.assertInstanceOf(ImmutableBooleanList.class, listFactory.of(true, false, true, false, true, false, true, true, true, false));
    Assert.assertEquals(BooleanArrayList.newListWith(true, false, true), listFactory.ofAll(BooleanArrayList.newListWith(true, false, true)));
    Verify.assertInstanceOf(ImmutableBooleanList.class, listFactory.ofAll(BooleanArrayList.newListWith(true, false, true)));
}
Also used : BooleanArrayList(org.eclipse.collections.impl.list.mutable.primitive.BooleanArrayList) ImmutableBooleanListFactory(org.eclipse.collections.api.factory.list.primitive.ImmutableBooleanListFactory) 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