Object Ranges
-
- All Implemented Interfaces:
public class Ranges
A collection of extension functions that enrich ClosedRange.
-
-
Method Summary
Modifier and Type Method Description final <T extends Comparable<T>> ClosedRange<T>
rangeFromUnordered(T bound1, T bound2)
Creates a ClosedRange from a couple of unordered values. final <T extends Comparable<T>> Boolean
coincidesWith(ClosedRange<T> $self, ClosedRange<T> other)
Checks whether two ranges coincide. final <T extends Comparable<T>> Boolean
contains(ClosedRange<T> $self, ClosedRange<T> other)
Checks whether the range contains the other one. final <T extends Comparable<T>> Boolean
intersects(ClosedRange<T> $self, ClosedRange<T> other)
Checks whether the range intersects the other one. final <T extends Comparable<T>> ClosedRange<T>
intersect(ClosedRange<T> $self, ClosedRange<T> other)
Finds the intersection between two ranges, the resulting range may feature a single value (if the ranges only share an endpoint) or can be null, if they don't intersect at all. final <T extends Comparable<T>> Boolean
intersectsBoundsExcluded(ClosedRange<T> $self, ClosedRange<T> other)
Checks whether two ranges intersect, excluding their bounds (i.e. final <T extends Comparable<T>> List<ClosedRange<T>>
minus(ClosedRange<T> $self, ClosedRange<T> other)
Performs a subtraction between ranges. final <T extends Comparable<T>> List<ClosedRange<T>>
subtractAll(ClosedRange<T> $self, List<ClosedRange<T>> others)
Subtracts all the given ranges from the current one. final <V extends Vector2D<V>> ClosedRange<Double>
findExtremeCoordsOnX(List<V> $self)
Given a non-empty list of points represented as vectors, this method finds the extreme coordinates (i.e. final <V extends Vector2D<V>> ClosedRange<Double>
findExtremeCoordsOnY(List<V> $self)
Given a non-empty list of points represented as vectors, this method finds the extreme coordinates (i.e. -
-
Method Detail
-
rangeFromUnordered
final <T extends Comparable<T>> ClosedRange<T> rangeFromUnordered(T bound1, T bound2)
Creates a ClosedRange from a couple of unordered values.
-
coincidesWith
final <T extends Comparable<T>> Boolean coincidesWith(ClosedRange<T> $self, ClosedRange<T> other)
Checks whether two ranges coincide. It's a different way of checking if they're equals, which doesn't depend on their actual implementation. Note that the way you obtain a range may influence the actual class used, and you can have two coincident ranges which are not equal because of different classes.
-
contains
final <T extends Comparable<T>> Boolean contains(ClosedRange<T> $self, ClosedRange<T> other)
Checks whether the range contains the other one. This method is faster than checking if the range contains both of the endpoints of other.
-
intersects
final <T extends Comparable<T>> Boolean intersects(ClosedRange<T> $self, ClosedRange<T> other)
Checks whether the range intersects the other one.
-
intersect
final <T extends Comparable<T>> ClosedRange<T> intersect(ClosedRange<T> $self, ClosedRange<T> other)
Finds the intersection between two ranges, the resulting range may feature a single value (if the ranges only share an endpoint) or can be null, if they don't intersect at all.
-
intersectsBoundsExcluded
final <T extends Comparable<T>> Boolean intersectsBoundsExcluded(ClosedRange<T> $self, ClosedRange<T> other)
Checks whether two ranges intersect, excluding their bounds (i.e., excluding both ClosedRange.start and ClosedRange.endInclusive). This means false is returned in case the ranges share a single endpoint.
-
minus
final <T extends Comparable<T>> List<ClosedRange<T>> minus(ClosedRange<T> $self, ClosedRange<T> other)
Performs a subtraction between ranges. The operation can produce an empty list (e.g. if the current range is contained in the other one), a list featuring a single element, or a list featuring two elements (e.g. if the current range contains the other one).
-
subtractAll
final <T extends Comparable<T>> List<ClosedRange<T>> subtractAll(ClosedRange<T> $self, List<ClosedRange<T>> others)
Subtracts all the given ranges from the current one. See ClosedRange.minus.
-
findExtremeCoordsOnX
final <V extends Vector2D<V>> ClosedRange<Double> findExtremeCoordsOnX(List<V> $self)
Given a non-empty list of points represented as vectors, this method finds the extreme coordinates (i.e. min and max coordinates) on the X-axis, these are used to create the returned ClosedRange.
-
findExtremeCoordsOnY
final <V extends Vector2D<V>> ClosedRange<Double> findExtremeCoordsOnY(List<V> $self)
Given a non-empty list of points represented as vectors, this method finds the extreme coordinates (i.e. min and max coordinates) on the Y-axis, these are used to create the returned ClosedRange.
-
-
-
-