public class Span extends Object implements Serializable, Iterable<Integer>
Constructor and Description |
---|
Span(int s,
int e)
This assumes that s <= e.
|
Span(Span... spans)
Creates a span that encloses all spans in the argument list.
|
Modifier and Type | Method and Description |
---|---|
boolean |
contains(int i)
Returns true if i is inside this span.
|
boolean |
contains(Span otherSpan)
Returns true if this span contains otherSpan.
|
static int |
distance(Span a,
Span b)
Returns the smallest distance between two spans.
|
int |
end() |
boolean |
equals(Object other) |
void |
expandToInclude(Span otherSpan) |
static Span |
fromValues(int val1,
int val2)
Safe way to construct Spans if you're not sure which value is higher.
|
static Span |
fromValues(Object... values) |
int |
hashCode() |
boolean |
isAfter(Span otherSpan)
Returns true if this span starts after the otherSpan's end.
|
boolean |
isBefore(Span otherSpan)
Returns true if this span ends before the otherSpan starts.
|
Iterator<Integer> |
iterator() |
static int |
overlap(Span spanA,
Span spanB) |
static boolean |
overlaps(Span spanA,
Collection<Span> spanB) |
static boolean |
overlaps(Span spanA,
Span spanB) |
void |
setEnd(int e) |
void |
setStart(int s) |
int |
size() |
int |
start() |
String |
toString() |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
forEach, spliterator
public Span(int s, int e)
public Span(Span... spans)
public static Span fromValues(int val1, int val2)
public int start()
public int end()
public void setStart(int s)
public void setEnd(int e)
public void expandToInclude(Span otherSpan)
public boolean contains(Span otherSpan)
public boolean contains(int i)
public boolean isBefore(Span otherSpan)
IllegalArgumentException
- if either span contains the other spanpublic boolean isAfter(Span otherSpan)
IllegalArgumentException
- if either span contains the other spanpublic int size()
public static boolean overlaps(Span spanA, Collection<Span> spanB)