Package fj.data

Class DList<A>

java.lang.Object
fj.data.DList<A>

public final class DList<A> extends Object
Difference List. It converts left associative appends into right associative ones to improve performance.
Version:
%build.number%
  • Field Details

  • Constructor Details

  • Method Details

    • 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:
      See Also:
    • listDList

      public static <A> DList<A> listDList(List<A> a)
      Creates a DList from a List
    • iterableDList

      public static <A> DList<A> iterableDList(Iterable<A> it)
      Creates a DList from an Iterable
    • iteratorDList

      public static <A> DList<A> iteratorDList(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 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)