public class Range<C extends java.lang.Comparable<C>>
extends java.lang.Object
implements java.lang.Iterable<C>
| Constructor and Description |
|---|
Range(C from) |
Range(C from,
C to,
java.util.function.Function<C,C> next) |
| Modifier and Type | Method and Description |
|---|---|
void |
forEach(java.util.function.BiConsumer<? super C,java.lang.Integer> action)
Similar to
forEach(Consumer), with additional parameter "index" as the second parameter of the lambda expression. |
void |
forEach(java.util.function.Consumer<? super C> action)
Iterate each element of the range.
|
Range<C> |
from(C from)
Set start point
|
C |
getFrom() |
C |
getTo() |
boolean |
isToIncluded() |
java.util.Iterator<C> |
iterator() |
Range<C> |
next(java.util.function.BiFunction<C,java.lang.Integer,C> next)
Set next element generator.
|
Range<C> |
next(java.util.function.Function<C,C> next)
Set next element generator.
|
java.util.Spliterator<C> |
spliterator() |
Seq<C> |
take(int n)
Get the first n elements of this range.
|
Seq<C> |
takeWhile(java.util.function.BiPredicate<C,java.lang.Integer> condition)
Get elements at the front of this range which satisfy the condition.
|
Seq<C> |
takeWhile(java.util.function.Predicate<C> condition)
Get elements at the front of this range which satisfy the condition.
|
Range<C> |
to(C to)
Set end point.
|
MutableSeq<C> |
toMutableSeq() |
Seq<C> |
toSeq() |
Range<C> |
until(C to)
Set end point.
|
public Range(C from)
from - The start point.java.lang.NullPointerException - if from is null.public Range<C> from(C from)
from - The start point.java.lang.NullPointerException - if from is null.public Range<C> to(C to)
to - The end point.java.lang.NullPointerException - if to is null.public Range<C> until(C to)
to - The end point.java.lang.NullPointerException - if to is null.public Range<C> next(java.util.function.Function<C,C> next)
next - The next element generatorjava.lang.NullPointerException - if next is null.public Range<C> next(java.util.function.BiFunction<C,java.lang.Integer,C> next)
next - The next element generatorjava.lang.NullPointerException - if next is null.public C getFrom()
public C getTo()
public boolean isToIncluded()
public void forEach(java.util.function.Consumer<? super C> action)
public void forEach(java.util.function.BiConsumer<? super C,java.lang.Integer> action)
forEach(Consumer), with additional parameter "index" as the second parameter of the lambda expression.java.lang.NullPointerException - if action, this.from, this.to or this.next is null.public MutableSeq<C> toMutableSeq()
public java.util.Iterator<C> iterator()
public java.util.Spliterator<C> spliterator()
public Seq<C> take(int n)
java.lang.IllegalArgumentException - if n < 0public Seq<C> takeWhile(java.util.function.Predicate<C> condition)
condition - the condition used to filter elements by passing the element,
returns true if the element satisfies the condition, otherwise returns false.java.lang.NullPointerException - if condition is nullpublic Seq<C> takeWhile(java.util.function.BiPredicate<C,java.lang.Integer> condition)
Similar to takeWhile(Predicate), with additional parameter "index" as the second parameter of the lambda expression.
condition - the condition used to filter elements by passing the element and its index,
returns true if the element satisfies the condition, otherwise returns false.java.lang.NullPointerException - if condition is null