public final class Interval extends AbstractLazyIterable<java.lang.Integer> implements java.util.List<java.lang.Integer>, java.io.Serializable, java.util.RandomAccess
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(java.lang.Integer integer) |
void |
add(int index,
java.lang.Integer element) |
boolean |
addAll(java.util.Collection<? extends java.lang.Integer> collection) |
boolean |
addAll(int index,
java.util.Collection<? extends java.lang.Integer> collection) |
<R extends java.util.Collection<java.lang.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 java.util.Collection<T>> |
collect(com.gs.collections.api.block.function.Function<? super java.lang.Integer,? extends T> function,
R target)
Same as
RichIterable.collect(Function), except that the results are gathered into the specified target
collection. |
boolean |
contains(int value)
Returns true if the Interval contains the specified int value.
|
boolean |
contains(java.lang.Object object)
Returns true if the iterable has an element which responds true to element.equals(object).
|
boolean |
containsAll(int... values)
Returns true if the Interval contains all of the specified int values.
|
boolean |
containsNone(int... values)
Returns true if the Interval contains none of the specified int values.
|
com.gs.collections.api.LazyIterable<java.lang.Integer> |
drop(int count)
Creates a deferred drop iterable for the current iterable using the specified count as the limit.
|
boolean |
equals(java.lang.Object otherList) |
static Interval |
evensFromTo(int from,
int to)
Returns an Interval representing the even values from the value from to the value to.
|
java.lang.Number |
factorial()
Returns the Number result of calculating factorial for the range.
|
void |
forEach(com.gs.collections.api.block.procedure.primitive.IntProcedure procedure) |
void |
forEach(com.gs.collections.api.block.procedure.Procedure<? super java.lang.Integer> procedure)
The procedure is executed for each element in the iterable.
|
void |
forEach(com.gs.collections.api.block.procedure.Procedure<? super java.lang.Integer> procedure,
java.util.concurrent.Executor executor)
This method executes a void procedure against an executor, passing the current index of the
interval.
|
void |
forEach(com.gs.collections.api.block.procedure.Procedure<? super java.lang.Integer> procedure,
int startIndex,
int endIndex) |
<P> void |
forEachWith(com.gs.collections.api.block.procedure.primitive.IntObjectProcedure<? super P> procedure,
P parameter) |
<P> void |
forEachWith(com.gs.collections.api.block.procedure.Procedure2<? super java.lang.Integer,? super P> procedure,
P parameter)
The procedure2 is evaluated for each element in the iterable with the specified parameter provided
as the second argument.
|
void |
forEachWithIndex(com.gs.collections.api.block.procedure.primitive.IntIntProcedure procedure) |
void |
forEachWithIndex(com.gs.collections.api.block.procedure.primitive.ObjectIntProcedure<? super java.lang.Integer> objectIntProcedure)
Iterates over the iterable passing each element and the current relative int index to the specified instance of
ObjectIntProcedure
|
void |
forEachWithIndex(com.gs.collections.api.block.procedure.primitive.ObjectIntProcedure<? super java.lang.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.
|
java.lang.Integer |
get(int index) |
java.lang.Integer |
getFirst()
Returns the first element of an iterable.
|
java.lang.Integer |
getLast()
Returns the last element of an iterable.
|
int |
hashCode() |
int |
indexOf(java.lang.Object object) |
double |
injectInto(double injectedValue,
com.gs.collections.api.block.function.primitive.DoubleObjectToDoubleFunction<? super java.lang.Integer> function)
Returns the final double result of evaluating function using each element of the iterable and the previous evaluation
result as the parameters.
|
int |
injectInto(int injectedValue,
com.gs.collections.api.block.function.primitive.IntObjectToIntFunction<? super java.lang.Integer> function)
Returns the final int result of evaluating function using each element of the iterable and the previous evaluation
result as the parameters.
|
long |
injectInto(long injectedValue,
com.gs.collections.api.block.function.primitive.LongObjectToLongFunction<? super java.lang.Integer> function)
Returns the final long result of evaluating function using each element of the iterable and the previous evaluation
result as the parameters.
|
<R> R |
injectInto(R injectValue,
com.gs.collections.api.block.function.Function2<? super R,? super java.lang.Integer,? extends R> function)
Returns the final result of evaluating function using each element of the iterable and the previous evaluation
result as the parameters.
|
java.util.Iterator<java.lang.Integer> |
iterator() |
int |
lastIndexOf(java.lang.Object object) |
java.util.ListIterator<java.lang.Integer> |
listIterator() |
java.util.ListIterator<java.lang.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.
|
java.lang.Number |
product()
Returns the Number result of calculating product for the range.
|
<R extends java.util.Collection<java.lang.Integer>> |
reject(com.gs.collections.api.block.predicate.Predicate<? super java.lang.Integer> predicate,
R target)
Same as the reject method with one parameter but uses the specified target collection for the results.
|
java.lang.Integer |
remove(int index) |
boolean |
remove(java.lang.Object o) |
boolean |
removeAll(java.util.Collection<?> collection) |
boolean |
retainAll(java.util.Collection<?> collection) |
void |
reverseForEach(com.gs.collections.api.block.procedure.Procedure<? super java.lang.Integer> procedure) |
<R> R |
reverseInjectInto(R injectValue,
com.gs.collections.api.block.function.Function2<R,java.lang.Integer,R> function) |
Interval |
reverseThis()
Returns a new interval with the from and to values reversed and the step value negated.
|
void |
run(java.lang.Runnable runnable)
This method runs a runnable a specified number of times against on the current thread.
|
void |
run(java.lang.Runnable runnable,
java.util.concurrent.Executor executor)
This method runs a runnable a specified number of times against an executor.
|
<R extends java.util.Collection<java.lang.Integer>> |
select(com.gs.collections.api.block.predicate.Predicate<? super java.lang.Integer> predicate,
R target)
Same as the select method with one parameter but uses the specified target collection for the results.
|
java.lang.Integer |
set(int index,
java.lang.Integer element) |
int |
size()
Calculates and returns the size of the interval.
|
Interval |
subList(int fromIndex,
int toIndex) |
Interval |
take(int count)
Creates a deferred take iterable for the current iterable using the specified count as the limit.
|
Interval |
to(int newTo)
This instance
to method allows Interval to act as a fluent builder for itself. |
java.lang.Integer[] |
toArray() |
static java.lang.Integer[] |
toArray(int from,
int to)
Returns an Integer array with the values inclusively between from and to.
|
com.gs.collections.api.bag.MutableBag<java.lang.Integer> |
toBag()
Converts the collection to the default MutableBag implementation.
|
int[] |
toIntArray()
Converts the interval to an Integer array
|
com.gs.collections.api.list.MutableList<java.lang.Integer> |
toList()
Converts the collection to a MutableList implementation.
|
static java.lang.Integer[] |
toReverseArray(int from,
int to) |
static com.gs.collections.api.list.MutableList<java.lang.Integer> |
toReverseList(int from,
int to)
Returns a MutableList representing the Integer values from the value from to the value to in reverse.
|
com.gs.collections.api.set.MutableSet<java.lang.Integer> |
toSet()
Converts the collection to a MutableSet implementation.
|
static com.gs.collections.api.set.MutableSet<java.lang.Integer> |
toSet(int from,
int to)
Returns an Set representing the Integer values from the value from to the value to.
|
java.lang.String |
toString()
Returns a string representation of this RichIterable.
|
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.
|
aggregateBy, aggregateInPlaceBy, allSatisfy, anySatisfy, appendString, appendString, appendString, asLazy, chunk, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectIf, collectInt, collectLong, collectShort, collectWith, concatenate, containsAll, containsAllArguments, containsAllIterable, count, detect, detectIfNone, flatCollect, flatCollect, groupBy, groupBy, groupByEach, groupByEach, injectInto, into, isEmpty, makeString, makeString, makeString, max, max, maxBy, min, min, minBy, noneSatisfy, notEmpty, partition, reject, rejectWith, select, selectInstancesOf, selectWith, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, toArray, toMap, toSortedList, toSortedList, toSortedListBy, toSortedMap, toSortedMap, toSortedSet, toSortedSet, toSortedSetBy, toStack, zip, zip, zipWithIndex, zipWithIndexpublic 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()
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 evensFromTo(int from, int to)
public static Interval oddsFromTo(int from, int to)
public static com.gs.collections.api.set.MutableSet<java.lang.Integer> toSet(int from,
int to)
public static com.gs.collections.api.list.MutableList<java.lang.Integer> toReverseList(int from,
int to)
public static java.lang.Integer[] toArray(int from,
int to)
public static java.lang.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(java.lang.Object object)
com.gs.collections.api.RichIterablecontains in interface com.gs.collections.api.RichIterable<java.lang.Integer>contains in interface java.util.Collection<java.lang.Integer>contains in interface java.util.List<java.lang.Integer>contains in class AbstractLazyIterable<java.lang.Integer>public boolean contains(int value)
public java.lang.Number factorial()
public java.lang.Number product()
public void forEachWithIndex(com.gs.collections.api.block.procedure.primitive.IntIntProcedure procedure)
public void forEachWithIndex(com.gs.collections.api.block.procedure.primitive.ObjectIntProcedure<? super java.lang.Integer> objectIntProcedure)
com.gs.collections.api.InternalIterablee.g. people.forEachWithIndex(new ObjectIntProcedure() { public void value(Person person, int index) { LOGGER.info("Index: " + index + " person: " + person.getName()); } });
forEachWithIndex in interface com.gs.collections.api.InternalIterable<java.lang.Integer>public <P> void forEachWith(com.gs.collections.api.block.procedure.primitive.IntObjectProcedure<? super P> procedure,
P parameter)
public <P> void forEachWith(com.gs.collections.api.block.procedure.Procedure2<? super java.lang.Integer,? super P> procedure,
P parameter)
com.gs.collections.api.InternalIterablee.g. people.forEachWith(new Procedure2() { public void value(Person person, Person other) { if (person.isRelatedTo(other)) { LOGGER.info(person.getName()); } } }, fred);
forEachWith in interface com.gs.collections.api.InternalIterable<java.lang.Integer>public void forEach(com.gs.collections.api.block.procedure.primitive.IntProcedure procedure)
public void forEach(com.gs.collections.api.block.procedure.Procedure<? super java.lang.Integer> procedure)
com.gs.collections.api.InternalIterablee.g. people.forEach(new Procedure() { public void value(Person person) { LOGGER.info(person.getName()); } });
forEach in interface com.gs.collections.api.InternalIterable<java.lang.Integer>public void forEach(com.gs.collections.api.block.procedure.Procedure<? super java.lang.Integer> procedure,
java.util.concurrent.Executor executor)
public void run(java.lang.Runnable runnable)
public void run(java.lang.Runnable runnable,
java.util.concurrent.Executor executor)
public <R> R injectInto(R injectValue,
com.gs.collections.api.block.function.Function2<? super R,? super java.lang.Integer,? extends R> function)
com.gs.collections.api.RichIterableinjectInto in interface com.gs.collections.api.RichIterable<java.lang.Integer>injectInto in class AbstractLazyIterable<java.lang.Integer>public int injectInto(int injectedValue,
com.gs.collections.api.block.function.primitive.IntObjectToIntFunction<? super java.lang.Integer> function)
com.gs.collections.api.RichIterableinjectInto in interface com.gs.collections.api.RichIterable<java.lang.Integer>injectInto in class AbstractLazyIterable<java.lang.Integer>public long injectInto(long injectedValue,
com.gs.collections.api.block.function.primitive.LongObjectToLongFunction<? super java.lang.Integer> function)
com.gs.collections.api.RichIterableinjectInto in interface com.gs.collections.api.RichIterable<java.lang.Integer>injectInto in class AbstractLazyIterable<java.lang.Integer>public double injectInto(double injectedValue,
com.gs.collections.api.block.function.primitive.DoubleObjectToDoubleFunction<? super java.lang.Integer> function)
com.gs.collections.api.RichIterableinjectInto in interface com.gs.collections.api.RichIterable<java.lang.Integer>injectInto in class AbstractLazyIterable<java.lang.Integer>public void reverseForEach(com.gs.collections.api.block.procedure.Procedure<? super java.lang.Integer> procedure)
public <R> R reverseInjectInto(R injectValue,
com.gs.collections.api.block.function.Function2<R,java.lang.Integer,R> function)
public <R extends java.util.Collection<java.lang.Integer>> R addAllTo(R targetCollection)
public <T,R extends java.util.Collection<T>> R collect(com.gs.collections.api.block.function.Function<? super java.lang.Integer,? extends T> function,
R target)
com.gs.collections.api.RichIterableRichIterable.collect(Function), except that the results are gathered into the specified target
collection.
e.g.
return people.collect(new Function<Person, String>()
{
public String valueOf(Person person)
{
return person.getFirstName() + " " + person.getLastName();
}
}, Lists.mutable.of());
collect in interface com.gs.collections.api.RichIterable<java.lang.Integer>collect in class AbstractLazyIterable<java.lang.Integer>function - a Function to use as the collect transformation functiontarget - the Collection to append to for all elements in this RichIterable that meet select criteria functiontarget, which contains appended elements as a result of the collect transformationRichIterable.collect(Function)public <R extends java.util.Collection<java.lang.Integer>> R select(com.gs.collections.api.block.predicate.Predicate<? super java.lang.Integer> predicate,
R target)
com.gs.collections.api.RichIterablee.g.
return people.select(new Predicate<Person>()
{
public boolean accept(Person person)
{
return person.person.getLastName().equals("Smith");
}
}, Lists.mutable.of());
e.g.
return collection.select(Predicates.attributeEqual("lastName", "Smith"), new ArrayList());
select in interface com.gs.collections.api.RichIterable<java.lang.Integer>select in class AbstractLazyIterable<java.lang.Integer>predicate - a Predicate to use as the select criteriatarget - the Collection to append to for all elements in this RichIterable that meet select criteria predicatetarget, which contains appended elements as a result of the select criteriaRichIterable.select(Predicate)public <R extends java.util.Collection<java.lang.Integer>> R reject(com.gs.collections.api.block.predicate.Predicate<? super java.lang.Integer> predicate,
R target)
com.gs.collections.api.RichIterablee.g.
return people.reject(new Predicate<Person>()
{
public boolean accept(Person person)
{
return person.person.getLastName().equals("Smith");
}
}, Lists.mutable.of());
reject in interface com.gs.collections.api.RichIterable<java.lang.Integer>reject in class AbstractLazyIterable<java.lang.Integer>predicate - a Predicate to use as the reject criteriatarget - the Collection to append to for all elements in this RichIterable that cause Predicate#accept(Object) method to evaluate to falsetarget, which contains appended elements as a result of the reject criteriapublic boolean equals(java.lang.Object otherList)
equals in interface java.util.Collection<java.lang.Integer>equals in interface java.util.List<java.lang.Integer>equals in class java.lang.Objectpublic int hashCode()
hashCode in interface java.util.Collection<java.lang.Integer>hashCode in interface java.util.List<java.lang.Integer>hashCode in class java.lang.Objectpublic Interval reverseThis()
public int size()
size in interface com.gs.collections.api.RichIterable<java.lang.Integer>size in interface java.util.Collection<java.lang.Integer>size in interface java.util.List<java.lang.Integer>size in class AbstractLazyIterable<java.lang.Integer>public java.lang.Integer[] toArray()
toArray in interface com.gs.collections.api.RichIterable<java.lang.Integer>toArray in interface java.util.Collection<java.lang.Integer>toArray in interface java.util.List<java.lang.Integer>toArray in class AbstractLazyIterable<java.lang.Integer>Collection.toArray()public int[] toIntArray()
public java.lang.String toString()
com.gs.collections.api.RichIterableString.valueOf(Object).toString in interface com.gs.collections.api.RichIterable<java.lang.Integer>toString in class AbstractLazyIterable<java.lang.Integer>public java.util.Iterator<java.lang.Integer> iterator()
iterator in interface java.lang.Iterable<java.lang.Integer>iterator in interface java.util.Collection<java.lang.Integer>iterator in interface java.util.List<java.lang.Integer>public java.lang.Integer getFirst()
com.gs.collections.api.RichIterablegetFirst in interface com.gs.collections.api.RichIterable<java.lang.Integer>getFirst in class AbstractLazyIterable<java.lang.Integer>public java.lang.Integer getLast()
com.gs.collections.api.RichIterablegetLast in interface com.gs.collections.api.RichIterable<java.lang.Integer>getLast in class AbstractLazyIterable<java.lang.Integer>public void forEach(com.gs.collections.api.block.procedure.Procedure<? super java.lang.Integer> procedure,
int startIndex,
int endIndex)
public void forEachWithIndex(com.gs.collections.api.block.procedure.primitive.ObjectIntProcedure<? super java.lang.Integer> objectIntProcedure,
int startIndex,
int endIndex)
public java.lang.Integer get(int index)
get in interface java.util.List<java.lang.Integer>public int indexOf(java.lang.Object object)
indexOf in interface java.util.List<java.lang.Integer>public int lastIndexOf(java.lang.Object object)
lastIndexOf in interface java.util.List<java.lang.Integer>public com.gs.collections.api.list.MutableList<java.lang.Integer> toList()
com.gs.collections.api.RichIterabletoList in interface com.gs.collections.api.RichIterable<java.lang.Integer>toList in class AbstractLazyIterable<java.lang.Integer>public com.gs.collections.api.set.MutableSet<java.lang.Integer> toSet()
com.gs.collections.api.RichIterabletoSet in interface com.gs.collections.api.RichIterable<java.lang.Integer>toSet in class AbstractLazyIterable<java.lang.Integer>public com.gs.collections.api.bag.MutableBag<java.lang.Integer> toBag()
com.gs.collections.api.RichIterabletoBag in interface com.gs.collections.api.RichIterable<java.lang.Integer>toBag in class AbstractLazyIterable<java.lang.Integer>public boolean add(java.lang.Integer integer)
add in interface java.util.Collection<java.lang.Integer>add in interface java.util.List<java.lang.Integer>public boolean remove(java.lang.Object o)
remove in interface java.util.Collection<java.lang.Integer>remove in interface java.util.List<java.lang.Integer>public boolean addAll(java.util.Collection<? extends java.lang.Integer> collection)
addAll in interface java.util.Collection<java.lang.Integer>addAll in interface java.util.List<java.lang.Integer>public boolean addAll(int index,
java.util.Collection<? extends java.lang.Integer> collection)
addAll in interface java.util.List<java.lang.Integer>public boolean removeAll(java.util.Collection<?> collection)
removeAll in interface java.util.Collection<java.lang.Integer>removeAll in interface java.util.List<java.lang.Integer>public boolean retainAll(java.util.Collection<?> collection)
retainAll in interface java.util.Collection<java.lang.Integer>retainAll in interface java.util.List<java.lang.Integer>public void clear()
clear in interface java.util.Collection<java.lang.Integer>clear in interface java.util.List<java.lang.Integer>public java.lang.Integer set(int index,
java.lang.Integer element)
set in interface java.util.List<java.lang.Integer>public void add(int index,
java.lang.Integer element)
add in interface java.util.List<java.lang.Integer>public java.lang.Integer remove(int index)
remove in interface java.util.List<java.lang.Integer>public java.util.ListIterator<java.lang.Integer> listIterator()
listIterator in interface java.util.List<java.lang.Integer>public java.util.ListIterator<java.lang.Integer> listIterator(int index)
listIterator in interface java.util.List<java.lang.Integer>public Interval subList(int fromIndex, int toIndex)
subList in interface java.util.List<java.lang.Integer>public Interval take(int count)
com.gs.collections.api.LazyIterabletake in interface com.gs.collections.api.LazyIterable<java.lang.Integer>take in class AbstractLazyIterable<java.lang.Integer>public com.gs.collections.api.LazyIterable<java.lang.Integer> drop(int count)
com.gs.collections.api.LazyIterabledrop in interface com.gs.collections.api.LazyIterable<java.lang.Integer>drop in class AbstractLazyIterable<java.lang.Integer>