T
- public class TimelineList<T>
extends java.lang.Object
implements java.io.Serializable
Modifier and Type | Class and Description |
---|---|
class |
TimelineList.TimeSegment
A time segment covers a span of time.
|
Constructor and Description |
---|
TimelineList() |
Modifier and Type | Method and Description |
---|---|
void |
add(long start,
long end,
T value) |
void |
add(long start,
T value)
Add the value at the given time, with a duration of forever.
|
void |
add(TimelineList timelineList) |
void |
add(TimelineList.TimeSegment timeSegment) |
boolean |
covered(long time)
Returns whether the timeline contains a segment that covers the specified time.
|
T |
get(long time)
Returns the value for the specified time, or null if a value isn't defined.
|
protected T |
get(long time,
boolean allowClosest,
boolean allowRollover) |
T |
getClosest(long time)
Returns the value for the given time, or the next defined value.
|
protected TimelineList.TimeSegment |
getSegment(int pos) |
TimelineList.TimeSegment |
getSegment(long time,
boolean allowClosest)
Returns the segment that contains the time.
|
TimelineList.TimeSegment |
getSegment(long time,
boolean allowClosest,
boolean allowRollover)
Returns the segment that contains the time.
|
java.util.List<TimelineList.TimeSegment> |
getSegments() |
protected int |
indexOf(long time,
boolean allowRollover)
Returns the index of the segment that covers the time, or comes next after the time.
|
void |
mergeSegments()
Merges together contiguous segments with the same value.
|
long |
nextEvent(long time)
Returns the next time that something interesting happens after the given time.
|
long |
nextEvent(long time,
boolean allowRollover) |
int |
size() |
void |
sort() |
java.lang.String |
toString() |
public int size()
public void sort()
protected int indexOf(long time, boolean allowRollover)
time
- allowRollover
- if the time is beyond the last segment, and this parameter is true, the first index will be returned.
Otherwise the last index of the list will be returned.protected TimelineList.TimeSegment getSegment(int pos)
public void add(long start, T value)
start
- value
- public void add(long start, long end, T value)
public void add(TimelineList.TimeSegment timeSegment)
public void add(TimelineList timelineList)
public boolean covered(long time)
time
- public T get(long time)
time
- public T getClosest(long time)
time
- protected T get(long time, boolean allowClosest, boolean allowRollover)
public TimelineList.TimeSegment getSegment(long time, boolean allowClosest)
time
- allowClosest
- public TimelineList.TimeSegment getSegment(long time, boolean allowClosest, boolean allowRollover)
time
- allowClosest
- public long nextEvent(long time)
time
- public long nextEvent(long time, boolean allowRollover)
public java.lang.String toString()
toString
in class java.lang.Object
public java.util.List<TimelineList.TimeSegment> getSegments()
public void mergeSegments()