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