T
- the type of the value of ControllableQueue.DelayNode
public class ControllableQueue<T> extends Object
ControllableQueue.DelayNode
s.
It supports tick the time forward and pop nodes whose delay is smaller than the past time.Modifier and Type | Class and Description |
---|---|
static class |
ControllableQueue.DelayNode<T>
A delay node in delta queue which records the value
and the total delay (which is the original delay plus the past time).
|
Constructor and Description |
---|
ControllableQueue()
Constructs a new
ControllableQueue . |
Modifier and Type | Method and Description |
---|---|
void |
add(long delay,
T value)
Adds a new node into the queue.
|
long |
getHeadDelay() |
T |
getHeadValue() |
boolean |
isEmpty() |
T |
pop() |
boolean |
remove(T element)
Removes an element.
|
void |
tick(long duration)
Jumps to a future time period.
|
String |
toString() |
public ControllableQueue()
ControllableQueue
.public boolean isEmpty()
public T getHeadValue()
public long getHeadDelay()
public void add(long delay, T value)
delay
- the delay in millisecondsvalue
- the valuepublic void tick(long duration)
duration
- the time period to jumppublic T pop()
public boolean remove(T element)
element
- an elementCopyright © 2023. All Rights Reserved.