forked from jasder/antlr
Allow var args in ctor of IntervalSet
This commit is contained in:
parent
f278d3b453
commit
6e4cba131a
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue