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;
}
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;
}
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)));
}
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);
}
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)));
}
Aggregations