Package fj.data
Class DList<A>
java.lang.Object
fj.data.DList<A>
Difference List. It converts left associative appends into right associative ones to improve performance.
- Version:
- %build.number%
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAppends two DLists together to produce a new DList.static <A> DList
<A> arrayDList
(A... as) Creates a DList from an arrayPrepends 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
(Iterable<A> it) Creates a DList from an Iterablestatic <A> DList
<A> iteratorDList
(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> Creates a DList from a Liststatic <A> DList
<A> nil()
A empty DList.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.Appends a single element on the end of the DList to produce a new DList.Converts the DList to a standard java.util.List.
-
Field Details
-
appendFn
-
-
Constructor Details
-
DList
-
-
Method Details
-
dlist
Creates a DList from the function For alternatives functions to create a DList:- See Also:
-
listDList
Creates a DList from a List -
iterableDList
Creates a DList from an Iterable -
iteratorDList
Creates a DList from an Iterator -
arrayDList
Creates a DList from an array -
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
Converts the DList to a standard java.util.List. -
nil
A empty DList.- Type Parameters:
A
-- Returns:
- a empty DList.
-
single
Produces a DList with one element.- Type Parameters:
A
-- Parameters:
a
- the element in the DList.- Returns:
- a DList with one element.
-
cons
Prepends a single element on the DList to produce a new DList.- Parameters:
a
- the element to append.- Returns:
- the new DList.
-
snoc
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
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, F<A,C> Trampoline<C>> kleisliTrampCompose(F<B, Trampoline<C>> bc, F<A, Trampoline<B>> ab)
-