Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package cz.cvut.k36.pr2.hw.hw06.impl;
- import cz.cvut.k36.pr2.hw.hw06.Function;
- import cz.cvut.k36.pr2.hw.hw06.Pr2List;
- /**
- *
- * @author Lukas
- */
- public class MapView<Input, Output> extends View<Output> {
- final Pr2List<Input> source;
- final Function<Input, Output> function;
- public MapView(Pr2List<Input> source, Function<Input, Output> function) {
- this.source = source;
- this.function = function;
- }
- @Override
- public Output head() {
- return function.apply(source.head());
- }
- @Override
- public Pr2List<Output> tail() {
- return new MapView(source.tail(), function);
- }
- @Override
- public boolean isEmpty() {
- return source.isEmpty();
- }
- @Override
- public int size() {
- return source.size();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement