All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.jnape.palatable.lambda.iterators.MappingIterator Maven / Gradle / Ivy

There is a newer version: 5.5.0
Show newest version
package com.jnape.palatable.lambda.iterators;

import java.util.Iterator;
import java.util.function.Function;

public class MappingIterator extends ImmutableIterator {

    private final Function function;
    private final Iterator                      iterator;

    public MappingIterator(Function function, Iterator iterator) {
        this.function = function;
        this.iterator = iterator;
    }

    @Override
    public boolean hasNext() {
        return iterator.hasNext();
    }

    @Override
    public B next() {
        return function.apply(iterator.next());
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy