com.iodesystems.fn.aspects.SizedIterables Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of fn Show documentation
Show all versions of fn Show documentation
Fn is a lazy Java Library that helps utilize some rudimentary functional concepts with more nounular
objects
package com.iodesystems.fn.aspects;
import com.iodesystems.fn.data.From;
import com.iodesystems.fn.data.From2;
import java.util.Iterator;
public class SizedIterables {
public static Iterable of(
A source, From getSize, From2 getItem) {
return new Iterable() {
@Override
public Iterator iterator() {
return new Iterator() {
final int size = getSize.from(source);
int index = 0;
@Override
public boolean hasNext() {
return index < size;
}
@Override
public B next() {
return getItem.from(source, index++);
}
};
}
};
}
}