use of org.eclipse.collections.api.collection.primitive.MutableBooleanCollection in project eclipse-collections by eclipse.
the class ObjectBooleanHashMapValuesTestCase method retainAll_iterable.
@Override
@Test
public void retainAll_iterable() {
Assert.assertFalse(this.newWith().retainAll(new BooleanArrayList()));
ObjectBooleanHashMap<Integer> map = ObjectBooleanHashMap.newWithKeysValues(1, true, null, false);
MutableBooleanCollection collection = map.values();
Assert.assertFalse(collection.retainAll(BooleanArrayList.newListWith(false, true)));
Assert.assertTrue(collection.retainAll(BooleanArrayList.newListWith(true)));
Assert.assertFalse(collection.contains(false));
Assert.assertTrue(collection.contains(true));
Assert.assertFalse(map.contains(false));
Assert.assertTrue(map.contains(true));
Assert.assertTrue(collection.retainAll(BooleanArrayList.newListWith(false)));
Assert.assertTrue(collection.isEmpty());
Assert.assertFalse(collection.contains(true));
Assert.assertFalse(collection.contains(false));
Assert.assertFalse(map.contains(true));
Assert.assertFalse(map.contains(false));
Assert.assertTrue(map.isEmpty());
ObjectBooleanHashMap<Integer> map1 = ObjectBooleanHashMap.newWithKeysValues(1, true, null, false);
MutableBooleanCollection collection1 = map1.values();
Assert.assertTrue(collection1.retainAll(new BooleanArrayList()));
Assert.assertTrue(collection1.isEmpty());
Assert.assertFalse(collection1.contains(true));
Assert.assertFalse(collection.contains(false));
Assert.assertFalse(map1.contains(true));
Assert.assertFalse(map1.contains(false));
Assert.assertTrue(map1.isEmpty());
}
use of org.eclipse.collections.api.collection.primitive.MutableBooleanCollection in project eclipse-collections by eclipse.
the class RichIterableTestCase method RichIterable_collectPrimitive.
@Test
default void RichIterable_collectPrimitive() {
assertEquals(this.getExpectedBoolean(false, false, true, true, false, false), this.newWith(3, 3, 2, 2, 1, 1).collectBoolean(each -> each % 2 == 0));
{
MutableBooleanCollection target = this.newBooleanForTransform();
MutableBooleanCollection result = this.newWith(3, 3, 2, 2, 1, 1).collectBoolean(each -> each % 2 == 0, target);
assertEquals(this.newBooleanForTransform(false, false, true, true, false, false), result);
assertSame(target, result);
}
RichIterable<Integer> iterable = this.newWith(13, 13, 12, 12, 11, 11, 3, 3, 2, 2, 1, 1);
assertEquals(this.getExpectedByte((byte) 3, (byte) 3, (byte) 2, (byte) 2, (byte) 1, (byte) 1, (byte) 3, (byte) 3, (byte) 2, (byte) 2, (byte) 1, (byte) 1), iterable.collectByte(each -> (byte) (each % 10)));
{
MutableByteCollection target = this.newByteForTransform();
MutableByteCollection result = iterable.collectByte(each -> (byte) (each % 10), target);
assertEquals(this.newByteForTransform((byte) 3, (byte) 3, (byte) 2, (byte) 2, (byte) 1, (byte) 1, (byte) 3, (byte) 3, (byte) 2, (byte) 2, (byte) 1, (byte) 1), result);
assertSame(target, result);
}
assertEquals(this.getExpectedChar((char) 3, (char) 3, (char) 2, (char) 2, (char) 1, (char) 1, (char) 3, (char) 3, (char) 2, (char) 2, (char) 1, (char) 1), iterable.collectChar(each -> (char) (each % 10)));
{
MutableCharCollection target = this.newCharForTransform();
MutableCharCollection result = iterable.collectChar(each -> (char) (each % 10), target);
assertEquals(this.newCharForTransform((char) 3, (char) 3, (char) 2, (char) 2, (char) 1, (char) 1, (char) 3, (char) 3, (char) 2, (char) 2, (char) 1, (char) 1), result);
assertSame(target, result);
}
assertEquals(this.getExpectedDouble(3.0, 3.0, 2.0, 2.0, 1.0, 1.0, 3.0, 3.0, 2.0, 2.0, 1.0, 1.0), iterable.collectDouble(each -> (double) (each % 10)));
{
MutableDoubleCollection target = this.newDoubleForTransform();
MutableDoubleCollection result = iterable.collectDouble(each -> (double) (each % 10), target);
assertEquals(this.newDoubleForTransform(3.0, 3.0, 2.0, 2.0, 1.0, 1.0, 3.0, 3.0, 2.0, 2.0, 1.0, 1.0), result);
assertSame(target, result);
}
assertEquals(this.getExpectedFloat(3.0f, 3.0f, 2.0f, 2.0f, 1.0f, 1.0f, 3.0f, 3.0f, 2.0f, 2.0f, 1.0f, 1.0f), iterable.collectFloat(each -> (float) (each % 10)));
{
MutableFloatCollection target = this.newFloatForTransform();
MutableFloatCollection result = iterable.collectFloat(each -> (float) (each % 10), target);
assertEquals(this.newFloatForTransform(3.0f, 3.0f, 2.0f, 2.0f, 1.0f, 1.0f, 3.0f, 3.0f, 2.0f, 2.0f, 1.0f, 1.0f), result);
assertSame(target, result);
}
assertEquals(this.getExpectedInt(3, 3, 2, 2, 1, 1, 3, 3, 2, 2, 1, 1), iterable.collectInt(each -> each % 10));
{
MutableIntCollection target = this.newIntForTransform();
MutableIntCollection result = iterable.collectInt(each -> each % 10, target);
assertEquals(this.newIntForTransform(3, 3, 2, 2, 1, 1, 3, 3, 2, 2, 1, 1), result);
assertSame(target, result);
}
assertEquals(this.getExpectedLong(3, 3, 2, 2, 1, 1, 3, 3, 2, 2, 1, 1), iterable.collectLong(each -> each % 10));
{
MutableLongCollection target = this.newLongForTransform();
MutableLongCollection result = iterable.collectLong(each -> each % 10, target);
assertEquals(this.newLongForTransform(3, 3, 2, 2, 1, 1, 3, 3, 2, 2, 1, 1), result);
assertSame(target, result);
}
assertEquals(this.getExpectedShort((short) 3, (short) 3, (short) 2, (short) 2, (short) 1, (short) 1, (short) 3, (short) 3, (short) 2, (short) 2, (short) 1, (short) 1), iterable.collectShort(each -> (short) (each % 10)));
MutableShortCollection target = this.newShortForTransform();
MutableShortCollection result = iterable.collectShort(each -> (short) (each % 10), target);
assertEquals(this.newShortForTransform((short) 3, (short) 3, (short) 2, (short) 2, (short) 1, (short) 1, (short) 3, (short) 3, (short) 2, (short) 2, (short) 1, (short) 1), result);
assertSame(target, result);
}
use of org.eclipse.collections.api.collection.primitive.MutableBooleanCollection in project eclipse-collections by eclipse.
the class RichIterableUniqueTestCase method RichIterable_collectPrimitive.
@Override
@Test
default void RichIterable_collectPrimitive() {
assertEquals(this.getExpectedBoolean(false, true, false), this.newWith(3, 2, 1).collectBoolean(each -> each % 2 == 0));
{
MutableBooleanCollection target = this.newBooleanForTransform();
MutableBooleanCollection result = this.newWith(3, 2, 1).collectBoolean(each -> each % 2 == 0, target);
assertEquals(this.getExpectedBoolean(false, true, false), result);
assertSame(target, result);
}
RichIterable<Integer> iterable = this.newWith(13, 12, 11, 3, 2, 1);
assertEquals(this.getExpectedByte((byte) 3, (byte) 2, (byte) 1, (byte) 3, (byte) 2, (byte) 1), iterable.collectByte(each -> (byte) (each % 10)));
{
MutableByteCollection target = this.newByteForTransform();
MutableByteCollection result = iterable.collectByte(each -> (byte) (each % 10), target);
assertEquals(this.getExpectedByte((byte) 3, (byte) 2, (byte) 1, (byte) 3, (byte) 2, (byte) 1), result);
assertSame(target, result);
}
assertEquals(this.getExpectedChar((char) 3, (char) 2, (char) 1, (char) 3, (char) 2, (char) 1), iterable.collectChar(each -> (char) (each % 10)));
{
MutableCharCollection target = this.newCharForTransform();
MutableCharCollection result = iterable.collectChar(each -> (char) (each % 10), target);
assertEquals(this.getExpectedChar((char) 3, (char) 2, (char) 1, (char) 3, (char) 2, (char) 1), result);
assertSame(target, result);
}
assertEquals(this.getExpectedDouble(3.0, 2.0, 1.0, 3.0, 2.0, 1.0), iterable.collectDouble(each -> (double) (each % 10)));
{
MutableDoubleCollection target = this.newDoubleForTransform();
MutableDoubleCollection result = iterable.collectDouble(each -> (double) (each % 10), target);
assertEquals(this.getExpectedDouble(3.0, 2.0, 1.0, 3.0, 2.0, 1.0), result);
assertSame(target, result);
}
assertEquals(this.getExpectedFloat(3.0f, 2.0f, 1.0f, 3.0f, 2.0f, 1.0f), iterable.collectFloat(each -> (float) (each % 10)));
{
MutableFloatCollection target = this.newFloatForTransform();
MutableFloatCollection result = iterable.collectFloat(each -> (float) (each % 10), target);
assertEquals(this.getExpectedFloat(3.0f, 2.0f, 1.0f, 3.0f, 2.0f, 1.0f), result);
assertSame(target, result);
}
assertEquals(this.getExpectedInt(3, 2, 1, 3, 2, 1), iterable.collectInt(each -> each % 10));
{
MutableIntCollection target = this.newIntForTransform();
MutableIntCollection result = iterable.collectInt(each -> each % 10, target);
assertEquals(this.getExpectedInt(3, 2, 1, 3, 2, 1), result);
assertSame(target, result);
}
assertEquals(this.getExpectedLong(3, 2, 1, 3, 2, 1), iterable.collectLong(each -> each % 10));
{
MutableLongCollection target = this.newLongForTransform();
MutableLongCollection result = iterable.collectLong(each -> each % 10, target);
assertEquals(this.getExpectedLong(3, 2, 1, 3, 2, 1), result);
assertSame(target, result);
}
assertEquals(this.getExpectedShort((short) 3, (short) 2, (short) 1, (short) 3, (short) 2, (short) 1), iterable.collectShort(each -> (short) (each % 10)));
MutableShortCollection target = this.newShortForTransform();
MutableShortCollection result = iterable.collectShort(each -> (short) (each % 10), target);
assertEquals(this.getExpectedShort((short) 3, (short) 2, (short) 1, (short) 3, (short) 2, (short) 1), result);
assertSame(target, result);
}
use of org.eclipse.collections.api.collection.primitive.MutableBooleanCollection in project eclipse-collections by eclipse.
the class AbstractMutableBooleanCollectionTestCase method containsAllArray.
@Override
@Test
public void containsAllArray() {
super.containsAllArray();
MutableBooleanCollection emptyCollection = this.newWith();
Assert.assertFalse(emptyCollection.containsAll(true));
Assert.assertFalse(emptyCollection.containsAll(false));
Assert.assertFalse(emptyCollection.containsAll(false, true, false));
emptyCollection.add(false);
Assert.assertFalse(emptyCollection.containsAll(true));
Assert.assertTrue(emptyCollection.containsAll(false));
}
use of org.eclipse.collections.api.collection.primitive.MutableBooleanCollection in project eclipse-collections by eclipse.
the class AbstractMutableBooleanCollectionTestCase method addAllArray.
@Test
public void addAllArray() {
MutableBooleanCollection collection = this.classUnderTest();
Assert.assertFalse(collection.addAll());
Assert.assertTrue(collection.addAll(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);
}
Aggregations