Search in sources :

Example 6 with MutableBooleanIterator

use of org.eclipse.collections.api.iterator.MutableBooleanIterator in project eclipse-collections by eclipse.

the class UnmodifiableBooleanBagTest method iterator_throws_on_invocation_of_remove_before_next.

@Override
@Test
public void iterator_throws_on_invocation_of_remove_before_next() {
    MutableBooleanIterator booleanIterator = this.classUnderTest().booleanIterator();
    Assert.assertTrue(booleanIterator.hasNext());
    Verify.assertThrows(UnsupportedOperationException.class, booleanIterator::remove);
}
Also used : MutableBooleanIterator(org.eclipse.collections.api.iterator.MutableBooleanIterator) Test(org.junit.Test)

Example 7 with MutableBooleanIterator

use of org.eclipse.collections.api.iterator.MutableBooleanIterator in project eclipse-collections by eclipse.

the class UnmodifiableBooleanListTest method booleanIterator_with_remove.

@Override
@Test
public void booleanIterator_with_remove() {
    MutableBooleanIterator booleanIterator = this.classUnderTest().booleanIterator();
    Assert.assertTrue(booleanIterator.hasNext());
    booleanIterator.next();
    Verify.assertThrows(UnsupportedOperationException.class, booleanIterator::remove);
}
Also used : MutableBooleanIterator(org.eclipse.collections.api.iterator.MutableBooleanIterator) Test(org.junit.Test)

Example 8 with MutableBooleanIterator

use of org.eclipse.collections.api.iterator.MutableBooleanIterator 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 9 with MutableBooleanIterator

use of org.eclipse.collections.api.iterator.MutableBooleanIterator in project eclipse-collections by eclipse.

the class AbstractMutableObjectBooleanMapTestCase method iterator_throws_on_consecutive_invocation_of_remove.

@Test
public void iterator_throws_on_consecutive_invocation_of_remove() {
    MutableObjectBooleanMap<String> map = this.classUnderTest();
    Verify.assertNotEmpty(map);
    MutableBooleanIterator booleanIterator = map.booleanIterator();
    Assert.assertTrue(booleanIterator.hasNext());
    booleanIterator.next();
    booleanIterator.remove();
    Verify.assertThrows(IllegalStateException.class, booleanIterator::remove);
}
Also used : MutableBooleanIterator(org.eclipse.collections.api.iterator.MutableBooleanIterator) Test(org.junit.Test)

Example 10 with MutableBooleanIterator

use of org.eclipse.collections.api.iterator.MutableBooleanIterator in project eclipse-collections by eclipse.

the class BooleanHashSetTest method booleanIterator_with_remove.

@Override
@Test
public void booleanIterator_with_remove() {
    super.booleanIterator_with_remove();
    BooleanHashSet falseSet = this.newWith(false);
    MutableBooleanIterator mutableBooleanIterator = falseSet.booleanIterator();
    Assert.assertTrue(mutableBooleanIterator.hasNext());
    Assert.assertFalse(mutableBooleanIterator.next());
    mutableBooleanIterator.remove();
    Verify.assertEmpty(falseSet);
    Verify.assertThrows(NoSuchElementException.class, mutableBooleanIterator::next);
    Verify.assertThrows(IllegalStateException.class, mutableBooleanIterator::remove);
    BooleanHashSet trueSet = this.newWith(true);
    mutableBooleanIterator = trueSet.booleanIterator();
    Assert.assertTrue(mutableBooleanIterator.hasNext());
    Assert.assertTrue(mutableBooleanIterator.next());
    mutableBooleanIterator.remove();
    Verify.assertEmpty(trueSet);
    Verify.assertThrows(NoSuchElementException.class, mutableBooleanIterator::next);
    Verify.assertThrows(IllegalStateException.class, mutableBooleanIterator::remove);
    BooleanHashSet emptySet = new BooleanHashSet();
    mutableBooleanIterator = emptySet.booleanIterator();
    Assert.assertFalse(mutableBooleanIterator.hasNext());
    Verify.assertEmpty(emptySet);
    Verify.assertThrows(NoSuchElementException.class, mutableBooleanIterator::next);
    Verify.assertThrows(IllegalStateException.class, mutableBooleanIterator::remove);
}
Also used : MutableBooleanIterator(org.eclipse.collections.api.iterator.MutableBooleanIterator) Test(org.junit.Test)

Aggregations

MutableBooleanIterator (org.eclipse.collections.api.iterator.MutableBooleanIterator)18 Test (org.junit.Test)18 MutableBooleanCollection (org.eclipse.collections.api.collection.primitive.MutableBooleanCollection)4 BooleanIterator (org.eclipse.collections.api.iterator.BooleanIterator)1 BooleanArrayList (org.eclipse.collections.impl.list.mutable.primitive.BooleanArrayList)1