public class DeadlineHeapTimerState extends Object implements TimerState.Mutable
- constant polling time via indexOfNextDeadline()
- log(n) time to add or remove a timer
- log(n) time to change the repetition of a timer
The data structure is very similar to that used by PriorityQueue.TimerState.Mutable, TimerState.Static| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_INITIAL_CAPACITY |
REPETITION_SINGLE| Constructor and Description |
|---|
DeadlineHeapTimerState() |
DeadlineHeapTimerState(int initialCapacity) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(long id,
int type,
int repetition,
long time,
long timeout) |
int |
count() |
long |
deadline(int index) |
boolean |
hasTimer(long id) |
long |
id(int index) |
int |
indexById(long id) |
int |
indexOfNextDeadline() |
int |
nextRepetition(int index) |
void |
remove(int index) |
int |
repetition(int index) |
void |
repetition(int index,
int repetition) |
long |
time(int index) |
long |
timeout(int index) |
String |
toString() |
int |
type(int index) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitremoveByIdpublic static final int DEFAULT_INITIAL_CAPACITY
public DeadlineHeapTimerState()
public DeadlineHeapTimerState(int initialCapacity)
public int count()
count in interface TimerStatepublic int indexById(long id)
indexById in interface TimerStatepublic long id(int index)
id in interface TimerStatepublic int type(int index)
type in interface TimerStatepublic int repetition(int index)
repetition in interface TimerStatepublic long time(int index)
time in interface TimerStatepublic long timeout(int index)
timeout in interface TimerStatepublic long deadline(int index)
deadline in interface TimerStatepublic int nextRepetition(int index)
nextRepetition in interface TimerStatepublic boolean hasTimer(long id)
hasTimer in interface TimerStatepublic int indexOfNextDeadline()
indexOfNextDeadline in interface TimerStatepublic boolean add(long id,
int type,
int repetition,
long time,
long timeout)
add in interface TimerState.Mutablepublic void remove(int index)
remove in interface TimerState.Mutablepublic void repetition(int index,
int repetition)
repetition in interface TimerState.MutableCopyright © 2020 tools4j.org (Marco Terzer, Anton Anufriev). All Rights Reserved.