public class IntervalSet extends Object implements IntSet
Modifier and Type | Field and Description |
---|---|
static IntervalSet |
COMPLETE_CHAR_SET |
static IntervalSet |
EMPTY_SET |
protected List<Interval> |
intervals
The list of sorted, disjoint intervals.
|
protected boolean |
readonly |
Constructor and Description |
---|
IntervalSet(int... els) |
IntervalSet(IntervalSet set) |
IntervalSet(List<Interval> intervals) |
Modifier and Type | Method and Description |
---|---|
void |
add(int el)
Add a single element to the set.
|
protected void |
add(Interval addition) |
void |
add(int a,
int b)
Add interval; i.e., add all integers from a to b to set.
|
IntervalSet |
addAll(IntSet set)
Add all elements from incoming set to this set.
|
IntervalSet |
and(IntSet other)
Return a new set with the intersection of this set with other.
|
void |
clear() |
IntervalSet |
complement(int minElement,
int maxElement) |
IntervalSet |
complement(IntSet vocabulary)
Given the set of possible values (rather than, say UNICODE or MAXINT),
return a new set containing all elements in vocabulary, but not in
this.
|
boolean |
contains(int el)
Is el in any range of this set?
|
protected String |
elementName(String[] tokenNames,
int a) |
boolean |
equals(Object obj)
Are two IntervalSets equal? Because all intervals are sorted
and disjoint, equals is a simple linear walk over both lists
to make sure they are the same.
|
int |
get(int i)
Get the ith element of ordered set.
|
List<Interval> |
getIntervals()
Return a list of Interval objects.
|
int |
getMaxElement() |
int |
getMinElement()
Return minimum element >= 0
|
int |
getSingleElement()
If this set is a single integer, return it otherwise Token.INVALID_TYPE
|
int |
hashCode() |
boolean |
isNil()
return true if this set has no members
|
boolean |
isReadonly() |
static IntervalSet |
of(int a)
Create a set with a single element, el.
|
static IntervalSet |
of(int a,
int b)
Create a set with all ints within range [a..b] (inclusive)
|
static IntervalSet |
or(IntervalSet[] sets)
combine all sets in the array returned the or'd value
|
IntervalSet |
or(IntSet a) |
void |
remove(int el)
remove this element from this set
|
void |
setReadonly(boolean readonly) |
int |
size()
Return the size of this set (not the underlying implementation's
allocated memory size, for example).
|
IntervalSet |
subtract(IntSet other)
Compute this-other via this&~other.
|
int[] |
toArray() |
IntegerList |
toIntegerList() |
List<Integer> |
toList() |
Set<Integer> |
toSet() |
String |
toString() |
String |
toString(boolean elemAreChar) |
String |
toString(String[] tokenNames) |
public static final IntervalSet COMPLETE_CHAR_SET
public static final IntervalSet EMPTY_SET
protected boolean readonly
public IntervalSet(IntervalSet set)
public IntervalSet(int... els)
@NotNull public static IntervalSet of(int a)
public static IntervalSet of(int a, int b)
public void clear()
public void add(int el)
public void add(int a, int b)
protected void add(Interval addition)
public static IntervalSet or(IntervalSet[] sets)
public IntervalSet addAll(IntSet set)
IntSet
public IntervalSet complement(int minElement, int maxElement)
public IntervalSet complement(IntSet vocabulary)
complement
in interface IntSet
public IntervalSet subtract(IntSet other)
public IntervalSet or(IntSet a)
public IntervalSet and(IntSet other)
public boolean contains(int el)
public boolean isNil()
public int getSingleElement()
getSingleElement
in interface IntSet
public int getMaxElement()
public int getMinElement()
public boolean equals(Object obj)
public String toString()
public String toString(boolean elemAreChar)
public int size()
IntSet
public IntegerList toIntegerList()
public int get(int i)
public int[] toArray()
public void remove(int el)
IntSet
public boolean isReadonly()
public void setReadonly(boolean readonly)
Copyright © 1992–2014 ANTLR. All rights reserved.