public final class Interval extends AbstractLazyIterable<Integer> implements List<Integer>, Serializable, RandomAccess
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(Integer integer) |
void |
add(int index,
Integer element) |
boolean |
addAll(Collection<? extends Integer> collection) |
boolean |
addAll(int index,
Collection<? extends Integer> collection) |
<R extends Collection<Integer>> |
addAllTo(R targetCollection) |
Interval |
by(int newStep)
This instance
by method allows Interval to act as a fluent builder for itself. |
void |
clear() |
<T,R extends Collection<T>> |
collect(Function<? super Integer,? extends T> function,
R target) |
boolean |
contains(int value)
Returns true if the Interval contains the specified int value.
|
boolean |
contains(Object object) |
boolean |
containsAll(int... values)
Returns true if the Interval contains all the specified int values.
|
boolean |
containsNone(int... values)
Returns true if the Interval contains none of the specified int values.
|
LazyIterable<Integer> |
distinct() |
LazyIterable<Integer> |
drop(int count) |
void |
each(Procedure<? super Integer> procedure) |
boolean |
equals(Object otherList) |
static Interval |
evensFromTo(int from,
int to)
Returns an Interval representing the even values from the value from to the value to.
|
Number |
factorial()
Returns the Number result of calculating factorial for the range.
|
void |
forEach(IntProcedure procedure) |
void |
forEach(Procedure<? super Integer> procedure,
Executor executor)
This method executes a void procedure against an executor, passing the current index of the
interval.
|
void |
forEach(Procedure<? super Integer> procedure,
int startIndex,
int endIndex) |
<P> void |
forEachWith(IntObjectProcedure<? super P> procedure,
P parameter) |
<P> void |
forEachWith(Procedure2<? super Integer,? super P> procedure,
P parameter) |
void |
forEachWithIndex(IntIntProcedure procedure) |
void |
forEachWithIndex(ObjectIntProcedure<? super Integer> objectIntProcedure) |
void |
forEachWithIndex(ObjectIntProcedure<? super Integer> objectIntProcedure,
int startIndex,
int endIndex) |
static Interval |
from(int newFrom)
This static
from method allows Interval to act as a fluent builder for itself. |
static Interval |
fromTo(int from,
int to)
Returns an Interval starting from the value from to the specified value to with a step value of 1.
|
static Interval |
fromToBy(int from,
int to,
int stepBy)
Returns an Interval for the range of integers inclusively between from and to with the specified
stepBy value.
|
static Interval |
fromToExclusive(int from,
int to)
Returns an Interval starting from the value from until the specified value to (exclusive) with a step value of 1
|
Integer |
get(int index) |
Integer |
getFirst() |
Integer |
getLast() |
int |
hashCode() |
int |
indexOf(Object object) |
double |
injectInto(double injectedValue,
DoubleObjectToDoubleFunction<? super Integer> function) |
int |
injectInto(int injectedValue,
IntObjectToIntFunction<? super Integer> function) |
long |
injectInto(long injectedValue,
LongObjectToLongFunction<? super Integer> function) |
<R> R |
injectInto(R injectValue,
Function2<? super R,? super Integer,? extends R> function) |
Iterator<Integer> |
iterator() |
int |
lastIndexOf(Object object) |
ListIterator<Integer> |
listIterator() |
ListIterator<Integer> |
listIterator(int index) |
static Interval |
oddsFromTo(int from,
int to)
Returns an Interval representing the odd values from the value from to the value to.
|
static Interval |
oneTo(int count)
Returns an Interval starting from 1 to the specified count value with a step value of 1.
|
static Interval |
oneToBy(int count,
int step)
Returns an Interval starting from 1 to the specified count value with a step value of step.
|
Number |
product()
Returns the Number result of calculating product for the range.
|
<R extends Collection<Integer>> |
reject(Predicate<? super Integer> predicate,
R target) |
Integer |
remove(int index) |
boolean |
remove(Object o) |
boolean |
removeAll(Collection<?> collection) |
boolean |
retainAll(Collection<?> collection) |
void |
reverseForEach(Procedure<? super Integer> procedure) |
<R> R |
reverseInjectInto(R injectValue,
Function2<? super R,Integer,? extends R> function) |
Interval |
reverseThis()
Returns a new interval with the from and to values reversed and the step value negated.
|
void |
run(Runnable runnable)
This method runs a runnable a specified number of times against on the current thread.
|
void |
run(Runnable runnable,
Executor executor)
This method runs a runnable a specified number of times against an executor.
|
<R extends Collection<Integer>> |
select(Predicate<? super Integer> predicate,
R target) |
Integer |
set(int index,
Integer element) |
int |
size()
Returns the size of the interval.
|
Interval |
subList(int fromIndex,
int toIndex) |
LazyIterable<Integer> |
take(int count) |
Interval |
to(int newTo)
This instance
to method allows Interval to act as a fluent builder for itself. |
Integer[] |
toArray() |
static Integer[] |
toArray(int from,
int to)
Returns an Integer array with the values inclusively between from and to.
|
MutableBag<Integer> |
toBag() |
int[] |
toIntArray()
Converts the interval to an Integer array.
|
MutableList<Integer> |
toList() |
static Integer[] |
toReverseArray(int from,
int to) |
static MutableList<Integer> |
toReverseList(int from,
int to)
Returns a MutableList representing the Integer values from the value from to the value to in reverse.
|
MutableSet<Integer> |
toSet() |
static MutableSet<Integer> |
toSet(int from,
int to)
Returns a Set representing the Integer values from the value from to the value to.
|
String |
toString()
Returns a string with the elements of the iterable separated by commas with spaces and
enclosed in square brackets.
|
static Interval |
zero()
Returns an Interval starting at zero.
|
static Interval |
zeroTo(int count)
Returns an Interval starting from 0 to the specified count value with a step value of 1.
|
static Interval |
zeroToBy(int count,
int step)
Returns an Interval starting from 0 to the specified count value with a step value of step.
|
asLazy, chunk, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, concatenate, dropWhile, flatCollect, getOnly, groupBy, groupByEach, groupByUniqueKey, into, isEmpty, maxByOptional, maxOptional, maxOptional, minByOptional, minOptional, minOptional, partition, partitionWith, reject, rejectWith, select, selectInstancesOf, selectWith, sumByDouble, sumByFloat, sumByInt, sumByLong, takeWhile, tap, toArray, toStack, zip, zipWithIndexallSatisfy, allSatisfyWith, anySatisfy, anySatisfyWith, appendString, appendString, collectIf, collectWith, containsAll, containsAllArguments, containsAllIterable, count, countByEach, countWith, detect, detectOptional, detectWith, detectWithIfNone, detectWithOptional, flatCollect, forEach, groupBy, groupByEach, groupByUniqueKey, injectInto, max, max, maxBy, min, min, minBy, noneSatisfy, noneSatisfyWith, rejectWith, selectWith, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, toBiMap, toMap, toSortedBag, toSortedBag, toSortedBagBy, toSortedListBy, toSortedMap, toSortedMap, toSortedMapBy, toSortedSet, toSortedSet, toSortedSetBy, zip, zipWithIndexcontainsAll, isEmpty, replaceAll, sort, spliterator, toArrayparallelStream, removeIf, streamflatCollectWithaggregateBy, aggregateBy, aggregateInPlaceBy, allSatisfy, allSatisfyWith, anySatisfy, anySatisfyWith, appendString, appendString, appendString, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, containsAll, containsAllArguments, containsAllIterable, containsAny, containsAnyIterable, containsBy, containsNone, containsNoneIterable, count, countBy, countBy, countByEach, countByEach, countByWith, countByWith, countWith, detect, detectIfNone, detectOptional, detectWith, detectWithIfNone, detectWithOptional, flatCollect, flatCollectBoolean, flatCollectByte, flatCollectChar, flatCollectDouble, flatCollectFloat, flatCollectInt, flatCollectLong, flatCollectShort, flatCollectWith, forEach, getAny, groupBy, groupByAndCollect, groupByEach, groupByUniqueKey, injectInto, injectIntoDouble, injectIntoFloat, injectIntoInt, injectIntoLong, makeString, makeString, makeString, makeString, max, max, maxBy, min, min, minBy, noneSatisfy, noneSatisfyWith, notEmpty, reduce, reduceInPlace, reduceInPlace, rejectWith, selectWith, summarizeDouble, summarizeFloat, summarizeInt, summarizeLong, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, toBiMap, toImmutableBag, toImmutableBiMap, toImmutableList, toImmutableMap, toImmutableSet, toImmutableSortedBag, toImmutableSortedBag, toImmutableSortedBagBy, toImmutableSortedList, toImmutableSortedList, toImmutableSortedListBy, toImmutableSortedSet, toImmutableSortedSet, toImmutableSortedSetBy, toMap, toMap, toSortedBag, toSortedBag, toSortedBagBy, toSortedList, toSortedList, toSortedListBy, toSortedMap, toSortedMap, toSortedMapBy, toSortedSet, toSortedSet, toSortedSetBy, zip, zipWithIndexforEachpublic static Interval from(int newFrom)
from method allows Interval to act as a fluent builder for itself.
It works in conjunction with the instance methods to(int) and by(int).
Usage Example:
Interval interval1 = Interval.from(1).to(5); // results in: 1, 2, 3, 4, 5. Interval interval2 = Interval.from(1).to(10).by(2); // results in: 1, 3, 5, 7, 9.
public Interval to(int newTo)
to method allows Interval to act as a fluent builder for itself.
It works in conjunction with the static method from(int) and instance method by(int).
Usage Example:
Interval interval1 = Interval.from(1).to(5); // results in: 1, 2, 3, 4, 5. Interval interval2 = Interval.from(1).to(10).by(2); // results in: 1, 3, 5, 7, 9.
public Interval by(int newStep)
by method allows Interval to act as a fluent builder for itself.
It works in conjunction with the static method from(int) and instance method to(int).
Usage Example:
Interval interval1 = Interval.from(1).to(5); // results in: 1, 2, 3, 4, 5. Interval interval2 = Interval.from(1).to(10).by(2); // results in: 1, 3, 5, 7, 9.
public static Interval zero()
Usage Example:
Interval interval1 = Interval.zero().to(5); // results in: 0, 1, 2, 3, 4, 5. Interval interval2 = Interval.zero().to(10).by(2); // results in: 0, 2, 4, 6, 8, 10.
public static Interval oneTo(int count)
public static Interval oneToBy(int count, int step)
public static Interval zeroTo(int count)
public static Interval zeroToBy(int count, int step)
public static Interval fromTo(int from, int to)
public static Interval fromToExclusive(int from, int to)
public static Interval evensFromTo(int from, int to)
public static Interval oddsFromTo(int from, int to)
public static MutableSet<Integer> toSet(int from, int to)
public static MutableList<Integer> toReverseList(int from, int to)
public static Integer[] toArray(int from, int to)
public static Integer[] toReverseArray(int from, int to)
public static Interval fromToBy(int from, int to, int stepBy)
public boolean containsAll(int... values)
public boolean containsNone(int... values)
public boolean contains(Object object)
contains in interface Collection<Integer>contains in interface List<Integer>contains in interface RichIterable<Integer>contains in class AbstractRichIterable<Integer>public boolean contains(int value)
public Number factorial()
public Number product()
public void forEachWithIndex(IntIntProcedure procedure)
public void forEachWithIndex(ObjectIntProcedure<? super Integer> objectIntProcedure)
forEachWithIndex in interface InternalIterable<Integer>forEachWithIndex in class AbstractRichIterable<Integer>public <P> void forEachWith(IntObjectProcedure<? super P> procedure, P parameter)
public <P> void forEachWith(Procedure2<? super Integer,? super P> procedure, P parameter)
forEachWith in interface InternalIterable<Integer>forEachWith in class AbstractRichIterable<Integer>public void forEach(IntProcedure procedure)
public void each(Procedure<? super Integer> procedure)
each in interface RichIterable<Integer>public void forEach(Procedure<? super Integer> procedure, Executor executor)
public void run(Runnable runnable)
public void run(Runnable runnable, Executor executor)
public <R> R injectInto(R injectValue,
Function2<? super R,? super Integer,? extends R> function)
injectInto in interface RichIterable<Integer>injectInto in class AbstractRichIterable<Integer>public int injectInto(int injectedValue,
IntObjectToIntFunction<? super Integer> function)
injectInto in interface RichIterable<Integer>injectInto in class AbstractRichIterable<Integer>public long injectInto(long injectedValue,
LongObjectToLongFunction<? super Integer> function)
injectInto in interface RichIterable<Integer>injectInto in class AbstractRichIterable<Integer>public double injectInto(double injectedValue,
DoubleObjectToDoubleFunction<? super Integer> function)
injectInto in interface RichIterable<Integer>injectInto in class AbstractRichIterable<Integer>public <R> R reverseInjectInto(R injectValue,
Function2<? super R,Integer,? extends R> function)
public <R extends Collection<Integer>> R addAllTo(R targetCollection)
public <T,R extends Collection<T>> R collect(Function<? super Integer,? extends T> function, R target)
collect in interface RichIterable<Integer>collect in class AbstractRichIterable<Integer>public <R extends Collection<Integer>> R select(Predicate<? super Integer> predicate, R target)
select in interface RichIterable<Integer>select in class AbstractRichIterable<Integer>public <R extends Collection<Integer>> R reject(Predicate<? super Integer> predicate, R target)
reject in interface RichIterable<Integer>reject in class AbstractRichIterable<Integer>public boolean equals(Object otherList)
public int hashCode()
public Interval reverseThis()
public int size()
size in interface Collection<Integer>size in interface List<Integer>size in interface RichIterable<Integer>size in class AbstractLazyIterable<Integer>public Integer[] toArray()
toArray in interface Collection<Integer>toArray in interface List<Integer>toArray in interface RichIterable<Integer>toArray in class AbstractRichIterable<Integer>public int[] toIntArray()
public String toString()
AbstractRichIterable
Assert.assertEquals("[]", Lists.mutable.empty().toString());
Assert.assertEquals("[1]", Lists.mutable.with(1).toString());
Assert.assertEquals("[1, 2, 3]", Lists.mutable.with(1, 2, 3).toString());
toString in interface RichIterable<Integer>toString in class AbstractRichIterable<Integer>AbstractCollection.toString()public Integer getFirst()
getFirst in interface LazyIterable<Integer>getFirst in interface RichIterable<Integer>getFirst in class AbstractLazyIterable<Integer>public Integer getLast()
getLast in interface RichIterable<Integer>getLast in class AbstractLazyIterable<Integer>public void forEachWithIndex(ObjectIntProcedure<? super Integer> objectIntProcedure, int startIndex, int endIndex)
public int lastIndexOf(Object object)
lastIndexOf in interface List<Integer>public MutableList<Integer> toList()
toList in interface RichIterable<Integer>toList in class AbstractRichIterable<Integer>public MutableSet<Integer> toSet()
toSet in interface RichIterable<Integer>toSet in class AbstractRichIterable<Integer>public MutableBag<Integer> toBag()
toBag in interface RichIterable<Integer>toBag in class AbstractRichIterable<Integer>public boolean add(Integer integer)
public boolean remove(Object o)
public boolean addAll(Collection<? extends Integer> collection)
public boolean addAll(int index,
Collection<? extends Integer> collection)
public boolean removeAll(Collection<?> collection)
public boolean retainAll(Collection<?> collection)
public void clear()
public ListIterator<Integer> listIterator()
listIterator in interface List<Integer>public ListIterator<Integer> listIterator(int index)
listIterator in interface List<Integer>public Interval subList(int fromIndex, int toIndex)
public LazyIterable<Integer> take(int count)
take in interface LazyIterable<Integer>take in class AbstractLazyIterable<Integer>public LazyIterable<Integer> drop(int count)
drop in interface LazyIterable<Integer>drop in class AbstractLazyIterable<Integer>public LazyIterable<Integer> distinct()
distinct in interface LazyIterable<Integer>distinct in class AbstractLazyIterable<Integer>Copyright © 2004–2022. All rights reserved.