org.matheclipse.core.eval
Class Range
- java.lang.Object
-
- org.matheclipse.core.eval.Range
-
-
Constructor Summary
Constructors Constructor and Description Range(IAST list)Construct a range for a ListRange(IAST list, int start)Construct a range for a List throws IndexOutOfBoundsException ifstartisn't valid.Range(IAST list, int start, int end)Construct a range for a List throws IndexOutOfBoundsException ifstartorendaren't valid.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description booleanall(Predicate<IExpr> predicate)Returns true if the predicate returns true for all elements in the range.booleanall(Predicate<IExpr>[] predicates)Returns true if all branch predicates return true for all elements in the range.booleanany(Predicate<IExpr> predicate)Returns true if the predicate returns true for at least one element in the range.booleanany(Predicate<IExpr>[] predicates)Returns true if at least one branch predicate returns true for all elements in the range.booleancompareAdjacent(BiPredicate<IExpr> predicate)Compare all adjacent elemants from lowest to highest index and return true, if the binary predicate gives true in each step.java.util.Collection<IExpr>complement(java.util.Collection<IExpr> result, Range secondRange)Create the (unordered) complement set from both rangesbooleancontains(IExpr o)booleancontainsAll(java.util.Collection<? extends IExpr> c)intcount(java.lang.Object value)Returns the number of elements in the range that equals the given value.intcountIf(Predicate<IExpr> predicate)Returns the number of elements in the range that match the given predicate.java.util.Collection<IExpr>difference(java.util.Collection<IExpr> result, Range secondList)java.util.Collection<IExpr>filter(java.util.Collection<IExpr> filterList, java.util.Collection<IExpr> restList, 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.IASTfilter(IAST filterList, java.util.Collection<IExpr> restList, 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.IASTfilter(IAST list, Predicate<IExpr> predicate)Apply the predicate to each element in the range and append the elements to the list, which match the predicate.IASTfilter(IAST list, 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.intfindAdjacent(java.lang.Object match)Locates the first pair of adjacent elements in a range that are the same value.intfindAdjacent(java.lang.Object match, int start)Locates the first pair of adjacent elements in a range that are the same value starting at indexstart and ending at the ranges upper limit.intfindAdjacent(Predicate<IExpr> predicate)Locates the first pair of adjacent elements in a range that match the given predicateIExprfoldLeft(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.IExprfoldRight(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.IExprforEach(Function<IExpr,? extends IExpr> function)Apply the functor to each element in the range and return the final result.IExprget(int index)Delegates to the lists get() method.intgetEnd()IASTgetList()get the list for this rnageintgetStart()intindexOf(IExpr match)Returns the index of the first found object from the range startintindexOf(IExpr match, int start)Returns the index of the first found object from the given start indexintindexOf(Predicate<IExpr> predicate)intindexOf(Predicate<IExpr> predicate, int start)Returns the index of the first found object that match the predicatejava.util.Collection<IExpr>intersection(java.util.Collection<IExpr> result, Range secondList)Create the (unordered) intersection set from both ranges.java.util.Iterator<IExpr>iterator()intlastIndexOf(java.lang.Object match)Returns the index of the first found object from the range endintlastIndexOf(Predicate<IExpr> predicate)booleanmap(java.util.Collection<IExpr> list, BiFunction<IExpr,IExpr,IExpr> function)Append the result of the pairwise mapped elements to the givenlist.IASTmap(IAST list, Function<IExpr,IExpr> function)Append the mapped ranges elements directly to the givenlistIASTmap(IAST list, IUnaryIndexFunction<IExpr,IExpr> function)Append the mapped ranges elements directly to the givenlistIASTmapLeft(IAST list, BiFunction<IExpr,IExpr,IExpr> binaryFunction, IExpr leftArg)Append the mapped ranges elements directly to the givenlistjava.util.Collection<IExpr>mapRight(java.util.Collection<IExpr> list, BiFunction<IExpr,IExpr,IExpr> binaryFunction, IExpr rightArg)Append the mapped ranges elements directly to the givenlistIExprmax(java.util.Comparator<? super IExpr> comp)Returns the largest value in the rangeIExprmin(java.util.Comparator<? super IExpr> comp)Return the smallest value in the rangejava.util.Collection<IExpr>removeAll(java.util.Collection<IExpr> list, 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, 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 givenlistjava.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 thelistjava.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 thelistintsize()The size of this range gives the number of elements, which this range includeIASTsort(ExprComparator comparator)Sorts the elements of the specified range "in place" (i.IExpr.IExpr[]toArray(IExpr[] array)java.util.List<IExpr>toList(java.util.List<IExpr> list)Append the ranges elements to the givenlistjava.util.Collection<IExpr>union(java.util.Collection<IExpr> result, Range secondList)Create the (unordered) union set from both ranges.
-
-
-
Constructor Detail
-
Range
public Range(IAST list)
Construct a range for a List- Parameters:
list-
-
Range
public Range(IAST list, int start)
Construct a range for a List throws IndexOutOfBoundsException ifstartisn't valid.- Parameters:
list-start-end-
-
Range
public Range(IAST list, int start, int end)
Construct a range for a List throws IndexOutOfBoundsException ifstartorendaren't valid.- Parameters:
list-start-end-
-
-
Method Detail
-
all
public boolean all(Predicate<IExpr> predicate)
Returns true if the predicate returns true for all elements in the range.- Returns:
- true if the predicate returns true, false otherwise
-
all
public boolean all(Predicate<IExpr>[] predicates)
Returns true if all branch predicates return true for all elements in the range. Also returns true when there are no branch predicates.- Returns:
- true if all branch predicates return true, false otherwise
-
any
public boolean any(Predicate<IExpr> predicate)
Returns true if the predicate returns true for at least one element in the range.- Returns:
- true if the predicate returns true for at least one element, false otherwise
-
any
public boolean any(Predicate<IExpr>[] predicates)
Returns true if at least one branch predicate returns true for all elements in the range.- Returns:
- true if at least one branch predicate returns true, false otherwise
-
compareAdjacent
public boolean compareAdjacent(BiPredicate<IExpr> predicate)
Compare all adjacent elemants from lowest to highest index and return true, if the binary predicate gives true in each step. If start >= (end-1) the method return false;
-
complement
public java.util.Collection<IExpr> complement(java.util.Collection<IExpr> result, Range secondRange)
Create the (unordered) complement set from both ranges- Parameters:
result-secondRange-- Returns:
-
contains
public boolean contains(IExpr o)
-
containsAll
public boolean containsAll(java.util.Collection<? extends IExpr> c)
-
count
public int count(java.lang.Object value)
Returns the number of elements in the range that equals the given value.
-
countIf
public int countIf(Predicate<IExpr> predicate)
Returns the number of elements in the range that match the given predicate.
-
difference
public java.util.Collection<IExpr> difference(java.util.Collection<IExpr> result, Range secondList)
-
filter
public IAST filter(IAST filterList, java.util.Collection<IExpr> restList, 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.- Parameters:
filterList- the elements which match the predicaterestList- the elements which don't match the predicatepredicate- the predicate which filters each element in the range- Returns:
- the
filterList
-
filter
public java.util.Collection<IExpr> filter(java.util.Collection<IExpr> filterList, java.util.Collection<IExpr> restList, 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.- Parameters:
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.- Returns:
- the
filterList
-
filter
public IAST filter(IAST list, Predicate<IExpr> predicate)
Apply the predicate to each element in the range and append the elements to the list, which match the predicate.- See Also:
Range#removeAll(List, Predicate),Range#replaceAll(List, Function)
-
filter
public IAST filter(IAST list, 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.- See Also:
Range#removeAll(List, Predicate),Range#replaceAll(List, Function)
-
findAdjacent
public int findAdjacent(java.lang.Object match)
Locates the first pair of adjacent elements in a range that are the same value.- Returns:
- the index of the first element
-
findAdjacent
public int findAdjacent(java.lang.Object match, int start)Locates the first pair of adjacent elements in a range that are the same value starting at indexstart and ending at the ranges upper limit.- Returns:
- the index of the first element
-
findAdjacent
public int findAdjacent(Predicate<IExpr> predicate)
Locates the first pair of adjacent elements in a range that match the given predicate- Parameters:
predicate- a predicate that analyzes the given elements- Returns:
- the index of the first element
-
foldLeft
public IExpr foldLeft(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. Results do accumulate from one invocation to the next: each time this method is called, the accumulation starts over with value from the previous function call.- Parameters:
function- a binary function that accumulate the elements- Returns:
- the accumulated elements
-
foldRight
public IExpr foldRight(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. Results do accumulate from one invocation to the next: each time this method is called, the accumulation starts over with value from the previous function call.- Parameters:
function- a binary function that accumulate the elements- Returns:
- the accumulated elements
-
forEach
public IExpr forEach(Function<IExpr,? extends IExpr> function)
Apply the functor to each element in the range and return the final result.- Returns:
- the result of the last execution of the functor, or null if the functor is not executed.
-
get
public final IExpr get(int index)
Delegates to the lists get() method. With this method you can access elements outside the given range- Parameters:
index-- Returns:
-
getEnd
public final int getEnd()
-
getList
public final IAST getList()
get the list for this rnage- Returns:
-
getStart
public final int getStart()
-
indexOf
public int indexOf(IExpr match)
Returns the index of the first found object from the range start- Parameters:
match-- Returns:
-
indexOf
public int indexOf(IExpr match, int start)
Returns the index of the first found object from the given start index- Parameters:
match-- Returns:
-
indexOf
public int indexOf(Predicate<IExpr> predicate, int start)
Returns the index of the first found object that match the predicate
-
intersection
public java.util.Collection<IExpr> intersection(java.util.Collection<IExpr> result, Range secondList)
Create the (unordered) intersection set from both ranges. Multiple equal values in both ranges.- Parameters:
result-secondRange-- Returns:
-
iterator
public java.util.Iterator<IExpr> iterator()
- Specified by:
iteratorin interfacejava.lang.Iterable<IExpr>
-
lastIndexOf
public int lastIndexOf(java.lang.Object match)
Returns the index of the first found object from the range end- Parameters:
match-- Returns:
-
map
public boolean map(java.util.Collection<IExpr> list, BiFunction<IExpr,IExpr,IExpr> function)
Append the result of the pairwise mapped elements to the givenlist. If the function evaluates tonullappend the current range element directly otherwise evaluate the next pair of elements- Parameters:
list-fromIndex-toIndex-
-
map
public IAST map(IAST list, Function<IExpr,IExpr> function)
Append the mapped ranges elements directly to the givenlist- Parameters:
list-function-
-
map
public IAST map(IAST list, IUnaryIndexFunction<IExpr,IExpr> function)
Append the mapped ranges elements directly to the givenlist- Parameters:
list-function-
-
mapLeft
public IAST mapLeft(IAST list, BiFunction<IExpr,IExpr,IExpr> binaryFunction, IExpr leftArg)
Append the mapped ranges elements directly to the givenlist- Parameters:
list-binaryFunction- binary functionleftArg- left argument of the binary functionsapply()method.
-
mapRight
public java.util.Collection<IExpr> mapRight(java.util.Collection<IExpr> list, BiFunction<IExpr,IExpr,IExpr> binaryFunction, IExpr rightArg)
Append the mapped ranges elements directly to the givenlist- Parameters:
list-binaryFunction- a binary functionleftArg- right argument of the binary functionsapply()method.
-
max
public IExpr max(java.util.Comparator<? super IExpr> comp)
Returns the largest value in the range
-
min
public IExpr min(java.util.Comparator<? super IExpr> comp)
Return the smallest value in the range
-
removeAll
public java.util.Collection<IExpr> removeAll(java.util.Collection<IExpr> list, 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.- See Also:
Range#filter(List, Predicate),Range#replaceAll(List, Function)
-
replaceAll
public java.util.Collection<IExpr> replaceAll(java.util.Collection<IExpr> list, Function<IExpr,? extends IExpr> function)
Apply the function to each element in the range and append the results to the list.- See Also:
Range#filter(List, Predicate),Range#removeAll(List, Predicate)
-
reverse
public java.util.Collection<IExpr> reverse(java.util.Collection<IExpr> list)
Append the ranges elements in reversed order to the givenlist- Parameters:
list-fromIndex-toIndex-
-
rotateLeft
public 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 thelist- Parameters:
list-n-
-
rotateRight
public 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 thelist- Parameters:
list-n-
-
size
public int size()
The size of this range gives the number of elements, which this range include- Returns:
-
sort
public IAST sort(ExprComparator 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.
-
toList
public java.util.List<IExpr> toList(java.util.List<IExpr> list)
Append the ranges elements to the givenlist- Parameters:
list-
-
-
DMelt 3.0 © DataMelt by jWork.ORG