parent
8dee8c774b
commit
6572b08095
|
@ -128,16 +128,6 @@ public interface IntSet {
|
|||
@Override
|
||||
boolean equals(Object obj);
|
||||
|
||||
/**
|
||||
* Returns the single value contained in the set, if {@link #size} is 1;
|
||||
* otherwise, result is undefined. Check {@link #isNil()} before using
|
||||
* this function.
|
||||
*
|
||||
* @return the single value contained in the set, if {@link #size} is 1;
|
||||
* otherwise, result is undefined.
|
||||
*/
|
||||
int getSingleElement();
|
||||
|
||||
/**
|
||||
* Returns {@code true} if the set contains the specified element.
|
||||
*
|
||||
|
|
|
@ -416,28 +416,15 @@ public class IntervalSet implements IntSet {
|
|||
return intervals==null || intervals.isEmpty();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public int getSingleElement() {
|
||||
if ( intervals!=null && intervals.size()==1 ) {
|
||||
Interval I = intervals.get(0);
|
||||
if ( I.a == I.b ) {
|
||||
return I.a;
|
||||
}
|
||||
}
|
||||
return Token.INVALID_TYPE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the maximum value contained in the set if not isNil().
|
||||
* Otherwise, result is undefined.
|
||||
*
|
||||
* @return the maximum value contained in the set. If the set is empty,
|
||||
* result is undefined.
|
||||
* @return the maximum value contained in the set.
|
||||
* @throws RuntimeException if set is empty
|
||||
*/
|
||||
public int getMaxElement() {
|
||||
if ( isNil() ) {
|
||||
return Token.INVALID_TYPE;
|
||||
throw new RuntimeException("set is empty");
|
||||
}
|
||||
Interval last = intervals.get(intervals.size()-1);
|
||||
return last.b;
|
||||
|
@ -445,14 +432,13 @@ public class IntervalSet implements IntSet {
|
|||
|
||||
/**
|
||||
* Returns the minimum value contained in the set if not isNil().
|
||||
* Otherwise, result is undefined.
|
||||
*
|
||||
* @return the minimum value contained in the set. If the set is empty,
|
||||
* result is undefined.
|
||||
* @return the minimum value contained in the set.
|
||||
* @throws RuntimeException if set is empty
|
||||
*/
|
||||
public int getMinElement() {
|
||||
if ( isNil() ) {
|
||||
return Token.INVALID_TYPE;
|
||||
throw new RuntimeException("set is empty");
|
||||
}
|
||||
|
||||
return intervals.get(0).a;
|
||||
|
|
Loading…
Reference in New Issue