Package manifold.collections.api.range
Interface Sequential<E extends Sequential<E,S,U>,S,U>
-
- Type Parameters:
E- The implementing type e.g., Rational or Length (recursive type)S- The step type e.g., RationalU- The unit type of the step e.g., Void or LengthUnit
- All Superinterfaces:
Comparable<E>
public interface Sequential<E extends Sequential<E,S,U>,S,U> extends Comparable<E>
ImplementSequentialif the set of possible instances of your type are a sequence, whereby given an arbitrary instance of the type and some step or increment value, the next instance can be computed.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description EnextInSequence(S step, U unit)Given astepandunitproduces the next instance in the sequence.EnextNthInSequence(S step, U unit, int index)Given astep,unit, andindexproduce the next instance in the sequence.EpreviousInSequence(S step, U unit)Given astepandunitproduces the previous instance in the sequence.EpreviousNthInSequence(S step, U unit, int index)Given astep,unit, andindexproduce the previous instance in the sequence.-
Methods inherited from interface java.lang.Comparable
compareTo
-
-
-
-
Method Detail
-
nextInSequence
E nextInSequence(S step, U unit)
Given astepandunitproduces the next instance in the sequence. For instance, given a Length value of1 meter, a step value of5, and a unit ofCentimeter, the next value in the sequence is1.05 meters.- Parameters:
step- A value indicating the number of units separating this instance from the next one in the sequence.unit- Specifies the unit of thestepfor instanceinchormonth. Note if the unit type isVoid, the unit value is insignificant and will have a null value.- Returns:
- The next instance separated by
stepunits from this instance.
-
nextNthInSequence
E nextNthInSequence(S step, U unit, int index)
Given astep,unit, andindexproduce the next instance in the sequence. For instance, given a Length value of1 meter, a step value of5, a unit ofCentimeter, and an index of2, the next value in the sequence is1.10 meters.- Parameters:
step- A value indicating the number of units separating this instance from the next one in the sequence.unit- Specifies the unit of thestepfor instanceinchormonth. Note if the unit type isVoid, the unit value is insignificant and will have a null value.index- A offset in terms ofstepandunit, typically1.- Returns:
- The next instance separated by
index * step * unitfrom this instance.
-
previousInSequence
E previousInSequence(S step, U unit)
Given astepandunitproduces the previous instance in the sequence. For instance, given a Length value of1 meter, a step value of5, and a unit ofCentimeter, the previous value in the sequence is0.95 meters.- Parameters:
step- A value indicating the number of units separating this instance from the previous one in the sequence.unit- Specifies the unit of thestepfor instanceinchormonth. Note if the unit type isVoid, the unit value is insignificant and will have a null value.- Returns:
- The previous instance separated by
stepunits from this instance.
-
previousNthInSequence
E previousNthInSequence(S step, U unit, int index)
Given astep,unit, andindexproduce the previous instance in the sequence. For instance, given a Length value of1 meter, a step value of5, a unit ofCentimeter, and an index of2, the previous value in the sequence is0.90 meters.- Parameters:
step- A value indicating the number of units separating this instance from the previous one in the sequence.unit- Specifies the unit of thestepfor instanceinchormonth. Note if the unit type isVoid, the unit value is insignificant and will have a null value.index- A offset in terms ofstepandunit, typically1.- Returns:
- The previous instance separated by
index * step * unitfrom this instance.
-
-