blob: 742a73ba5d23aa535addf0e6819ce9fbda932e65 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
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;
}
public boolean hasNext() {
return source.hasNext();
}
public PostType next() {
return transform.apply(source.next());
}
}
|