com.annimon.stream.operator.ObjMapIndexed Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of stream Show documentation
Show all versions of stream Show documentation
Stream API from Java 8 rewritten on iterators for Java 7 and below
package com.annimon.stream.operator;
import com.annimon.stream.function.IndexedFunction;
import com.annimon.stream.iterator.IndexedIterator;
import com.annimon.stream.iterator.LsaIterator;
public class ObjMapIndexed extends LsaIterator {
private final IndexedIterator extends T> iterator;
private final IndexedFunction super T, ? extends R> mapper;
public ObjMapIndexed(IndexedIterator extends T> iterator, IndexedFunction super T, ? extends R> mapper) {
this.iterator = iterator;
this.mapper = mapper;
}
@Override
public boolean hasNext() {
return iterator.hasNext();
}
@Override
public R nextIteration() {
return mapper.apply(iterator.getIndex(), iterator.next());
}
}