Interface ImmutableNonEmptyIterable<A>

    • Method Detail

      • tail

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

        default <B> ImmutableNonEmptyIterable<B> fmap​(com.jnape.palatable.lambda.functions.Fn1<? super A,​? extends B> f)
        Returns a new ImmutableNonEmptyIterable by applying a function to all elements of this ImmutableNonEmptyIterable.
        Specified by:
        fmap in interface EnhancedIterable<A>
        Specified by:
        fmap in interface com.jnape.palatable.lambda.functor.Functor<A,​EnhancedIterable<?>>
        Specified by:
        fmap in interface ImmutableIterable<A>
        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:
        an ImmutableNonEmptyIterable<B>
      • intersperse

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

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

        Specified by:
        intersperse in interface EnhancedIterable<A>
        Specified by:
        intersperse in interface ImmutableIterable<A>
        Specified by:
        intersperse in interface NonEmptyIterable<A>
        Parameters:
        separator - the separator value
        Returns:
        a ImmutableNonEmptyIterable<A>
      • magnetizeBy

        default ImmutableNonEmptyIterable<? extends ImmutableNonEmptyIterable<A>> magnetizeBy​(com.jnape.palatable.lambda.functions.Fn2<A,​A,​java.lang.Boolean> predicate)
        Returns an Iterable of contiguous groups of elements in this ImmutableNonEmptyIterable that match a predicate pairwise.
        Specified by:
        magnetizeBy in interface EnhancedIterable<A>
        Specified by:
        magnetizeBy in interface ImmutableIterable<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 ImmutableNonEmptyIterable<ImmutableNonEmptyIterable<A>> containing the contiguous groups
      • toFinite

        default com.jnape.palatable.lambda.adt.Maybe<? extends ImmutableNonEmptyFiniteIterable<A>> toFinite()
        Converts this ImmutableNonEmptyIterable to an ImmutableNonEmptyFiniteIterable if there is enough information to do so without iterating it.

        Note that if this method returns nothing(), it does NOT necessarily mean this ImmutableNonEmptyIterable is infinite.

        Specified by:
        toFinite in interface EnhancedIterable<A>
        Specified by:
        toFinite in interface ImmutableIterable<A>
        Specified by:
        toFinite in interface NonEmptyIterable<A>
        Returns:
        a Maybe<ImmutableNonEmptyFiniteIterable<A>
      • zipWith

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

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

        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 ImmutableNonEmptyIterable<C>
      • zipWith

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

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

        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 ImmutableNonEmptyFiniteIterable<C>
      • immutableNonEmptyIterable

        static <A> ImmutableNonEmptyIterable<A> immutableNonEmptyIterable​(A head,
                                                                          ImmutableIterable<A> tail)
        Creates an ImmutableNonEmptyIterable.
        Type Parameters:
        A - the element type
        Parameters:
        head - the first element
        tail - the remaining elements. May be empty.
        Returns:
        a ImmutableNonEmptyIterable<A>
      • repeat

        static <A> ImmutableNonEmptyIterable<A> repeat​(A element)
        Returns an infinite ImmutableNonEmptyIterable that repeatedly iterates a given element.
        Type Parameters:
        A - the element type
        Parameters:
        element - the value to repeat
        Returns:
        an ImmutableNonEmptyIterable<A>