Package fj.data
Class DList<A>
- java.lang.Object
-
- fj.data.DList<A>
-
public final class DList<A> extends java.lang.Object
Difference List. It converts left associative appends into right associative ones to improve performance.- Version:
- %build.number%
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description DList<A>
append(DList<A> other)
Appends two DLists together to produce a new DList.static <A> DList<A>
arrayDList(A... as)
Creates a DList from an arrayDList<A>
cons(A a)
Prepends a single element on the DList to produce a new DList.static <A> DList<A>
dlist(F<List<A>,Trampoline<List<A>>> f)
Creates a DList from the function For alternatives functions to create a DList:static <A> DList<A>
iterableDList(java.lang.Iterable<A> it)
Creates a DList from an Iterablestatic <A> DList<A>
iteratorDList(java.util.Iterator<A> it)
Creates a DList from an Iteratorprivate static <A,B,C>
F<A,Trampoline<C>>kleisliTrampCompose(F<B,Trampoline<C>> bc, F<A,Trampoline<B>> ab)
static <A> DList<A>
listDList(List<A> a)
Creates a DList from a Liststatic <A> DList<A>
nil()
A empty DList.List<A>
run()
Concatenates all the internal Lists together that are held in the DList's lambda's state to produce a List.static <A> DList<A>
single(A a)
Produces a DList with one element.DList<A>
snoc(A a)
Appends a single element on the end of the DList to produce a new DList.java.util.List<A>
toJavaList()
Converts the DList to a standard java.util.List.
-
-
-
Method Detail
-
dlist
public static <A> DList<A> dlist(F<List<A>,Trampoline<List<A>>> f)
Creates a DList from the function For alternatives functions to create a DList:
-
iterableDList
public static <A> DList<A> iterableDList(java.lang.Iterable<A> it)
Creates a DList from an Iterable
-
iteratorDList
public static <A> DList<A> iteratorDList(java.util.Iterator<A> it)
Creates a DList from an Iterator
-
arrayDList
@SafeVarargs public static <A> DList<A> arrayDList(A... as)
Creates a DList from an array
-
run
public List<A> run()
Concatenates all the internal Lists together that are held in the DList's lambda's state to produce a List. This is what converts the appending operation from left associative to right associative, giving DList it's speed.- Returns:
- the final List
-
toJavaList
public java.util.List<A> toJavaList()
Converts the DList to a standard java.util.List.
-
nil
public static <A> DList<A> nil()
A empty DList.- Type Parameters:
A
-- Returns:
- a empty DList.
-
single
public static <A> DList<A> single(A a)
Produces a DList with one element.- Type Parameters:
A
-- Parameters:
a
- the element in the DList.- Returns:
- a DList with one element.
-
cons
public DList<A> cons(A a)
Prepends a single element on the DList to produce a new DList.- Parameters:
a
- the element to append.- Returns:
- the new DList.
-
snoc
public DList<A> snoc(A a)
Appends a single element on the end of the DList to produce a new DList.- Parameters:
a
- the element to append.- Returns:
- the new DList.
-
append
public DList<A> append(DList<A> other)
Appends two DLists together to produce a new DList.- Parameters:
other
- the other DList to append on the end of this one.- Returns:
- the new DList.
-
kleisliTrampCompose
private static <A,B,C> F<A,Trampoline<C>> kleisliTrampCompose(F<B,Trampoline<C>> bc, F<A,Trampoline<B>> ab)
-
-