public class Interval extends Object
| Modifier and Type | Field and Description |
|---|---|
int |
a
The start of the interval.
|
int |
b
The end of the interval (inclusive).
|
static int |
INTERVAL_POOL_MAX_VALUE |
static Interval |
INVALID |
| Constructor and Description |
|---|
Interval(int a,
int b) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
adjacent(Interval other)
Are two intervals adjacent such as 0..41 and 42..42?
|
Interval |
differenceNotProperlyContained(Interval other)
Return the interval with elements from
this not in other;
other must not be totally enclosed (properly contained)
within this, which would result in two disjoint intervals
instead of the single one returned by this method. |
boolean |
disjoint(Interval other)
Are both ranges disjoint? I.e., no overlap?
|
boolean |
equals(Object o) |
int |
hashCode() |
Interval |
intersection(Interval other)
Return the interval in common between this and o
|
int |
length()
return number of elements between a and b inclusively.
|
static Interval |
of(int a,
int b)
Interval objects are used readonly so share all with the
same single value a==b up to some max size.
|
boolean |
properlyContains(Interval other) |
boolean |
startsAfter(Interval other)
Does this.a start after other.b? May or may not be disjoint
|
boolean |
startsAfterDisjoint(Interval other)
Does this start completely after other? Disjoint
|
boolean |
startsAfterNonDisjoint(Interval other)
Does this start after other? NonDisjoint
|
boolean |
startsBeforeDisjoint(Interval other)
Does this start completely before other? Disjoint
|
boolean |
startsBeforeNonDisjoint(Interval other)
Does this start at or before other? Nondisjoint
|
String |
toString() |
Interval |
union(Interval other)
Return the interval computed from combining this and other
|
public static final int INTERVAL_POOL_MAX_VALUE
public static final Interval INVALID
public final int a
public final int b
public static Interval of(int a, int b)
public int length()
public boolean startsBeforeDisjoint(Interval other)
public boolean startsBeforeNonDisjoint(Interval other)
public boolean startsAfter(Interval other)
public boolean startsAfterDisjoint(Interval other)
public boolean startsAfterNonDisjoint(Interval other)
public boolean disjoint(Interval other)
public boolean adjacent(Interval other)
public boolean properlyContains(Interval other)
public Interval union(Interval other)
public Interval intersection(Interval other)
public Interval differenceNotProperlyContained(Interval other)
this not in other;
other must not be totally enclosed (properly contained)
within this, which would result in two disjoint intervals
instead of the single one returned by this method.Copyright © 1992–2024 Daniel Sun. All rights reserved.