public class Span extends java.lang.Object implements java.lang.Iterable<java.lang.Long>, java.lang.Comparable<Span>, java.io.Serializable
| Modifier and Type | Field and Description |
|---|---|
long |
begin
The beginning of this span, inclusive.
|
long |
end
The end of this span, exclusive.
|
| Constructor and Description |
|---|
Span(long begin,
long end)
Create a new span from two values.
|
| Modifier and Type | Method and Description |
|---|---|
int |
compareTo(Span o) |
boolean |
contains(int i)
If true, the value is contined in the span.
|
boolean |
contains(Span other)
Returns true if this span contains the argument span.
|
boolean |
equals(java.lang.Object o) |
static Span |
fromValues(long a,
long b)
Create a span from two values.
|
int |
hashCode() |
static Span |
intersect(Span a,
Span b)
Returns the intersection between two spans.
|
java.util.Iterator<java.lang.Long> |
iterator() |
long |
length()
|
long |
middle()
The middle (average?) of the span.
|
long |
overlap(Span other)
Returns the amount of overlap between this span and the argument span.
|
boolean |
overlaps(Span other)
Returns true if there's any overlap between this span and the argument span.
|
java.lang.String |
toString() |
public final long begin
public final long end
public Span(long begin,
long end)
begin - The beginning of the span, inclusive.end - The end of the span, exclusive.public boolean contains(Span other)
other - The other span.public long length()
public boolean overlaps(Span other)
other - The other span to compare this span to.public long overlap(Span other)
other - The argument span.public static Span intersect(Span a, Span b)
a - The first span.b - The second span.public static Span fromValues(long a, long b)
a - One of the values (not necessarily the smaller).b - The other value (not necessarily bigger).public boolean equals(java.lang.Object o)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.Objectpublic java.util.Iterator<java.lang.Long> iterator()
iterator in interface java.lang.Iterable<java.lang.Long>public int compareTo(Span o)
compareTo in interface java.lang.Comparable<Span>public boolean contains(int i)
i - The value we are checking.public long middle()