Search in sources :

Example 21 with MutableBooleanCollection

use of org.eclipse.collections.api.collection.primitive.MutableBooleanCollection in project eclipse-collections by eclipse.

the class ObjectBooleanHashMapValuesTestCase method booleanIterator.

@Override
@Test
public void booleanIterator() {
    MutableBooleanCollection bag = this.newWith(true, false, true, true);
    BooleanArrayList list = BooleanArrayList.newListWith(true, false, true, true);
    BooleanIterator iterator1 = bag.booleanIterator();
    for (int i = 0; i < 4; i++) {
        Assert.assertTrue(iterator1.hasNext());
        Assert.assertTrue(list.remove(iterator1.next()));
    }
    Verify.assertEmpty(list);
    Assert.assertFalse(iterator1.hasNext());
    Verify.assertThrows(NoSuchElementException.class, (Runnable) iterator1::next);
    ObjectBooleanHashMap<String> map2 = new ObjectBooleanHashMap<>();
    for (int each = 2; each < 100; each++) {
        map2.put(String.valueOf(each), each % 2 == 0);
    }
    MutableBooleanIterator iterator2 = map2.booleanIterator();
    while (iterator2.hasNext()) {
        iterator2.next();
        iterator2.remove();
    }
    Assert.assertTrue(map2.isEmpty());
}
Also used : MutableBooleanCollection(org.eclipse.collections.api.collection.primitive.MutableBooleanCollection) BooleanArrayList(org.eclipse.collections.impl.list.mutable.primitive.BooleanArrayList) MutableBooleanIterator(org.eclipse.collections.api.iterator.MutableBooleanIterator) BooleanIterator(org.eclipse.collections.api.iterator.BooleanIterator) MutableBooleanIterator(org.eclipse.collections.api.iterator.MutableBooleanIterator) Test(org.junit.Test)

Example 22 with MutableBooleanCollection

use of org.eclipse.collections.api.collection.primitive.MutableBooleanCollection in project eclipse-collections by eclipse.

the class ObjectBooleanHashMapValuesTestCase method clear.

@Override
@Test
public void clear() {
    MutableBooleanCollection emptyCollection = this.newWith();
    emptyCollection.clear();
    Verify.assertSize(0, emptyCollection);
    ObjectBooleanHashMap<Integer> map = ObjectBooleanHashMap.newWithKeysValues(1, true, 2, false, 3, true);
    MutableBooleanCollection collection = map.values();
    collection.clear();
    Verify.assertEmpty(collection);
    Verify.assertEmpty(map);
    Verify.assertSize(0, collection);
    Assert.assertFalse(collection.contains(true));
    Assert.assertFalse(collection.contains(false));
}
Also used : MutableBooleanCollection(org.eclipse.collections.api.collection.primitive.MutableBooleanCollection) Test(org.junit.Test)

Example 23 with MutableBooleanCollection

use of org.eclipse.collections.api.collection.primitive.MutableBooleanCollection in project eclipse-collections by eclipse.

the class ObjectBooleanHashMapValuesTestCase method contains.

@Override
@Test
public void contains() {
    MutableBooleanCollection collection = this.classUnderTest();
    Assert.assertTrue(collection.contains(true));
    Assert.assertTrue(collection.contains(false));
    Assert.assertTrue(collection.remove(false));
    Assert.assertFalse(collection.contains(false));
    Assert.assertTrue(collection.remove(true));
    Assert.assertFalse(collection.contains(false));
    Assert.assertTrue(collection.contains(true));
    Assert.assertTrue(collection.remove(true));
    Assert.assertFalse(collection.contains(false));
    Assert.assertFalse(collection.contains(true));
}
Also used : MutableBooleanCollection(org.eclipse.collections.api.collection.primitive.MutableBooleanCollection) Test(org.junit.Test)

Example 24 with MutableBooleanCollection

use of org.eclipse.collections.api.collection.primitive.MutableBooleanCollection in project eclipse-collections by eclipse.

the class ObjectBooleanHashMapValuesTestCase method remove.

@Override
@Test
public void remove() {
    ObjectBooleanHashMap<Integer> map = ObjectBooleanHashMap.newWithKeysValues(1, true, 2, false, 3, true);
    MutableBooleanCollection collection = map.values();
    Assert.assertTrue(collection.remove(false));
    Assert.assertFalse(collection.contains(false));
    Assert.assertTrue(collection.contains(true));
    Assert.assertFalse(map.contains(false));
    Assert.assertTrue(map.contains(true));
}
Also used : MutableBooleanCollection(org.eclipse.collections.api.collection.primitive.MutableBooleanCollection) Test(org.junit.Test)

Example 25 with MutableBooleanCollection

use of org.eclipse.collections.api.collection.primitive.MutableBooleanCollection in project eclipse-collections by eclipse.

the class AbstractImmutableBooleanListTestCase method newWithoutAll.

@Override
@Test
public void newWithoutAll() {
    ImmutableBooleanCollection immutableBooleanCollection = this.classUnderTest();
    MutableBooleanCollection mutableTrueCollection = this.getTrueCollection(immutableBooleanCollection);
    ImmutableBooleanCollection trueCollection = mutableTrueCollection.toImmutable();
    Assert.assertEquals(this.newMutableCollectionWith(), trueCollection.newWithoutAll(this.newMutableCollectionWith(true, false)));
    Assert.assertEquals(mutableTrueCollection, trueCollection);
    MutableBooleanList list = immutableBooleanCollection.toList();
    list.removeAll(true);
    Assert.assertEquals(list, immutableBooleanCollection.newWithoutAll(this.newMutableCollectionWith(true)));
    Assert.assertEquals(this.newMutableCollectionWith(), immutableBooleanCollection.newWithoutAll(this.newMutableCollectionWith(true, false)));
    ImmutableBooleanCollection collection = this.newWith(true, false, true, false, true);
    Assert.assertEquals(this.newMutableCollectionWith(false, false), collection.newWithoutAll(this.newMutableCollectionWith(true, true)));
    Assert.assertEquals(this.newMutableCollectionWith(), collection.newWithoutAll(this.newMutableCollectionWith(true, false)));
}
Also used : MutableBooleanCollection(org.eclipse.collections.api.collection.primitive.MutableBooleanCollection) MutableBooleanList(org.eclipse.collections.api.list.primitive.MutableBooleanList) ImmutableBooleanCollection(org.eclipse.collections.api.collection.primitive.ImmutableBooleanCollection) Test(org.junit.Test)

Aggregations

MutableBooleanCollection (org.eclipse.collections.api.collection.primitive.MutableBooleanCollection)45 Test (org.junit.Test)43 BooleanArrayList (org.eclipse.collections.impl.list.mutable.primitive.BooleanArrayList)11 MutableByteCollection (org.eclipse.collections.api.collection.primitive.MutableByteCollection)4 MutableCharCollection (org.eclipse.collections.api.collection.primitive.MutableCharCollection)4 MutableDoubleCollection (org.eclipse.collections.api.collection.primitive.MutableDoubleCollection)4 MutableFloatCollection (org.eclipse.collections.api.collection.primitive.MutableFloatCollection)4 MutableIntCollection (org.eclipse.collections.api.collection.primitive.MutableIntCollection)4 MutableLongCollection (org.eclipse.collections.api.collection.primitive.MutableLongCollection)4 MutableShortCollection (org.eclipse.collections.api.collection.primitive.MutableShortCollection)4 MutableBooleanIterator (org.eclipse.collections.api.iterator.MutableBooleanIterator)4 Optional (java.util.Optional)3 RichIterable (org.eclipse.collections.api.RichIterable)3 MutableCollection (org.eclipse.collections.api.collection.MutableCollection)3 MutableList (org.eclipse.collections.api.list.MutableList)3 Pair (org.eclipse.collections.api.tuple.Pair)3 Predicates2 (org.eclipse.collections.impl.block.factory.Predicates2)3 Lists (org.eclipse.collections.impl.factory.Lists)3 List (java.util.List)2 Map (java.util.Map)2