java.io.Serializable
, ImmutableIntCollection
, IntIterable
, ImmutableIntList
, IntList
, OrderedIntIterable
, ReversibleIntIterable
, PrimitiveIterable
public 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. |
<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.
|
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.
|
tap
averageIfEmpty, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectInt, collectLong, collectShort, flatCollect, medianIfEmpty, reject, select, summaryStatistics
public 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 IntIterable
public boolean containsAll(IntIterable source)
IntIterable
containsAll
in interface IntIterable
public boolean containsNone(int... values)
public boolean contains(int value)
contains
in interface IntIterable
public void forEachWithIndex(IntIntProcedure procedure)
forEachWithIndex
in interface OrderedIntIterable
public void forEach(IntProcedure procedure)
IntIterable
forEach
in interface IntIterable
public void each(IntProcedure procedure)
IntIterable
each
in interface IntIterable
public int count(IntPredicate predicate)
IntIterable
count
in interface IntIterable
public boolean anySatisfy(IntPredicate predicate)
IntIterable
anySatisfy
in interface IntIterable
public boolean allSatisfy(IntPredicate predicate)
IntIterable
allSatisfy
in interface IntIterable
public boolean noneSatisfy(IntPredicate predicate)
IntIterable
noneSatisfy
in interface IntIterable
public boolean equals(java.lang.Object otherList)
IntList
List.equals(Object)
.public int hashCode()
IntList
List.hashCode()
.public IntInterval toReversed()
toReversed
in interface ImmutableIntList
toReversed
in interface IntList
toReversed
in interface ReversibleIntIterable
public ImmutableIntList distinct()
distinct
in interface ImmutableIntList
distinct
in interface IntList
distinct
in interface ReversibleIntIterable
public ImmutableIntList subList(int fromIndex, int toIndex)
subList
in interface ImmutableIntList
subList
in interface IntList
List.subList(int fromIndex, int toIndex)
public int size()
size
in interface PrimitiveIterable
public long dotProduct(IntList list)
dotProduct
in interface IntList
public boolean isEmpty()
PrimitiveIterable
isEmpty
in interface PrimitiveIterable
public boolean notEmpty()
PrimitiveIterable
notEmpty
in interface PrimitiveIterable
public java.lang.String makeString()
PrimitiveIterable
PrimitiveIterable.makeString(String)
and defaulting
the separator parameter to the characters ", " (comma and space).makeString
in interface PrimitiveIterable
public java.lang.String makeString(java.lang.String separator)
PrimitiveIterable
PrimitiveIterable.makeString(String, String, String)
and defaulting the start and end parameters to "" (the empty String).makeString
in interface PrimitiveIterable
public java.lang.String makeString(java.lang.String start, java.lang.String separator, java.lang.String end)
PrimitiveIterable
makeString
in interface PrimitiveIterable
public void appendString(java.lang.Appendable appendable)
PrimitiveIterable
Appendable
. Prints the string returned
by PrimitiveIterable.makeString()
.appendString
in interface PrimitiveIterable
public void appendString(java.lang.Appendable appendable, java.lang.String separator)
PrimitiveIterable
Appendable
. Prints the string returned
by PrimitiveIterable.makeString(String)
.appendString
in interface PrimitiveIterable
public void appendString(java.lang.Appendable appendable, java.lang.String start, java.lang.String separator, java.lang.String end)
PrimitiveIterable
Appendable
. Prints the string returned
by PrimitiveIterable.makeString(String, String, String)
.appendString
in interface PrimitiveIterable
public int[] toArray()
IntIterable
toArray
in interface IntIterable
public <T> T injectInto(T injectedValue, ObjectIntToObjectFunction<? super T,? extends T> function)
injectInto
in interface IntIterable
public <T> T injectIntoWithIndex(T injectedValue, ObjectIntIntToObjectFunction<? super T,? extends T> function)
injectIntoWithIndex
in interface OrderedIntIterable
injectIntoWithIndex
in interface ReversibleIntIterable
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 PrimitiveIterable
toString
in class java.lang.Object
AbstractCollection.toString()
public IntIterator intIterator()
IntIterable
intIterator
in interface IntIterable
public int getFirst()
getFirst
in interface OrderedIntIterable
public int getLast()
getLast
in interface ReversibleIntIterable
public int indexOf(int value)
indexOf
in interface OrderedIntIterable
public int lastIndexOf(int value)
lastIndexOf
in interface IntList
public ImmutableIntList select(IntPredicate predicate)
IntIterable
select
in interface ImmutableIntCollection
select
in interface ImmutableIntList
select
in interface IntIterable
select
in interface IntList
select
in interface OrderedIntIterable
select
in interface ReversibleIntIterable
public ImmutableIntList reject(IntPredicate predicate)
IntIterable
reject
in interface ImmutableIntCollection
reject
in interface ImmutableIntList
reject
in interface IntIterable
reject
in interface IntList
reject
in interface OrderedIntIterable
reject
in interface ReversibleIntIterable
public int detectIfNone(IntPredicate predicate, int ifNone)
detectIfNone
in interface IntIterable
public <V> ImmutableList<V> collect(IntToObjectFunction<? extends V> function)
IntIterable
collect
in interface ImmutableIntCollection
collect
in interface ImmutableIntList
collect
in interface IntIterable
collect
in interface IntList
collect
in interface OrderedIntIterable
collect
in interface ReversibleIntIterable
public LazyIntIterable asReversed()
asReversed
in interface ReversibleIntIterable
public long sum()
sum
in interface IntIterable
public int max()
max
in interface IntIterable
public int min()
min
in interface IntIterable
public int minIfEmpty(int defaultValue)
minIfEmpty
in interface IntIterable
public int maxIfEmpty(int defaultValue)
maxIfEmpty
in interface IntIterable
public double average()
average
in interface IntIterable
public double median()
median
in interface IntIterable
public int binarySearch(int value)
binarySearch
in interface IntList
public int[] toSortedArray()
toSortedArray
in interface IntIterable
public MutableIntList toList()
IntIterable
toList
in interface IntIterable
public MutableIntList toSortedList()
toSortedList
in interface IntIterable
public MutableIntSet toSet()
IntIterable
toSet
in interface IntIterable
public MutableIntBag toBag()
IntIterable
toBag
in interface IntIterable
public LazyIntIterable asLazy()
IntIterable
asLazy
in interface IntIterable
public ImmutableIntList toImmutable()
IntList
toImmutable
in interface IntList
public ImmutableIntList newWith(int element)
newWith
in interface ImmutableIntCollection
newWith
in interface ImmutableIntList
public ImmutableIntList newWithout(int element)
newWithout
in interface ImmutableIntCollection
newWithout
in interface ImmutableIntList
public ImmutableIntList newWithAll(IntIterable elements)
newWithAll
in interface ImmutableIntCollection
newWithAll
in interface ImmutableIntList
public ImmutableIntList newWithoutAll(IntIterable elements)
newWithoutAll
in interface ImmutableIntCollection
newWithoutAll
in interface ImmutableIntList
Copyright © 2004–2017. All rights reserved.