jet.runtime
Class ProgressionUtil

java.lang.Object
  extended by jet.runtime.ProgressionUtil

public class ProgressionUtil
extends java.lang.Object


Method Summary
static int getProgressionFinalElement(int start, int end, int increment)
          Calculates the final element of a bounded arithmetic progression, i.e.
static long getProgressionFinalElement(long start, long end, long increment)
          Calculates the final element of a bounded arithmetic progression, i.e.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getProgressionFinalElement

public static int getProgressionFinalElement(int start,
                                             int end,
                                             int increment)
Calculates the final element of a bounded arithmetic progression, i.e. the last element of the progression which is in the range from start to end in case of a positive increment, or from end to start in case of a negative increment.

No validation on passed parameters is performed. The given parameters should satisfy the condition: either increment > 0 and start <= end, or increment < 0 and start >= end.

Parameters:
start - first element of the progression
end - ending bound for the progression
increment - increment, or difference of successive elements in the progression
Returns:
the final element of the progression

getProgressionFinalElement

public static long getProgressionFinalElement(long start,
                                              long end,
                                              long increment)
Calculates the final element of a bounded arithmetic progression, i.e. the last element of the progression which is in the range from start to end in case of a positive increment, or from end to start in case of a negative increment.

No validation on passed parameters is performed. The given parameters should satisfy the condition: either increment > 0 and start <= end, or increment < 0 and start >= end.

Parameters:
start - first element of the progression
end - ending bound for the progression
increment - increment, or difference of successive elements in the progression
Returns:
the final element of the progression