Interface NonEmptyFiniteIterable<A>

    • Method Detail

      • tail

        FiniteIterable<A> tail()
        Returns an FiniteIterable containing all subsequent elements of this one beyond the first.
        Specified by:
        tail in interface NonEmptyIterable<A>
        Returns:
        an FiniteIterable<A>
      • concat

        default NonEmptyFiniteIterable<A> concat​(java.util.Collection<A> other)
        Lazily concatenates a Collection to the end of this NonEmptyFiniteIterable, yielding a new NonEmptyFiniteIterable.
        Specified by:
        concat in interface FiniteIterable<A>
        Parameters:
        other - a Collection
        Returns:
        an NonEmptyFiniteIterable<A>
      • cross

        default <B> NonEmptyFiniteIterable<com.jnape.palatable.lambda.adt.hlist.Tuple2<A,​B>> cross​(NonEmptyFiniteIterable<B> other)
        Returns the lazily computed cartesian product of this NonEmptyFiniteIterable with another NonEmptyFiniteIterable.
        Type Parameters:
        B - the type of the other NonEmptyFiniteIterable
        Parameters:
        other - a NonEmptyFiniteIterable of any type
        Returns:
        a NonEmptyFiniteIterable<Tuple2<A, B>>
      • cycle

        default NonEmptyIterable<A> cycle()
        Returns an infinite NonEmptyIterable that repeatedly cycles this NonEmptyFiniteIterable's elements, in order.
        Specified by:
        cycle in interface FiniteIterable<A>
        Returns:
        an NonEmptyIterable<A>
      • fmap

        default <B> NonEmptyFiniteIterable<B> fmap​(com.jnape.palatable.lambda.functions.Fn1<? super A,​? extends B> f)
        Returns a new NonEmptyFiniteIterable by applying a function to all elements of this NonEmptyFiniteIterable.
        Specified by:
        fmap in interface EnhancedIterable<A>
        Specified by:
        fmap in interface FiniteIterable<A>
        Specified by:
        fmap in interface com.jnape.palatable.lambda.functor.Functor<A,​EnhancedIterable<?>>
        Specified by:
        fmap in interface NonEmptyIterable<A>
        Type Parameters:
        B - the type returned by f
        Parameters:
        f - a function from A to B. This function should be referentially transparent and not perform side-effects. It may be called zero or more times for each element.
        Returns:
        a NonEmptyFiniteIterable<B>
      • init

        default FiniteIterable<A> init()
        Returns a FiniteIterable containing all of elements of this one, except for the last element.
        Returns:
        a FiniteIterable<A>
      • intersperse

        default NonEmptyFiniteIterable<A> intersperse​(A separator)
        Returns a new NonEmptyFiniteIterable with the provided separator value injected between each value of this NonEmptyFiniteIterable.

        If this NonEmptyFiniteIterable contains only one element, it is left untouched.

        Specified by:
        intersperse in interface EnhancedIterable<A>
        Specified by:
        intersperse in interface FiniteIterable<A>
        Specified by:
        intersperse in interface NonEmptyIterable<A>
        Parameters:
        separator - the separator value
        Returns:
        a NonEmptyFiniteIterable<A>
      • last

        default A last()
        Returns the last element.
        Returns:
        an element of type A
      • magnetizeBy

        default NonEmptyFiniteIterable<? extends NonEmptyFiniteIterable<A>> magnetizeBy​(com.jnape.palatable.lambda.functions.Fn2<A,​A,​java.lang.Boolean> predicate)
        Returns an Iterable of contiguous groups of elements in this NonEmptyFiniteIterable that match a predicate pairwise.
        Specified by:
        magnetizeBy in interface EnhancedIterable<A>
        Specified by:
        magnetizeBy in interface FiniteIterable<A>
        Specified by:
        magnetizeBy in interface NonEmptyIterable<A>
        Parameters:
        predicate - the predicate function. This function should be referentially transparent and not perform side-effects. It may be called zero or more times for each element.
        Returns:
        an NonEmptyFiniteIterable<NonEmptyFiniteIterable<A>> containing the contiguous groups
      • reduceLeft

        default A reduceLeft​(com.jnape.palatable.lambda.functions.Fn2<? super A,​? super A,​? extends A> op)
        Applies a binary operator to all elements of this NonEmptyFiniteIterable, going left to right.
        Parameters:
        op - the binary operator (accumulator on the left, item on the right)
        Returns:
        the result of inserting op between consecutive elements of this NonEmptyFiniteIterable, going left to right: op( op( ... op(x_1, x_2) ..., x_{n-1}), x_n) where x,,1,,, ..., x,,n,, are the elements of this NonEmptyFiniteIterable
      • reduceRight

        default A reduceRight​(com.jnape.palatable.lambda.functions.Fn2<? super A,​? super A,​? extends A> op)
        Applies a binary operator to all elements of this NonEmptyFiniteIterable, going right to left.
        Parameters:
        op - the binary operator (item on the left, accumulator on the right)
        Returns:
        the result of inserting op between consecutive elements of this NonEmptyFiniteIterable, going right to left: op(x_1, op(x_2, ..., op(x_{n-1}, x_n)...)) where x,,1,,, ..., x,,n,, are the elements of this NonEmptyFiniteIterable
      • reverse

        default NonEmptyFiniteIterable<A> reverse()
        Returns a reversed representation of this NonEmptyFiniteIterable.

        Note that reversing is deferred until the returned Iterable is iterated.

        Specified by:
        reverse in interface FiniteIterable<A>
        Returns:
        a NonEmptyFiniteIterable<A>
      • zipWith

        default <B,​C> NonEmptyFiniteIterable<C> zipWith​(com.jnape.palatable.lambda.functions.Fn2<A,​B,​C> fn,
                                                              NonEmptyIterable<B> other)
        Zips together this NonEmptyFiniteIterable with an NonEmptyIterable by applying a zipping function.

        Applies the function to the successive elements of each Iterable until one of them runs out of elements.

        Specified by:
        zipWith in interface NonEmptyIterable<A>
        Type Parameters:
        B - the element type of the other Iterable
        C - the element type of the result
        Parameters:
        fn - the zipping function. Not null. This function should be referentially transparent and not perform side-effects. It may be called zero or more times for each element.
        other - the other Iterable
        Returns:
        an NonEmptyFiniteIterable<C>
      • nonEmptyFiniteIterable

        static <A> NonEmptyFiniteIterable<A> nonEmptyFiniteIterable​(A head,
                                                                    FiniteIterable<A> tail)
        Creates a NonEmptyFiniteIterable.
        Type Parameters:
        A - the element type
        Parameters:
        head - the first element
        tail - the remaining elements. May be empty.
        Returns:
        a NonEmptyFiniteIterable<A>
      • nonEmptyFiniteIterable

        static <A> NonEmptyFiniteIterable<A> nonEmptyFiniteIterable​(A head,
                                                                    java.util.Collection<A> tail)
        Creates a NonEmptyFiniteIterable.
        Type Parameters:
        A - the element type
        Parameters:
        head - the first element
        tail - the remaining elements. May be empty.
        Returns:
        a NonEmptyFiniteIterable<A>
      • of

        @SafeVarargs
        static <A> ImmutableNonEmptyFiniteIterable<A> of​(A first,
                                                         A... more)
        Creates a NonEmptyFiniteIterable containing the given elements.

        Note that this method actually returns an ImmutableNonEmptyFiniteIterable, which is also an NonEmptyFiniteIterable.

        Type Parameters:
        A - the element type
        Parameters:
        first - the first element
        more - the remaining elements
        Returns:
        an ImmutableNonEmptyFiniteIterable<A>