Skip to content
Permalink
Browse files

[#353] Add documentation to Range about it being inclusive

  • Loading branch information...
lukaseder committed Jun 24, 2019
1 parent f754836 commit daf778b41932915d5656bffa5e9d7985f4483021
@@ -23,15 +23,17 @@
* Ranges can be (partially) unbounded if one or both of their bounds are <code>null</code>,
* which corresponds to "infinity", if <code>T</code> is a type that doesn't already have an
* infinity value, such as {@link Double#POSITIVE_INFINITY} or {@link Double#NEGATIVE_INFINITY}.
* <p>
* Ranges are inclusive on both bounds.
*
* @author Lukas Eder
*/
public class Range<T extends Comparable<T>> extends Tuple2<T, T> {

private static final long serialVersionUID = 1L;

public Range(T v1, T v2) {
super(r(v1, v2));
public Range(T lowerInclusive, T upperInclusive) {
super(r(lowerInclusive, upperInclusive));
}

public Range(Tuple2<T, T> tuple) {
@@ -94,8 +96,8 @@ public boolean overlaps(Range<T> other) {
* range(1, 3).overlaps(5, 8)
* </pre></code>
*/
public boolean overlaps(T t1, T t2) {
return overlaps(new Range<>(t1, t2));
public boolean overlaps(T lowerInclusive, T upperInclusive) {
return overlaps(new Range<>(lowerInclusive, upperInclusive));
}

/**
@@ -158,8 +160,8 @@ public boolean overlaps(T t1, T t2) {
* range(1, 3).intersect(5, 8)
* </pre></code>
*/
public Optional<Range<T>> intersect(T t1, T t2) {
return intersect(new Range<>(t1, t2));
public Optional<Range<T>> intersect(T lowerInclusive, T upperInclusive) {
return intersect(new Range<>(lowerInclusive, upperInclusive));
}

/**
@@ -1377,10 +1377,10 @@ static Tuple0 tuple() {
}

/**
* Create a new range.
* Create a new range with inclusive bounds.
*/
static <T extends Comparable<T>> Range<T> range(T t1, T t2) {
return new Range<>(t1, t2);
static <T extends Comparable<T>> Range<T> range(T lowerInclusive, T upperInclusive) {
return new Range<>(lowerInclusive, upperInclusive);
}

/**
@@ -23,15 +23,17 @@
* Ranges can be (partially) unbounded if one or both of their bounds are <code>null</code>,
* which corresponds to "infinity", if <code>T</code> is a type that doesn't already have an
* infinity value, such as {@link Double#POSITIVE_INFINITY} or {@link Double#NEGATIVE_INFINITY}.
* <p>
* Ranges are inclusive on both bounds.
*
* @author Lukas Eder
*/
public class Range<T extends Comparable<T>> extends Tuple2<T, T> {

private static final long serialVersionUID = 1L;

public Range(T v1, T v2) {
super(r(v1, v2));
public Range(T lowerInclusive, T upperInclusive) {
super(r(lowerInclusive, upperInclusive));
}

public Range(Tuple2<T, T> tuple) {
@@ -94,8 +96,8 @@ public boolean overlaps(Range<T> other) {
* range(1, 3).overlaps(5, 8)
* </pre></code>
*/
public boolean overlaps(T t1, T t2) {
return overlaps(new Range<>(t1, t2));
public boolean overlaps(T lowerInclusive, T upperInclusive) {
return overlaps(new Range<>(lowerInclusive, upperInclusive));
}

/**
@@ -158,8 +160,8 @@ public boolean overlaps(T t1, T t2) {
* range(1, 3).intersect(5, 8)
* </pre></code>
*/
public Optional<Range<T>> intersect(T t1, T t2) {
return intersect(new Range<>(t1, t2));
public Optional<Range<T>> intersect(T lowerInclusive, T upperInclusive) {
return intersect(new Range<>(lowerInclusive, upperInclusive));
}

/**
@@ -1377,10 +1377,10 @@ static Tuple0 tuple() {
}

/**
* Create a new range.
* Create a new range with inclusive bounds.
*/
static <T extends Comparable<T>> Range<T> range(T t1, T t2) {
return new Range<>(t1, t2);
static <T extends Comparable<T>> Range<T> range(T lowerInclusive, T upperInclusive) {
return new Range<>(lowerInclusive, upperInclusive);
}

/**

0 comments on commit daf778b

Please sign in to comment.
You can’t perform that action at this time.