public class SectoredRandomGrabArray<T,C extends RemoveRandomWithObject<T>> extends java.lang.Object implements RemoveRandom, RemoveRandomParent, RequestSelectionTreeNode
RemoveRandom.RemoveRandomReturn
Modifier and Type | Field and Description |
---|---|
protected ClientRequestSelector |
root |
Constructor and Description |
---|
SectoredRandomGrabArray(RemoveRandomParent parent,
ClientRequestSelector root) |
Modifier and Type | Method and Description |
---|---|
protected void |
addElement(T client,
C rga) |
void |
addGrabber(T client,
C requestGrabber,
ClientContext context)
Put a grabber.
|
void |
clearWakeupTime(ClientContext context)
When a request becomes fetchable, set all the wakeup times above it to 0.
|
T |
getClient(int x) |
C |
getGrabber(T client)
Get a grabber.
|
RequestSelectionTreeNode |
getParentGrabArray()
Return the parent RequestSelectionTreeNode or null if it's not in the tree or is the root (e.g.
|
long |
getWakeupTime(ClientContext context,
long now)
Unless this is a RandomGrabArrayItem, this will return the wakeup time for the subtree
rooted at this node.
|
protected int |
haveClient(T client) |
boolean |
isEmpty() |
void |
maybeRemove(RemoveRandom r,
ClientContext context)
Remove the specified RemoveRandom, and propagate upwards if the parent is now empty.
|
boolean |
reduceWakeupTime(long wakeupTime,
ClientContext context)
If the current cooldown time is larger than the parameter, reduce it and recurse up the
tree.
|
RemoveRandom.RemoveRandomReturn |
removeRandom(RandomGrabArrayItemExclusionList excluding,
ClientContext context,
long now)
Return a random RandomGrabArrayItem, or a time at which there will be one, or null
if the RGA is empty and should be removed by the parent.
|
void |
setParent(RemoveRandomParent newParent) |
int |
size() |
protected final ClientRequestSelector root
public SectoredRandomGrabArray(RemoveRandomParent parent, ClientRequestSelector root)
protected int haveClient(T client)
public T getClient(int x)
public void addGrabber(T client, C requestGrabber, ClientContext context)
public RemoveRandom.RemoveRandomReturn removeRandom(RandomGrabArrayItemExclusionList excluding, ClientContext context, long now)
RemoveRandom
removeRandom
in interface RemoveRandom
public boolean isEmpty()
public int size()
public void maybeRemove(RemoveRandom r, ClientContext context)
RemoveRandomParent
maybeRemove
in interface RemoveRandomParent
public void setParent(RemoveRandomParent newParent)
setParent
in interface RemoveRandom
public RequestSelectionTreeNode getParentGrabArray()
RequestSelectionTreeNode
getParentGrabArray
in interface RequestSelectionTreeNode
public long getWakeupTime(ClientContext context, long now)
RequestSelectionTreeNode
getWakeupTime
in interface RequestSelectionTreeNode
public boolean reduceWakeupTime(long wakeupTime, ClientContext context)
RequestSelectionTreeNode
reduceWakeupTime
in interface RequestSelectionTreeNode
public void clearWakeupTime(ClientContext context)
RequestSelectionTreeNode
clearWakeupTime
in interface RequestSelectionTreeNode