Constructor and Description |
---|
Range(IAST list)
Construct a range for a List
|
Range(IAST list,
int start)
Construct a range for a List
throws IndexOutOfBoundsException if
start isn't valid. |
Range(IAST list,
int start,
int end)
Construct a range for a List
throws IndexOutOfBoundsException if
start or
end aren't valid. |
Modifier and Type | Method and Description |
---|---|
boolean |
all(java.util.function.Predicate<IExpr> predicate)
Returns true if the predicate returns true for all elements in the range.
|
boolean |
all(java.util.function.Predicate<IExpr>[] predicates)
Returns true if all branch predicates return true for all elements in the
range.
|
boolean |
any(java.util.function.Predicate<IExpr> predicate)
Returns true if the predicate returns true for at least one element in
the range.
|
boolean |
any(java.util.function.Predicate<IExpr>[] predicates)
Returns true if at least one branch predicate returns true for all
elements in the range.
|
boolean |
compareAdjacent(java.util.function.BiPredicate<IExpr,IExpr> predicate)
Compare all adjacent elemants from lowest to highest index and return
true, if the binary predicate gives true in each step.
|
boolean |
contains(IExpr o) |
boolean |
containsAll(java.util.Collection<? extends IExpr> c) |
int |
count(java.lang.Object value)
Returns the number of elements in the range that equals the given value.
|
int |
countIf(java.util.function.Predicate<IExpr> predicate)
Returns the number of elements in the range that match the given
predicate.
|
java.util.Collection<IExpr> |
filter(java.util.Collection<IExpr> filterList,
java.util.Collection<IExpr> restList,
java.util.function.Function<IExpr,IExpr> function)
Apply the function to each element in the range and append the result
elements for which the function returns non-null elements to the
filterList, or otherwise append it to the restList.
|
IAST |
filter(IAST filterList,
java.util.Collection<IExpr> restList,
java.util.function.Predicate<IExpr> predicate)
Apply the predicate to each element in the range and append the elements
which match the predicate to the filterList, or otherwise append it to
the restList.
|
IAST |
filter(IAST list,
java.util.function.Predicate<IExpr> predicate)
Apply the predicate to each element in the range and append the elements
to the list, which match the predicate.
|
IAST |
filter(IAST list,
java.util.function.Predicate<IExpr> predicate,
int maxMatches)
Apply the predicate to each element in the range and append the elements
to the list, which match the predicate.
|
int |
findAdjacent(java.util.function.Predicate<IExpr> predicate)
Locates the first pair of adjacent elements in a range that match the
given predicate
|
IExpr |
foldLeft(java.util.function.BiFunction<IExpr,IExpr,? extends IExpr> function,
IExpr startValue)
Apply the functor to the elements of the range from left to right and
return the final result.
|
IExpr |
foldRight(java.util.function.BiFunction<IExpr,IExpr,? extends IExpr> function,
IExpr startValue)
Apply the functor to the elements of the range from right to left and
return the final result.
|
IExpr |
forEach(java.util.function.Function<IExpr,? extends IExpr> function)
Apply the functor to each element in the range and return the final
result.
|
IExpr |
get(int index)
Delegates to the lists get() method.
|
int |
getEnd() |
IAST |
getList()
get the list for this rnage
|
int |
getStart() |
int |
indexOf(IExpr match)
Returns the index of the first found object from the range start
|
int |
indexOf(IExpr match,
int start)
Returns the index of the first found object from the given start index
|
int |
indexOf(java.util.function.Predicate<IExpr> predicate) |
int |
indexOf(java.util.function.Predicate<IExpr> predicate,
int start)
Returns the index of the first found object that match the predicate
|
java.util.Iterator<IExpr> |
iterator() |
int |
lastIndexOf(java.lang.Object match)
Returns the index of the first found object from the range end
|
int |
lastIndexOf(java.util.function.Predicate<IExpr> predicate) |
boolean |
map(java.util.Collection<IExpr> list,
java.util.function.BiFunction<IExpr,IExpr,IExpr> function)
Append the result of the pairwise mapped elements to the given
list . |
IAST |
map(IAST list,
java.util.function.Function<IExpr,IExpr> function)
Deprecated.
use
IAST.mapAt(IAST, IAST, int) instead |
IAST |
map(IAST list,
IUnaryIndexFunction<IExpr,IExpr> function)
Append the mapped ranges elements directly to the given
list |
IAST |
mapLeft(IAST list,
java.util.function.BiFunction<IExpr,IExpr,IExpr> binaryFunction,
IExpr leftArg)
Append the mapped ranges elements directly to the given
list |
java.util.Collection<IExpr> |
mapRight(java.util.Collection<IExpr> list,
java.util.function.BiFunction<IExpr,IExpr,IExpr> binaryFunction,
IExpr rightArg)
Append the mapped ranges elements directly to the given
list |
IExpr |
max(java.util.Comparator<? super IExpr> comp)
Returns the largest value in the range
|
IExpr |
min(java.util.Comparator<? super IExpr> comp)
Return the smallest value in the range
|
java.util.Collection<IExpr> |
removeAll(java.util.Collection<IExpr> list,
java.util.function.Predicate<IExpr> predicate)
Apply the predicate to each element in the range and append the elements
to the list, which don't match the predicate.
|
java.util.Collection<IExpr> |
replaceAll(java.util.Collection<IExpr> list,
java.util.function.Function<IExpr,? extends IExpr> function)
Apply the function to each element in the range and append the results to
the list.
|
java.util.Collection<IExpr> |
reverse(java.util.Collection<IExpr> list)
Append the ranges elements in reversed order to the given
list |
java.util.Collection<IExpr> |
rotateLeft(java.util.Collection<IExpr> list,
int n)
Rotate the ranges elements to the left by n places and append the
resulting elements to the
list |
java.util.Collection<IExpr> |
rotateRight(java.util.Collection<IExpr> list,
int n)
Rotate the ranges elements to the right by n places and append the
resulting elements to the
list |
int |
size()
The size of this range gives the number of elements, which this range
include
|
IAST |
sort(java.util.Comparator<IExpr> comparator)
Sorts the elements of the specified range "in place" (i.IExpr. modify the
internal referenced list), according to the order induced by the
specified comparator.
|
IExpr[] |
toArray(IExpr[] array) |
java.util.List<IExpr> |
toList(java.util.List<IExpr> list)
Append the ranges elements to the given
list |
public Range(IAST list)
list
- public Range(IAST list, int start)
start
isn't valid.list
- start
- end
- public Range(IAST list, int start, int end)
start
or
end
aren't valid.list
- start
- end
- public boolean all(java.util.function.Predicate<IExpr> predicate)
public boolean all(java.util.function.Predicate<IExpr>[] predicates)
public boolean any(java.util.function.Predicate<IExpr> predicate)
public boolean any(java.util.function.Predicate<IExpr>[] predicates)
public boolean compareAdjacent(java.util.function.BiPredicate<IExpr,IExpr> predicate)
public boolean contains(IExpr o)
public boolean containsAll(java.util.Collection<? extends IExpr> c)
public int count(java.lang.Object value)
public int countIf(java.util.function.Predicate<IExpr> predicate)
public IAST filter(IAST filterList, java.util.Collection<IExpr> restList, java.util.function.Predicate<IExpr> predicate)
filterList
- the elements which match the predicaterestList
- the elements which don't match the predicatepredicate
- the predicate which filters each element in the rangefilterList
public java.util.Collection<IExpr> filter(java.util.Collection<IExpr> filterList, java.util.Collection<IExpr> restList, java.util.function.Function<IExpr,IExpr> function)
filterList
- the elements which match the predicaterestList
- the elements which don't match the predicatefunction
- the function which filters each element in the range by
returning a non-null result.filterList
public IAST filter(IAST list, java.util.function.Predicate<IExpr> predicate)
Range#removeAll(List, Predicate)
,
Range#replaceAll(List, Function)
public IAST filter(IAST list, java.util.function.Predicate<IExpr> predicate, int maxMatches)
Range#removeAll(List, Predicate)
,
Range#replaceAll(List, Function)
public int findAdjacent(java.util.function.Predicate<IExpr> predicate)
predicate
- a predicate that analyzes the given elementspublic IExpr foldLeft(java.util.function.BiFunction<IExpr,IExpr,? extends IExpr> function, IExpr startValue)
function
- a binary function that accumulate the elementspublic IExpr foldRight(java.util.function.BiFunction<IExpr,IExpr,? extends IExpr> function, IExpr startValue)
function
- a binary function that accumulate the elementspublic IExpr forEach(java.util.function.Function<IExpr,? extends IExpr> function)
public final IExpr get(int index)
index
- public final int getEnd()
public final IAST getList()
public final int getStart()
public int indexOf(IExpr match)
match
- public int indexOf(IExpr match, int start)
match
- public int indexOf(java.util.function.Predicate<IExpr> predicate)
public int indexOf(java.util.function.Predicate<IExpr> predicate, int start)
public java.util.Iterator<IExpr> iterator()
iterator
in interface java.lang.Iterable<IExpr>
public int lastIndexOf(java.lang.Object match)
match
- public int lastIndexOf(java.util.function.Predicate<IExpr> predicate)
public boolean map(java.util.Collection<IExpr> list, java.util.function.BiFunction<IExpr,IExpr,IExpr> function)
list
. If the function evaluates to null
append
the current range element directly otherwise evaluate the next pair of
elementslist
- fromIndex
- toIndex
- @Deprecated public IAST map(IAST list, java.util.function.Function<IExpr,IExpr> function)
IAST.mapAt(IAST, IAST, int)
insteadlist
list
- function
- public IAST map(IAST list, IUnaryIndexFunction<IExpr,IExpr> function)
list
list
- function
- public IAST mapLeft(IAST list, java.util.function.BiFunction<IExpr,IExpr,IExpr> binaryFunction, IExpr leftArg)
list
list
- binaryFunction
- binary functionleftArg
- left argument of the binary functions apply()
method.public java.util.Collection<IExpr> mapRight(java.util.Collection<IExpr> list, java.util.function.BiFunction<IExpr,IExpr,IExpr> binaryFunction, IExpr rightArg)
list
list
- binaryFunction
- a binary functionleftArg
- right argument of the binary functions apply()
method.public IExpr max(java.util.Comparator<? super IExpr> comp)
public IExpr min(java.util.Comparator<? super IExpr> comp)
public java.util.Collection<IExpr> removeAll(java.util.Collection<IExpr> list, java.util.function.Predicate<IExpr> predicate)
Range#filter(List, Predicate)
,
Range#replaceAll(List, Function)
public java.util.Collection<IExpr> replaceAll(java.util.Collection<IExpr> list, java.util.function.Function<IExpr,? extends IExpr> function)
Range#filter(List, Predicate)
,
Range#removeAll(List, Predicate)
public java.util.Collection<IExpr> reverse(java.util.Collection<IExpr> list)
list
list
- fromIndex
- toIndex
- public java.util.Collection<IExpr> rotateLeft(java.util.Collection<IExpr> list, int n)
list
list
- n
- public java.util.Collection<IExpr> rotateRight(java.util.Collection<IExpr> list, int n)
list
list
- n
- public int size()
public IAST sort(java.util.Comparator<IExpr> comparator)