Search in sources :

Example 81 with Iterator

use of java.util.Iterator in project groovy-core by groovy.

the class NumberRangeTest method testReverseStepByOneWithClosure.

/**
     * Tests stepping through a reversed range by one with a closure.
     */
public void testReverseStepByOneWithClosure() {
    final List callLog = new ArrayList();
    final Closure closure = new RecordingClosure(callLog);
    final Range range = createRange(5, 1);
    range.step(1, closure);
    assertEquals("wrong number of calls to closure", 5, callLog.size());
    final Iterator iter = callLog.iterator();
    for (int i = 5; i >= 1; i--) {
        assertEquals("wrong argument passed to closure", createValue(i), iter.next());
    }
}
Also used : ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) List(java.util.List) ArrayList(java.util.ArrayList)

Example 82 with Iterator

use of java.util.Iterator in project groovy-core by groovy.

the class RangeTest method testIterator.

public void testIterator() {
    Range r = createRange(5, 11);
    int i = 5;
    for (Iterator it = r.iterator(); it.hasNext(); ) {
        assertEquals("equals to " + i, new Integer(i), (Integer) (it.next()));
        i++;
    }
    r = createRange(new BigDecimal("5.0"), new BigDecimal("11.0"));
    BigDecimal one = new BigDecimal("1.0");
    BigDecimal val = new BigDecimal("5.0");
    for (Iterator it = r.iterator(); it.hasNext(); ) {
        assertEquals("equals to " + val, val, (BigDecimal) (it.next()));
        val = val.add(one);
    }
}
Also used : Iterator(java.util.Iterator) BigDecimal(java.math.BigDecimal)

Example 83 with Iterator

use of java.util.Iterator in project groovy-core by groovy.

the class AntProjectPropertiesDelegate method putAll.

public synchronized void putAll(Map t) {
    Set keySet = t.keySet();
    for (Iterator iterator = keySet.iterator(); iterator.hasNext(); ) {
        Object key = iterator.next();
        Object value = t.get(key);
        put(key, value);
    }
}
Also used : Set(java.util.Set) Iterator(java.util.Iterator)

Example 84 with Iterator

use of java.util.Iterator in project groovy-core by groovy.

the class SpoofTaskContainer method execute.

public void execute() throws BuildException {
    spoof("begin SpoofTaskContainer execute");
    for (Iterator iter = tasks.iterator(); iter.hasNext(); ) {
        Task task = (Task) iter.next();
        task.perform();
    }
    spoof("end SpoofTaskContainer execute");
}
Also used : Task(org.apache.tools.ant.Task) Iterator(java.util.Iterator)

Example 85 with Iterator

use of java.util.Iterator in project groovy-core by groovy.

the class TupleListTest method testIterateOverList.

public void testIterateOverList() throws Exception {
    StringBuilder buffer = new StringBuilder();
    for (Iterator iter = InvokerHelper.asIterator(InvokerHelper.createList(new Object[] { "a", "b", "c" })); iter.hasNext(); ) {
        Object i = iter.next();
        buffer.append(i);
    }
    assertEquals("buffer", "abc", buffer.toString());
}
Also used : Iterator(java.util.Iterator)

Aggregations

Iterator (java.util.Iterator)8930 ArrayList (java.util.ArrayList)2267 Set (java.util.Set)1895 HashMap (java.util.HashMap)1828 Map (java.util.Map)1714 List (java.util.List)1622 HashSet (java.util.HashSet)1602 Test (org.junit.Test)624 IOException (java.io.IOException)524 Collection (java.util.Collection)377 Region (org.apache.geode.cache.Region)240 SSOException (com.iplanet.sso.SSOException)227 File (java.io.File)216 LinkedList (java.util.LinkedList)213 TreeSet (java.util.TreeSet)191 LinkedHashMap (java.util.LinkedHashMap)181 Entry (java.util.Map.Entry)174 SMSException (com.sun.identity.sm.SMSException)169 ListIterator (java.util.ListIterator)146 TreeMap (java.util.TreeMap)145