diff --git a/runtime/Java/src/org/antlr/v4/runtime/misc/IntSet.java b/runtime/Java/src/org/antlr/v4/runtime/misc/IntSet.java index d4d499ff2..9edd1c3ea 100644 --- a/runtime/Java/src/org/antlr/v4/runtime/misc/IntSet.java +++ b/runtime/Java/src/org/antlr/v4/runtime/misc/IntSet.java @@ -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. * diff --git a/runtime/Java/src/org/antlr/v4/runtime/misc/IntervalSet.java b/runtime/Java/src/org/antlr/v4/runtime/misc/IntervalSet.java index 8ed76c6d7..57ccba055 100644 --- a/runtime/Java/src/org/antlr/v4/runtime/misc/IntervalSet.java +++ b/runtime/Java/src/org/antlr/v4/runtime/misc/IntervalSet.java @@ -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;