Class One<V,A>

java.lang.Object
fj.data.fingertrees.Digit<V,A>
fj.data.fingertrees.One<V,A>

public final class One<V,A> extends Digit<V,A>
A single-element prefix or suffix of a finger tree.
  • Field Details

    • a

      private final A a
  • Constructor Details

  • Method Details

    • foldRight

      public <B> B foldRight(F<A,F<B,B>> aff, B z)
      Description copied from class: Digit
      Folds this digit to the right using the given function and the given initial value.
      Specified by:
      foldRight in class Digit<V,A>
      Parameters:
      aff - A function with which to fold this digit.
      z - An initial value to apply at the rightmost end of the fold.
      Returns:
      The right reduction of this digit with the given function and the given initial value.
    • foldLeft

      public <B> B foldLeft(F<B,F<A,B>> bff, B z)
      Description copied from class: Digit
      Folds this digit to the left using the given function and the given initial value.
      Specified by:
      foldLeft in class Digit<V,A>
      Parameters:
      bff - A function with which to fold this digit.
      z - An initial value to apply at the leftmost end of the fold.
      Returns:
      The left reduction of this digit with the given function and the given initial value.
    • match

      public <B> B match(F<One<V,A>,B> one, F<Two<V,A>,B> two, F<Three<V,A>,B> three, F<Four<V,A>,B> four)
      Description copied from class: Digit
      Structural pattern matching on digits. Applies the function that matches the structure of this digit.
      Specified by:
      match in class Digit<V,A>
      Parameters:
      one - A function to apply to this digit if it's One.
      two - A function to apply to this digit if it's Two.
      three - A function to apply to this digit if it's Three.
      four - A function to apply to this digit if it's Four.
      Returns:
      The result of applying the function matching this Digit.
    • value

      public A value()
      Returns the single element in this digit.
      Returns:
      the single element in this digit.
    • split1

      P3<Option<Digit<V,A>>,A,Option<Digit<V,A>>> split1(F<V,Boolean> predicate, V acc)
      Specified by:
      split1 in class Digit<V,A>
    • lookup

      public P2<Integer,A> lookup(F<V,Integer> o, int i)
      Specified by:
      lookup in class Digit<V,A>
    • length

      public int length()
      Specified by:
      length in class Digit<V,A>
    • toString

      public String toString()
      Overrides:
      toString in class Digit<V,A>
    • toStream

      public Stream<A> toStream()
      Specified by:
      toStream in class Digit<V,A>