Revision 2439
org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.lib/src/main/java/org/gvsig/tools/util/ChainedIterator.java | ||
---|---|---|
1 | 1 |
package org.gvsig.tools.util; |
2 | 2 |
|
3 | 3 |
import java.util.Iterator; |
4 |
import org.gvsig.tools.dispose.DisposableIterator; |
|
5 |
import org.gvsig.tools.dispose.DisposeUtils; |
|
4 | 6 |
|
5 |
public class ChainedIterator<T> implements Iterator<T> { |
|
7 |
public class ChainedIterator<T> implements DisposableIterator<T> {
|
|
6 | 8 |
|
7 |
private final Iterator<T>[] iterators;
|
|
9 |
private Iterator<T>[] iterators; |
|
8 | 10 |
private int current; |
9 | 11 |
|
10 | 12 |
public ChainedIterator(Iterator<T>... iterators) { |
... | ... | |
40 | 42 |
} |
41 | 43 |
return it.next(); |
42 | 44 |
} |
45 |
|
|
46 |
@Override |
|
47 |
public void remove() { |
|
48 |
Iterator<T> it = this.iterators[this.current]; |
|
49 |
if( it==null ) { |
|
50 |
return; |
|
51 |
} |
|
52 |
it.remove(); |
|
53 |
} |
|
54 |
|
|
55 |
@Override |
|
56 |
public void dispose() { |
|
57 |
if( this.iterators == null ) { |
|
58 |
return; |
|
59 |
} |
|
60 |
for (Iterator<T> iterator : iterators) { |
|
61 |
DisposeUtils.dispose(iterator); |
|
62 |
} |
|
63 |
this.iterators = null; |
|
64 |
this.current = -1; |
|
65 |
} |
|
66 |
|
|
67 |
public int getCurrent() { |
|
68 |
return current; |
|
69 |
} |
|
70 |
|
|
71 |
|
|
43 | 72 |
} |
Also available in: Unified diff