Allow var args in ctor of IntervalSet

This commit is contained in:
Terence Parr 2012-02-11 15:30:54 -08:00
parent f278d3b453
commit 6e4cba131a
1 changed files with 11 additions and 7 deletions

View File

@ -28,8 +28,7 @@
*/
package org.antlr.v4.runtime.misc;
import org.antlr.v4.runtime.Lexer;
import org.antlr.v4.runtime.Token;
import org.antlr.v4.runtime.*;
import java.util.*;
@ -56,11 +55,6 @@ public class IntervalSet implements IntSet {
protected boolean readonly;
/** Create a set with no elements */
public IntervalSet() {
intervals = new ArrayList<Interval>(2); // most sets are 1 or 2 elements
}
public IntervalSet(List<Interval> intervals) {
this.intervals = intervals;
}
@ -70,6 +64,16 @@ public class IntervalSet implements IntSet {
addAll(set);
}
public IntervalSet(int... els) {
if ( els==null ) {
intervals = new ArrayList<Interval>(2); // most sets are 1 or 2 elements
}
else {
intervals = new ArrayList<Interval>(els.length);
for (int e : els) add(e);
}
}
/** Create a set with a single element, el. */
@NotNull
public static IntervalSet of(int a) {