java.io.Serializable, ImmutableIntCollection, IntIterable, ImmutableIntList, IntList, OrderedIntIterable, ReversibleIntIterable, PrimitiveIterablepublic final class IntInterval extends java.lang.Object implements ImmutableIntList, java.io.Serializable
| Modifier and Type | Method | Description |
|---|---|---|
boolean |
allSatisfy(IntPredicate predicate) |
Returns true if all of the elements in the IntIterable return true for the
specified predicate, otherwise returns false.
|
boolean |
anySatisfy(IntPredicate predicate) |
Returns true if any of the elements in the IntIterable return true for the
specified predicate, otherwise returns false.
|
void |
appendString(java.lang.Appendable appendable) |
Prints a string representation of this collection onto the given
Appendable. |
void |
appendString(java.lang.Appendable appendable,
java.lang.String separator) |
Prints a string representation of this collection onto the given
Appendable. |
void |
appendString(java.lang.Appendable appendable,
java.lang.String start,
java.lang.String separator,
java.lang.String end) |
Prints a string representation of this collection onto the given
Appendable. |
LazyIntIterable |
asLazy() |
Returns a LazyIntIterable adapter wrapping the source IntIterable.
|
LazyIntIterable |
asReversed() |
|
double |
average() |
|
int |
binarySearch(int value) |
|
IntInterval |
by(int newStep) |
This instance
by method allows IntInterval to act as a fluent builder for itself. |
RichIterable<IntIterable> |
chunk(int size) |
Partitions elements in fixed size chunks.
|
<V> ImmutableList<V> |
collect(IntToObjectFunction<? extends V> function) |
Returns a new collection with the results of applying the specified function on each element of the source
collection.
|
boolean |
contains(int value) |
Returns true if the IntInterval contains the specified int value.
|
boolean |
containsAll(int... values) |
Returns true if the IntInterval contains all of the specified int values.
|
boolean |
containsAll(IntIterable source) |
Returns true if the all of the values specified in the source IntIterable are contained
in the IntIterable, and false if they are not.
|
boolean |
containsNone(int... values) |
Returns true if the IntInterval contains none of the specified int values.
|
int |
count(IntPredicate predicate) |
Returns a count of the number of elements in the IntIterable that return true for the
specified predicate.
|
int |
detectIfNone(IntPredicate predicate,
int ifNone) |
|
ImmutableIntList |
distinct() |
|
long |
dotProduct(IntList list) |
|
void |
each(IntProcedure procedure) |
A synonym for forEach.
|
boolean |
equals(java.lang.Object otherList) |
Follows the same general contract as
List.equals(Object). |
static IntInterval |
evensFromTo(int from,
int to) |
Returns an IntInterval representing the even values from the value from to the value to.
|
void |
forEach(IntProcedure procedure) |
Applies the IntProcedure to each element in the IntIterable.
|
void |
forEachWithIndex(IntIntProcedure procedure) |
|
static IntInterval |
from(int newFrom) |
This static
from method allows IntInterval to act as a fluent builder for itself. |
static IntInterval |
fromTo(int from,
int to) |
Returns an IntInterval starting from the value from to the specified value to with a step value of 1.
|
static IntInterval |
fromToBy(int from,
int to,
int stepBy) |
Returns an IntInterval for the range of integers inclusively between from and to with the specified
stepBy value.
|
int |
get(int index) |
|
int |
getFirst() |
|
int |
getLast() |
|
int |
hashCode() |
Follows the same general contract as
List.hashCode(). |
int |
indexOf(int value) |
|
<T> T |
injectInto(T injectedValue,
ObjectIntToObjectFunction<? super T,? extends T> function) |
|
<T> T |
injectIntoWithIndex(T injectedValue,
ObjectIntIntToObjectFunction<? super T,? extends T> function) |
|
IntIterator |
intIterator() |
Returns a primitive iterator that can be used to iterate over the IntIterable in an
imperative style.
|
boolean |
isEmpty() |
Returns true if this iterable has zero items.
|
int |
lastIndexOf(int value) |
|
java.lang.String |
makeString() |
Returns a string representation of this collection by delegating to
PrimitiveIterable.makeString(String) and defaulting
the separator parameter to the characters ", " (comma and space). |
java.lang.String |
makeString(java.lang.String separator) |
Returns a string representation of this collection by delegating to
PrimitiveIterable.makeString(String, String, String)
and defaulting the start and end parameters to "" (the empty String). |
java.lang.String |
makeString(java.lang.String start,
java.lang.String separator,
java.lang.String end) |
Returns a string representation of this collection with the elements separated by the specified
separator and enclosed between the start and end strings.
|
int |
max() |
|
int |
maxIfEmpty(int defaultValue) |
|
double |
median() |
|
int |
min() |
|
int |
minIfEmpty(int defaultValue) |
|
ImmutableIntList |
newWith(int element) |
|
ImmutableIntList |
newWithAll(IntIterable elements) |
|
ImmutableIntList |
newWithout(int element) |
|
ImmutableIntList |
newWithoutAll(IntIterable elements) |
|
boolean |
noneSatisfy(IntPredicate predicate) |
Returns true if none of the elements in the IntIterable return true for the
specified predicate, otherwise returns false.
|
boolean |
notEmpty() |
The English equivalent of !this.isEmpty()
|
static IntInterval |
oddsFromTo(int from,
int to) |
Returns an IntInterval representing the odd values from the value from to the value to.
|
static IntInterval |
oneTo(int count) |
Returns an IntInterval starting from 1 to the specified count value with a step value of 1.
|
static IntInterval |
oneToBy(int count,
int step) |
Returns an IntInterval starting from 1 to the specified count value with a step value of step.
|
ImmutableIntList |
reject(IntPredicate predicate) |
Returns a new IntIterable with all of the elements in the IntIterable that
return false for the specified predicate.
|
ImmutableIntList |
select(IntPredicate predicate) |
Returns a new IntIterable with all of the elements in the IntIterable that
return true for the specified predicate.
|
int |
size() |
Calculates and returns the size of the interval.
|
java.util.Spliterator.OfInt |
spliterator() |
|
ImmutableIntList |
subList(int fromIndex,
int toIndex) |
|
long |
sum() |
|
IntInterval |
to(int newTo) |
This instance
to method allows IntInterval to act as a fluent builder for itself. |
int[] |
toArray() |
Converts the IntIterable to a primitive int array.
|
MutableIntBag |
toBag() |
Converts the IntIterable to a new MutableIntBag.
|
ImmutableIntList |
toImmutable() |
Returns an immutable copy of this list.
|
MutableIntList |
toList() |
Converts the IntIterable to a new MutableIntList.
|
IntInterval |
toReversed() |
Returns a new IntInterval with the from and to values reversed and the step value negated.
|
MutableIntSet |
toSet() |
Converts the IntIterable to a new MutableIntSet.
|
int[] |
toSortedArray() |
|
MutableIntList |
toSortedList() |
|
java.lang.String |
toString() |
Returns a string with the elements of this iterable separated by commas with spaces and
enclosed in square brackets.
|
static IntInterval |
zero() |
Returns an IntInterval starting at zero.
|
static IntInterval |
zeroTo(int count) |
Returns an IntInterval starting from 0 to the specified count value with a step value of 1.
|
static IntInterval |
zeroToBy(int count,
int step) |
Returns an IntInterval starting from 0 to the specified count value with a step value of step.
|
<T> ImmutableList<IntObjectPair<T>> |
zip(java.lang.Iterable<T> iterable) |
Returns an
ImmutableList formed from this ImmutableIntList and a ListIterable by
combining corresponding elements in pairs. |
ImmutableList<IntIntPair> |
zipInt(IntIterable iterable) |
Returns an
ImmutableList formed from this ImmutableIntList and another IntList by
combining corresponding elements in pairs. |
collectWithIndex, tapaverageIfEmpty, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectInt, collectLong, collectShort, flatCollect, medianIfEmpty, reduce, reduceIfEmpty, reject, select, summaryStatisticsprimitiveParallelStream, primitiveStreamcollectWithIndexpublic static IntInterval from(int newFrom)
from method allows IntInterval to act as a fluent builder for itself.
It works in conjunction with the instance methods to(int) and by(int).
Usage Example:
IntInterval interval1 = IntInterval.from(1).to(5); // results in: 1, 2, 3, 4, 5. IntInterval interval2 = IntInterval.from(1).to(10).by(2); // results in: 1, 3, 5, 7, 9.
public IntInterval to(int newTo)
to method allows IntInterval 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:
IntInterval interval1 = IntInterval.from(1).to(5); // results in: 1, 2, 3, 4, 5. IntInterval interval2 = IntInterval.from(1).to(10).by(2); // results in: 1, 3, 5, 7, 9.
public IntInterval by(int newStep)
by method allows IntInterval 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:
IntInterval interval1 = IntInterval.from(1).to(5); // results in: 1, 2, 3, 4, 5. IntInterval interval2 = IntInterval.from(1).to(10).by(2); // results in: 1, 3, 5, 7, 9.
public static IntInterval zero()
Usage Example:
IntInterval interval1 = IntInterval.zero().to(5); // results in: 0, 1, 2, 3, 4, 5. IntInterval interval2 = IntInterval.zero().to(10).by(2); // results in: 0, 2, 4, 6, 8, 10.
public static IntInterval oneTo(int count)
public static IntInterval oneToBy(int count, int step)
public static IntInterval zeroTo(int count)
public static IntInterval zeroToBy(int count, int step)
public static IntInterval fromTo(int from, int to)
public static IntInterval evensFromTo(int from, int to)
public static IntInterval oddsFromTo(int from, int to)
public static IntInterval fromToBy(int from, int to, int stepBy)
public boolean containsAll(int... values)
containsAll in interface IntIterablepublic boolean containsAll(IntIterable source)
IntIterablecontainsAll in interface IntIterablepublic boolean containsNone(int... values)
public boolean contains(int value)
contains in interface IntIterablepublic void forEachWithIndex(IntIntProcedure procedure)
forEachWithIndex in interface OrderedIntIterablepublic void forEach(IntProcedure procedure)
IntIterableforEach in interface IntIterablepublic void each(IntProcedure procedure)
IntIterableeach in interface IntIterablepublic int count(IntPredicate predicate)
IntIterablecount in interface IntIterablepublic boolean anySatisfy(IntPredicate predicate)
IntIterableanySatisfy in interface IntIterablepublic boolean allSatisfy(IntPredicate predicate)
IntIterableallSatisfy in interface IntIterablepublic boolean noneSatisfy(IntPredicate predicate)
IntIterablenoneSatisfy in interface IntIterablepublic boolean equals(java.lang.Object otherList)
IntListList.equals(Object).public int hashCode()
IntListList.hashCode().public IntInterval toReversed()
toReversed in interface ImmutableIntListtoReversed in interface IntListtoReversed in interface ReversibleIntIterablepublic ImmutableIntList distinct()
distinct in interface ImmutableIntListdistinct in interface IntListdistinct in interface ReversibleIntIterablepublic ImmutableIntList subList(int fromIndex, int toIndex)
subList in interface ImmutableIntListsubList in interface IntListList.subList(int fromIndex, int toIndex)public int size()
size in interface PrimitiveIterablepublic long dotProduct(IntList list)
dotProduct in interface IntListpublic boolean isEmpty()
PrimitiveIterableisEmpty in interface PrimitiveIterablepublic boolean notEmpty()
PrimitiveIterablenotEmpty in interface PrimitiveIterablepublic java.lang.String makeString()
PrimitiveIterablePrimitiveIterable.makeString(String) and defaulting
the separator parameter to the characters ", " (comma and space).makeString in interface PrimitiveIterablepublic java.lang.String makeString(java.lang.String separator)
PrimitiveIterablePrimitiveIterable.makeString(String, String, String)
and defaulting the start and end parameters to "" (the empty String).makeString in interface PrimitiveIterablepublic java.lang.String makeString(java.lang.String start,
java.lang.String separator,
java.lang.String end)
PrimitiveIterablemakeString in interface PrimitiveIterablepublic void appendString(java.lang.Appendable appendable)
PrimitiveIterableAppendable. Prints the string returned
by PrimitiveIterable.makeString().appendString in interface PrimitiveIterablepublic void appendString(java.lang.Appendable appendable,
java.lang.String separator)
PrimitiveIterableAppendable. Prints the string returned
by PrimitiveIterable.makeString(String).appendString in interface PrimitiveIterablepublic void appendString(java.lang.Appendable appendable,
java.lang.String start,
java.lang.String separator,
java.lang.String end)
PrimitiveIterableAppendable. Prints the string returned
by PrimitiveIterable.makeString(String, String, String).appendString in interface PrimitiveIterablepublic int[] toArray()
IntIterabletoArray in interface IntIterablepublic <T> T injectInto(T injectedValue,
ObjectIntToObjectFunction<? super T,? extends T> function)
injectInto in interface IntIterablepublic <T> T injectIntoWithIndex(T injectedValue,
ObjectIntIntToObjectFunction<? super T,? extends T> function)
injectIntoWithIndex in interface OrderedIntIterableinjectIntoWithIndex in interface ReversibleIntIterablepublic RichIterable<IntIterable> chunk(int size)
IntIterablechunk in interface IntIterablesize - the number of elements per chunkRichIterable containing IntIterables of size size, except the last will be
truncated if the elements don't divide evenly.public java.lang.String toString()
PrimitiveIterable
Assert.assertEquals("[]", IntLists.mutable.empty().toString());
Assert.assertEquals("[1]", IntLists.mutable.with(1).toString());
Assert.assertEquals("[1, 2, 3]", IntLists.mutable.with(1, 2, 3).toString());
toString in interface PrimitiveIterabletoString in class java.lang.ObjectAbstractCollection.toString()public IntIterator intIterator()
IntIterableintIterator in interface IntIterablepublic int getFirst()
getFirst in interface OrderedIntIterablepublic int getLast()
getLast in interface ReversibleIntIterablepublic int indexOf(int value)
indexOf in interface OrderedIntIterablepublic int lastIndexOf(int value)
lastIndexOf in interface IntListpublic ImmutableIntList select(IntPredicate predicate)
IntIterableselect in interface ImmutableIntCollectionselect in interface ImmutableIntListselect in interface IntIterableselect in interface IntListselect in interface OrderedIntIterableselect in interface ReversibleIntIterablepublic ImmutableIntList reject(IntPredicate predicate)
IntIterablereject in interface ImmutableIntCollectionreject in interface ImmutableIntListreject in interface IntIterablereject in interface IntListreject in interface OrderedIntIterablereject in interface ReversibleIntIterablepublic int detectIfNone(IntPredicate predicate, int ifNone)
detectIfNone in interface IntIterablepublic <V> ImmutableList<V> collect(IntToObjectFunction<? extends V> function)
IntIterablecollect in interface ImmutableIntCollectioncollect in interface ImmutableIntListcollect in interface IntIterablecollect in interface IntListcollect in interface OrderedIntIterablecollect in interface ReversibleIntIterablepublic LazyIntIterable asReversed()
asReversed in interface ReversibleIntIterablepublic long sum()
sum in interface IntIterablepublic int max()
max in interface IntIterablepublic int min()
min in interface IntIterablepublic int minIfEmpty(int defaultValue)
minIfEmpty in interface IntIterablepublic int maxIfEmpty(int defaultValue)
maxIfEmpty in interface IntIterablepublic double average()
average in interface IntIterablepublic double median()
median in interface IntIterablepublic int binarySearch(int value)
binarySearch in interface IntListpublic int[] toSortedArray()
toSortedArray in interface IntIterablepublic MutableIntList toList()
IntIterabletoList in interface IntIterablepublic MutableIntList toSortedList()
toSortedList in interface IntIterablepublic MutableIntSet toSet()
IntIterabletoSet in interface IntIterablepublic MutableIntBag toBag()
IntIterabletoBag in interface IntIterablepublic LazyIntIterable asLazy()
IntIterableasLazy in interface IntIterablepublic ImmutableIntList toImmutable()
IntListtoImmutable in interface IntListpublic ImmutableIntList newWith(int element)
newWith in interface ImmutableIntCollectionnewWith in interface ImmutableIntListpublic ImmutableIntList newWithout(int element)
newWithout in interface ImmutableIntCollectionnewWithout in interface ImmutableIntListpublic ImmutableIntList newWithAll(IntIterable elements)
newWithAll in interface ImmutableIntCollectionnewWithAll in interface ImmutableIntListpublic ImmutableIntList newWithoutAll(IntIterable elements)
newWithoutAll in interface ImmutableIntCollectionnewWithoutAll in interface ImmutableIntListpublic ImmutableList<IntIntPair> zipInt(IntIterable iterable)
ImmutableIntListImmutableList formed from this ImmutableIntList and another IntList by
combining corresponding elements in pairs. If one of the two IntLists is longer than the other, its
remaining elements are ignored.zipInt in interface ImmutableIntListzipInt in interface IntListpublic <T> ImmutableList<IntObjectPair<T>> zip(java.lang.Iterable<T> iterable)
ImmutableIntListImmutableList formed from this ImmutableIntList and a ListIterable by
combining corresponding elements in pairs. If one of the two Lists is longer than the other, its
remaining elements are ignored.zip in interface ImmutableIntListzip in interface IntListpublic java.util.Spliterator.OfInt spliterator()
spliterator in interface IntListCopyright © 2004–2020. All rights reserved.