Package org.antlr.v4.runtime.misc
Class Interval
java.lang.Object
org.antlr.v4.runtime.misc.Interval
An immutable inclusive interval a..b
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanAre two intervals adjacent such as 0..41 and 42..42?Return the interval with elements fromthisnot inother;othermust not be totally enclosed (properly contained) withinthis, which would result in two disjoint intervals instead of the single one returned by this method.booleanAre both ranges disjoint? I.e., no overlap?booleaninthashCode()intersection(Interval other) Return the interval in common between this and ointlength()return number of elements between a and b inclusively.static Intervalof(int a, int b) Returns a shared instance whena == band0 <= a <= INTERVAL_POOL_MAX_VALUE; otherwise a new interval.booleanproperlyContains(Interval other) booleanstartsAfter(Interval other) Does this.a start after other.b? May or may not be disjointbooleanstartsAfterDisjoint(Interval other) Does this start completely after other? DisjointbooleanstartsAfterNonDisjoint(Interval other) Does this start after other? NonDisjointbooleanstartsBeforeDisjoint(Interval other) Does this start completely before other? DisjointbooleanstartsBeforeNonDisjoint(Interval other) Does this start at or before other? NondisjointtoString()Return the interval computed from combining this and other
-
Field Details
-
INTERVAL_POOL_MAX_VALUE
public static final int INTERVAL_POOL_MAX_VALUE- See Also:
-
INVALID
-
cache
Sharedn..ninstances for0..INTERVAL_POOL_MAX_VALUE. Filled during class initialization (JLS 12.4.2) soof(int, int)never publishes a slot under a data race. Upstream #4902 deleted this table because the previous lazy fill was not thread-safe and could handCommonToken.getText()a wrong range; eager init keeps the allocation win without that race. -
a
public final int aThe start of the interval. -
b
public final int bThe end of the interval (inclusive).
-
-
Constructor Details
-
Interval
public Interval(int a, int b)
-
-
Method Details
-
of
Returns a shared instance whena == band0 <= a <= INTERVAL_POOL_MAX_VALUE; otherwise a new interval. Callers must treat the result as immutable. -
length
public int length()return number of elements between a and b inclusively. x..x is length 1. if b < a, then length is 0. 9..10 has length 2. -
equals
-
hashCode
public int hashCode() -
startsBeforeDisjoint
Does this start completely before other? Disjoint -
startsBeforeNonDisjoint
Does this start at or before other? Nondisjoint -
startsAfter
Does this.a start after other.b? May or may not be disjoint -
startsAfterDisjoint
Does this start completely after other? Disjoint -
startsAfterNonDisjoint
Does this start after other? NonDisjoint -
disjoint
Are both ranges disjoint? I.e., no overlap? -
adjacent
Are two intervals adjacent such as 0..41 and 42..42? -
properlyContains
-
union
Return the interval computed from combining this and other -
intersection
Return the interval in common between this and o -
differenceNotProperlyContained
Return the interval with elements fromthisnot inother;othermust not be totally enclosed (properly contained) withinthis, which would result in two disjoint intervals instead of the single one returned by this method. -
toString
-