Documentation of 'org.matheclipse.core.eval.Range' Java class
Range
org.matheclipse.core.eval

Class Range

  • All Implemented Interfaces:
    java.lang.Iterable<IExpr>
    Direct Known Subclasses:
    ASTRange


    public class Range
    extends java.lang.Object
    implements java.lang.Iterable<IExpr>
    Create a range for a given List instance
    • Constructor Summary

      Constructors 
      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.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      boolean all(Predicate<IExpr> predicate)
      Returns true if the predicate returns true for all elements in the range.
      boolean all(Predicate<IExpr>[] predicates)
      Returns true if all branch predicates return true for all elements in the range.
      boolean any(Predicate<IExpr> predicate)
      Returns true if the predicate returns true for at least one element in the range.
      boolean any(Predicate<IExpr>[] predicates)
      Returns true if at least one branch predicate returns true for all elements in the range.
      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.
      java.util.Collection<IExpr> complement(java.util.Collection<IExpr> result, Range secondRange)
      Create the (unordered) complement set from both ranges
      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(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.
      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.
      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.
      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.
      int findAdjacent(java.lang.Object match)
      Locates the first pair of adjacent elements in a range that are the same value.
      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 index start and ending at the ranges upper limit.
      int findAdjacent(Predicate<IExpr> predicate)
      Locates the first pair of adjacent elements in a range that match the given predicate
      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.
      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.
      IExpr forEach(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(Predicate<IExpr> predicate) 
      int indexOf(Predicate<IExpr> predicate, int start)
      Returns the index of the first found object that match the predicate
      java.util.Collection<IExpr> intersection(java.util.Collection<IExpr> result, Range secondList)
      Create the (unordered) intersection set from both ranges.
      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(Predicate<IExpr> predicate) 
      boolean map(java.util.Collection<IExpr> list, BiFunction<IExpr,IExpr,IExpr> function)
      Append the result of the pairwise mapped elements to the given list.
      IAST map(IAST list, Function<IExpr,IExpr> function)
      Append the mapped ranges elements directly to the given list
      IAST map(IAST list, IUnaryIndexFunction<IExpr,IExpr> function)
      Append the mapped ranges elements directly to the given list
      IAST mapLeft(IAST list, 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, 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, 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 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(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 given list
      java.util.Collection<IExpr> union(java.util.Collection<IExpr> result, Range secondList)
      Create the (unordered) union set from both ranges.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.lang.Iterable

        forEach, spliterator
    • 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 if start isn't valid.
        Parameters:
        list -
        start -
        end -
      • Range

        public Range(IAST list,
                     int start,
                     int end)
        Construct a range for a List throws IndexOutOfBoundsException if start or end aren'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 predicate
        restList - the elements which don't match the predicate
        predicate - 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 predicate
        restList - the elements which don't match the predicate
        function - 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 index start 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:
        iterator in interface java.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 given list. If the function evaluates to null append 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 given list
        Parameters:
        list -
        function -
      • mapLeft

        public IAST mapLeft(IAST list,
                            BiFunction<IExpr,IExpr,IExpr> binaryFunction,
                            IExpr leftArg)
        Append the mapped ranges elements directly to the given list
        Parameters:
        list -
        binaryFunction - binary function
        leftArg - left argument of the binary functions apply() 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 given list
        Parameters:
        list -
        binaryFunction - a binary function
        leftArg - right argument of the binary functions apply() 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 given list
        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 the list
        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 the list
        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.
      • toArray

        public IExpr[] toArray(IExpr[] array)
      • toList

        public java.util.List<IExpr> toList(java.util.List<IExpr> list)
        Append the ranges elements to the given list
        Parameters:
        list -
      • union

        public java.util.Collection<IExpr> union(java.util.Collection<IExpr> result,
                                                 Range secondList)
        Create the (unordered) union set from both ranges. Multiple equal values in the given ranges are reduced to one value in the result.
        Parameters:
        result -
        secondRange -
        Returns:

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.