public class IntervalSet extends Object implements IntSet
Modifier and Type | Field and Description |
---|---|
static IntervalSet |
COMPLETE_SET |
protected List<Interval> |
intervals
The list of sorted, disjoint intervals.
|
Constructor and Description |
---|
IntervalSet()
Create a set with no elements
|
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.
|
void |
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.
|
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 |
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 Label.INVALID
|
boolean |
isNil()
return true if this set has no members
|
boolean |
member(int el)
Is el in any range of this set?
|
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)
|
IntSet |
or(IntSet a)
TODO: implement this!
|
void |
remove(int el)
remove this element from this set
|
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() |
List<Integer> |
toList() |
BitSet |
toRuntimeBitSet() |
String |
toString() |
String |
toString(Grammar g) |
public static final IntervalSet COMPLETE_SET
public static IntervalSet of(int a)
public static IntervalSet of(int a, int b)
public void add(int el)
public void add(int a, int b)
protected void add(Interval addition)
public void 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 and(IntSet other)
public boolean member(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 int size()
IntSet
public int get(int i)
public int[] toArray()
public BitSet toRuntimeBitSet()
Copyright © 1992–2015 ANTLR. All rights reserved.