public final class RulerUtils
extends java.lang.Object
Modifier | Constructor and Description |
---|---|
private |
RulerUtils() |
Modifier and Type | Method and Description |
---|---|
static int |
calculateViolations(Ruler ruler)
Calculates the ruler overall violation.
|
static java.util.List<java.lang.Integer> |
getMeasurableDistances(Ruler ruler,
boolean includeOneLengthDistance)
Gets the measurable distances.
|
static boolean |
isValid(Ruler ruler)
Checks if a given ruler is valid.
|
public static boolean isValid(Ruler ruler)
Checks if a given ruler is valid.
ruler
- the rulertrue
, if ruler is valid (all measurable distances are distinct)public static int calculateViolations(Ruler ruler)
Calculates the ruler overall violation.
The violation v(d) of a distance d in a n-mark ruler is the number of times distance d appears between two marks in the ruler. (…) The overall violation v of a n-mark ruler is simply the sum of the violations of its distances. [source]
ruler
- the rulerpublic static java.util.List<java.lang.Integer> getMeasurableDistances(Ruler ruler, boolean includeOneLengthDistance)
Gets the measurable distances. Distances in the result list are ordered as they appear in the ruler.
ruler
- the rulerincludeOneLengthDistance
- the flag indicating whether or not to include a distance of one unit