Statistics
| Revision:

gvsig-tools / org.gvsig.tools / library / trunk / org.gvsig.tools / org.gvsig.tools.lib / src / main / java / org / gvsig / tools / util / ChainedIterator.java @ 1882

History | View | Annotate | Download (704 Bytes)

1
package org.gvsig.tools.util;
2

    
3
import java.util.Collections;
4
import java.util.Iterator;
5

    
6
public class ChainedIterator<T> implements Iterator<T> {
7

    
8
    private final Iterator<T>[] iterators;
9
    private int current;
10

    
11
    public ChainedIterator(Iterator<T>... iterators) {
12
        this.iterators = iterators;
13
        this.current = 0;
14
    }
15

    
16
    @Override
17
    public boolean hasNext() {
18
        while (this.current < this.iterators.length) {
19
            if (this.iterators[this.current].hasNext()) {
20
                return true;
21
            }
22
            this.current++;
23
        }
24
        return false;
25
    }
26

    
27
    @Override
28
    public T next() {
29
        return this.iterators[this.current].next();
30
    }
31
}