fj.data.Seq Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of functionaljava Show documentation
Show all versions of functionaljava Show documentation
Functional Java is an open source library that supports closures for the Java programming language
package fj.data;
import fj.*;
import static fj.Bottom.error;
import static fj.Monoid.intAdditionMonoid;
import static fj.data.fingertrees.FingerTree.measured;
import fj.data.List.Buffer;
import fj.data.fingertrees.FingerTree;
import fj.data.fingertrees.MakeTree;
import fj.data.fingertrees.Measured;
import java.util.AbstractList;
import java.util.Iterator;
import java.util.NoSuchElementException;
/**
* Provides an immutable finite sequence, implemented as a finger tree. This structure gives O(1) access to
* the head and tail, as well as O(log n) random access and concatenation of sequences.
*/
public final class Seq implements Iterable {
private static final Measured ELEM_MEASURED = measured(intAdditionMonoid, Function.constant(1));
private static final MakeTree MK_TREE = FingerTree.mkTree(ELEM_MEASURED);
private static final Seq