blob: 80de96f90bcaae735b7441984e72af263a351b19 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
package bjc.utils.data;
import java.util.Iterator;
import java.util.function.Function;
public class TransformedIterator<PreType, PostType> implements Iterator<PostType> {
private Iterator<PreType> source;
private Function<PreType, PostType> transform;
public TransformedIterator(Iterator<PreType> src, Function<PreType, PostType> trans) {
source = src;
trans = transform;
}
@Override
public boolean hasNext() {
return source.hasNext();
}
@Override
public PostType next() {
return transform.apply(source.next());
}
}
|