Package software.kes.enhancediterables
Interface ImmutableNonEmptyFiniteIterable<A>
-
- Type Parameters:
A
- the element type
- All Superinterfaces:
EnhancedIterable<A>
,FiniteIterable<A>
,com.jnape.palatable.lambda.functor.Functor<A,EnhancedIterable<?>>
,ImmutableFiniteIterable<A>
,ImmutableIterable<A>
,ImmutableNonEmptyIterable<A>
,java.lang.Iterable<A>
,NonEmptyFiniteIterable<A>
,NonEmptyIterable<A>
public interface ImmutableNonEmptyFiniteIterable<A> extends ImmutableFiniteIterable<A>, ImmutableNonEmptyIterable<A>, NonEmptyFiniteIterable<A>
AnEnhancedIterable
that is finite, safe from mutation, and guaranteed to contain at least one element.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default ImmutableNonEmptyFiniteIterable<A>
concat(ImmutableFiniteIterable<A> other)
Lazily concatenates anotherImmutableFiniteIterable
to the end of thisImmutableNonEmptyFiniteIterable
, yielding a newImmutableIterable
.default <B> ImmutableNonEmptyFiniteIterable<com.jnape.palatable.lambda.adt.hlist.Tuple2<A,B>>
cross(ImmutableNonEmptyFiniteIterable<B> other)
Returns the lazily computed cartesian product of thisImmutableNonEmptyFiniteIterable
with anotherImmutableNonEmptyFiniteIterable
.default ImmutableNonEmptyIterable<A>
cycle()
Returns an infiniteImmutableNonEmptyIterable
that repeatedly cycles thisImmutableNonEmptyFiniteIterable
's elements, in order.default ImmutableNonEmptyFiniteIterable<A>
distinct()
Returns aImmutableNonEmptyFiniteIterable
of the distinct values from thisImmutableNonEmptyFiniteIterable
.default <B> ImmutableNonEmptyFiniteIterable<B>
fmap(com.jnape.palatable.lambda.functions.Fn1<? super A,? extends B> f)
Returns a newImmutableNonEmptyFiniteIterable
by applying a function to all elements of thisImmutableNonEmptyFiniteIterable
.static <A> ImmutableNonEmptyFiniteIterable<A>
immutableNonEmptyFiniteIterable(A head, ImmutableFiniteIterable<A> tail)
Creates anImmutableNonEmptyFiniteIterable
.default ImmutableFiniteIterable<A>
init()
Returns anImmutableFiniteIterable
containing all of elements of this one, except for the last element.default ImmutableNonEmptyFiniteIterable<A>
intersperse(A separator)
Returns a newImmutableNonEmptyFiniteIterable
with the provided separator value injected between each value of thisImmutableNonEmptyFiniteIterable
.default ImmutableNonEmptyFiniteIterable<? extends ImmutableNonEmptyFiniteIterable<A>>
magnetizeBy(com.jnape.palatable.lambda.functions.Fn2<A,A,java.lang.Boolean> predicate)
Returns anIterable
of contiguous groups of elements in thisImmutableNonEmptyFiniteIterable
that match a predicate pairwise.static <A> ImmutableNonEmptyFiniteIterable<A>
of(A first, A... more)
Creates anImmutableNonEmptyFiniteIterable
containing the given elements.default ImmutableNonEmptyFiniteIterable<A>
prepend(A element)
Lazily prepends an element to the front of thisImmutableNonEmptyFiniteIterable
, yielding a newImmutableNonEmptyFiniteIterable
.default ImmutableNonEmptyFiniteIterable<A>
prependAll(A separator)
Returns a newImmutableNonEmptyFiniteIterable
with the provided separator value injected before each value of thisImmutableNonEmptyFiniteIterable
.default ImmutableNonEmptyFiniteIterable<A>
reverse()
Returns a reversed representation of thisImmutableNonEmptyFiniteIterable
.ImmutableFiniteIterable<A>
tail()
Returns anImmutableFiniteIterable
containing all subsequent elements of this one beyond the first.default com.jnape.palatable.lambda.adt.Maybe<? extends ImmutableNonEmptyFiniteIterable<A>>
toFinite()
Always succeeds becauseImmutableNonEmptyFiniteIterable
s are always finite.default com.jnape.palatable.lambda.adt.Maybe<? extends ImmutableNonEmptyFiniteIterable<A>>
toNonEmpty()
Always succeeds becauseImmutableNonEmptyFiniteIterable
s are always non-empty.default <B,C>
ImmutableNonEmptyFiniteIterable<C>zipWith(com.jnape.palatable.lambda.functions.Fn2<A,B,C> fn, ImmutableNonEmptyIterable<B> other)
Zips together thisImmutableNonEmptyFiniteIterable
with anotherImmutableNonEmptyIterable
by applying a zipping function.-
Methods inherited from interface software.kes.enhancediterables.EnhancedIterable
concat, find, toArray, toCollection, zipWith, zipWith
-
Methods inherited from interface software.kes.enhancediterables.FiniteIterable
append, concat, cross, cross, drop, dropWhile, filter, foldLeft, foldRight, partition, size, slide, span, tails, takeWhile, zipWith
-
Methods inherited from interface software.kes.enhancediterables.ImmutableFiniteIterable
append, concat, cross, drop, dropWhile, filter, inits, partition, slide, span, tails, takeWhile, zipWith
-
Methods inherited from interface software.kes.enhancediterables.ImmutableIterable
concat, take, zipWith
-
Methods inherited from interface software.kes.enhancediterables.ImmutableNonEmptyIterable
concat, zipWith
-
Methods inherited from interface software.kes.enhancediterables.NonEmptyFiniteIterable
concat, concat, cross, last, reduceLeft, reduceRight, zipWith
-
-
-
-
Method Detail
-
tail
ImmutableFiniteIterable<A> tail()
Returns anImmutableFiniteIterable
containing all subsequent elements of this one beyond the first.- Specified by:
tail
in interfaceImmutableNonEmptyIterable<A>
- Specified by:
tail
in interfaceNonEmptyFiniteIterable<A>
- Specified by:
tail
in interfaceNonEmptyIterable<A>
- Returns:
- an
ImmutableFiniteIterable<A>
-
concat
default ImmutableNonEmptyFiniteIterable<A> concat(ImmutableFiniteIterable<A> other)
Lazily concatenates anotherImmutableFiniteIterable
to the end of thisImmutableNonEmptyFiniteIterable
, yielding a newImmutableIterable
.- Specified by:
concat
in interfaceImmutableFiniteIterable<A>
- Parameters:
other
- the otherImmutableIterable
- Returns:
- an
ImmutableIterable<A>
-
cross
default <B> ImmutableNonEmptyFiniteIterable<com.jnape.palatable.lambda.adt.hlist.Tuple2<A,B>> cross(ImmutableNonEmptyFiniteIterable<B> other)
Returns the lazily computed cartesian product of thisImmutableNonEmptyFiniteIterable
with anotherImmutableNonEmptyFiniteIterable
.- Type Parameters:
B
- the type of the otherImmutableNonEmptyFiniteIterable
- Parameters:
other
- anImmutableNonEmptyFiniteIterable
of any type- Returns:
- a
ImmutableNonEmptyFiniteIterable<Tuple2<A, B>>
-
cycle
default ImmutableNonEmptyIterable<A> cycle()
Returns an infiniteImmutableNonEmptyIterable
that repeatedly cycles thisImmutableNonEmptyFiniteIterable
's elements, in order.- Specified by:
cycle
in interfaceFiniteIterable<A>
- Specified by:
cycle
in interfaceImmutableFiniteIterable<A>
- Specified by:
cycle
in interfaceNonEmptyFiniteIterable<A>
- Returns:
- an
ImmutableNonEmptyIterable<A>
-
distinct
default ImmutableNonEmptyFiniteIterable<A> distinct()
Returns aImmutableNonEmptyFiniteIterable
of the distinct values from thisImmutableNonEmptyFiniteIterable
.- Specified by:
distinct
in interfaceFiniteIterable<A>
- Specified by:
distinct
in interfaceImmutableFiniteIterable<A>
- Specified by:
distinct
in interfaceNonEmptyFiniteIterable<A>
- Returns:
- a
ImmutableNonEmptyFiniteIterable<A>
-
fmap
default <B> ImmutableNonEmptyFiniteIterable<B> fmap(com.jnape.palatable.lambda.functions.Fn1<? super A,? extends B> f)
Returns a newImmutableNonEmptyFiniteIterable
by applying a function to all elements of thisImmutableNonEmptyFiniteIterable
.- Specified by:
fmap
in interfaceEnhancedIterable<A>
- Specified by:
fmap
in interfaceFiniteIterable<A>
- Specified by:
fmap
in interfacecom.jnape.palatable.lambda.functor.Functor<A,EnhancedIterable<?>>
- Specified by:
fmap
in interfaceImmutableFiniteIterable<A>
- Specified by:
fmap
in interfaceImmutableIterable<A>
- Specified by:
fmap
in interfaceImmutableNonEmptyIterable<A>
- Specified by:
fmap
in interfaceNonEmptyFiniteIterable<A>
- Specified by:
fmap
in interfaceNonEmptyIterable<A>
- Type Parameters:
B
- the type returned byf
- Parameters:
f
- a function fromA
toB
. This function should be referentially transparent and not perform side-effects. It may be called zero or more times for each element.- Returns:
- an
ImmutableNonEmptyFiniteIterable<B>
-
init
default ImmutableFiniteIterable<A> init()
Returns anImmutableFiniteIterable
containing all of elements of this one, except for the last element.- Specified by:
init
in interfaceNonEmptyFiniteIterable<A>
- Returns:
- an
ImmutableFiniteIterable<A>
-
intersperse
default ImmutableNonEmptyFiniteIterable<A> intersperse(A separator)
Returns a newImmutableNonEmptyFiniteIterable
with the provided separator value injected between each value of thisImmutableNonEmptyFiniteIterable
.If this
ImmutableNonEmptyFiniteIterable
contains only one element, it is left untouched.- Specified by:
intersperse
in interfaceEnhancedIterable<A>
- Specified by:
intersperse
in interfaceFiniteIterable<A>
- Specified by:
intersperse
in interfaceImmutableFiniteIterable<A>
- Specified by:
intersperse
in interfaceImmutableIterable<A>
- Specified by:
intersperse
in interfaceImmutableNonEmptyIterable<A>
- Specified by:
intersperse
in interfaceNonEmptyFiniteIterable<A>
- Specified by:
intersperse
in interfaceNonEmptyIterable<A>
- Parameters:
separator
- the separator value- Returns:
- an
ImmutableNonEmptyFiniteIterable<A>
-
magnetizeBy
default ImmutableNonEmptyFiniteIterable<? extends ImmutableNonEmptyFiniteIterable<A>> magnetizeBy(com.jnape.palatable.lambda.functions.Fn2<A,A,java.lang.Boolean> predicate)
Returns anIterable
of contiguous groups of elements in thisImmutableNonEmptyFiniteIterable
that match a predicate pairwise.- Specified by:
magnetizeBy
in interfaceEnhancedIterable<A>
- Specified by:
magnetizeBy
in interfaceFiniteIterable<A>
- Specified by:
magnetizeBy
in interfaceImmutableFiniteIterable<A>
- Specified by:
magnetizeBy
in interfaceImmutableIterable<A>
- Specified by:
magnetizeBy
in interfaceImmutableNonEmptyIterable<A>
- Specified by:
magnetizeBy
in interfaceNonEmptyFiniteIterable<A>
- Specified by:
magnetizeBy
in interfaceNonEmptyIterable<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
ImmutableNonEmptyFiniteIterable<ImmutableNonEmptyFiniteIterable<A>>
containing the contiguous groups
-
prepend
default ImmutableNonEmptyFiniteIterable<A> prepend(A element)
Lazily prepends an element to the front of thisImmutableNonEmptyFiniteIterable
, yielding a newImmutableNonEmptyFiniteIterable
.- Specified by:
prepend
in interfaceEnhancedIterable<A>
- Specified by:
prepend
in interfaceFiniteIterable<A>
- Specified by:
prepend
in interfaceImmutableFiniteIterable<A>
- Specified by:
prepend
in interfaceImmutableIterable<A>
- Parameters:
element
- the element to prepend- Returns:
- a
ImmutableNonEmptyFiniteIterable<A>
-
prependAll
default ImmutableNonEmptyFiniteIterable<A> prependAll(A separator)
Returns a newImmutableNonEmptyFiniteIterable
with the provided separator value injected before each value of thisImmutableNonEmptyFiniteIterable
.- Specified by:
prependAll
in interfaceEnhancedIterable<A>
- Specified by:
prependAll
in interfaceFiniteIterable<A>
- Specified by:
prependAll
in interfaceImmutableFiniteIterable<A>
- Specified by:
prependAll
in interfaceImmutableIterable<A>
- Specified by:
prependAll
in interfaceImmutableNonEmptyIterable<A>
- Specified by:
prependAll
in interfaceNonEmptyFiniteIterable<A>
- Specified by:
prependAll
in interfaceNonEmptyIterable<A>
- Parameters:
separator
- the separator value- Returns:
- an
ImmutableNonEmptyFiniteIterable<A>
-
reverse
default ImmutableNonEmptyFiniteIterable<A> reverse()
Returns a reversed representation of thisImmutableNonEmptyFiniteIterable
.Note that reversing is deferred until the returned
Iterable
is iterated.- Specified by:
reverse
in interfaceFiniteIterable<A>
- Specified by:
reverse
in interfaceImmutableFiniteIterable<A>
- Specified by:
reverse
in interfaceNonEmptyFiniteIterable<A>
- Returns:
- an
ImmutableNonEmptyFiniteIterable<A>
-
toFinite
default com.jnape.palatable.lambda.adt.Maybe<? extends ImmutableNonEmptyFiniteIterable<A>> toFinite()
Always succeeds becauseImmutableNonEmptyFiniteIterable
s are always finite.- Specified by:
toFinite
in interfaceEnhancedIterable<A>
- Specified by:
toFinite
in interfaceFiniteIterable<A>
- Specified by:
toFinite
in interfaceImmutableFiniteIterable<A>
- Specified by:
toFinite
in interfaceImmutableIterable<A>
- Specified by:
toFinite
in interfaceImmutableNonEmptyIterable<A>
- Specified by:
toFinite
in interfaceNonEmptyFiniteIterable<A>
- Specified by:
toFinite
in interfaceNonEmptyIterable<A>
- Returns:
- this
ImmutableNonEmptyFiniteIterable
wrapped in a `just`
-
toNonEmpty
default com.jnape.palatable.lambda.adt.Maybe<? extends ImmutableNonEmptyFiniteIterable<A>> toNonEmpty()
Always succeeds becauseImmutableNonEmptyFiniteIterable
s are always non-empty.- Specified by:
toNonEmpty
in interfaceEnhancedIterable<A>
- Specified by:
toNonEmpty
in interfaceFiniteIterable<A>
- Specified by:
toNonEmpty
in interfaceImmutableFiniteIterable<A>
- Specified by:
toNonEmpty
in interfaceImmutableIterable<A>
- Specified by:
toNonEmpty
in interfaceImmutableNonEmptyIterable<A>
- Specified by:
toNonEmpty
in interfaceNonEmptyFiniteIterable<A>
- Specified by:
toNonEmpty
in interfaceNonEmptyIterable<A>
- Returns:
- this
ImmutableNonEmptyFiniteIterable
wrapped in a `just`
-
zipWith
default <B,C> ImmutableNonEmptyFiniteIterable<C> zipWith(com.jnape.palatable.lambda.functions.Fn2<A,B,C> fn, ImmutableNonEmptyIterable<B> other)
Zips together thisImmutableNonEmptyFiniteIterable
with anotherImmutableNonEmptyIterable
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 interfaceImmutableNonEmptyIterable<A>
- Type Parameters:
B
- the element type of the otherIterable
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 otherIterable
- Returns:
- an
ImmutableNonEmptyFiniteIterable<C>
-
immutableNonEmptyFiniteIterable
static <A> ImmutableNonEmptyFiniteIterable<A> immutableNonEmptyFiniteIterable(A head, ImmutableFiniteIterable<A> tail)
Creates anImmutableNonEmptyFiniteIterable
.- Type Parameters:
A
- the element type- Parameters:
head
- the first elementtail
- the remaining elements. May be empty.- Returns:
- a
ImmutableNonEmptyFiniteIterable<A>
-
of
@SafeVarargs static <A> ImmutableNonEmptyFiniteIterable<A> of(A first, A... more)
Creates anImmutableNonEmptyFiniteIterable
containing the given elements.- Type Parameters:
A
- the element type- Parameters:
first
- the first elementmore
- the remaining elements- Returns:
- an
ImmutableNonEmptyFiniteIterable<A>
-
-