blob: 848b6acd2b17358ca7c389235ab3fb17e2f5c4c4 (
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());
}
}
|