peersim.edsim
Interface PriorityQ

All Known Implementing Classes:
Heap

public interface PriorityQ

The interface to be implemented by the event queue of the evend based engine. An implementation must also provide the standard cosntructor required by any peersim components: one that takes a String argument, the component name in the configuration.


Nested Class Summary
static class PriorityQ.Event
          Return type of removeFirst().
 
Method Summary
 void add(long time, java.lang.Object event, Node node, byte pid)
          Add a new event, to be scheduled at the specified time.
 void add(long time, java.lang.Object event, Node node, byte pid, long priority)
          Add a new event, to be scheduled at the specified time, specifying also the priority of the event, should there be other events scheduled at the same time.
 long maxPriority()
          Maximal value of priority this interpretation can deal with.
 long maxTime()
          Maximal value of time this interpretation can represent.
 PriorityQ.Event removeFirst()
          Removes the first event in the heap and returns it.
 int size()
          Returns the current number of events in the queue.
 

Method Detail

size

int size()
Returns the current number of events in the queue.


add

void add(long time,
         java.lang.Object event,
         Node node,
         byte pid)
Add a new event, to be scheduled at the specified time. If there are other events scheduled at the same time, then the time of execution if this event relative to the other events is unspecified.

Parameters:
time - The time at which this event should be scheduled. It is guaranteed to be non-negative (so no extra checks are needed)
event - the object describing the event
node - the node at which the event has to be delivered
pid - the protocol that handles the event

add

void add(long time,
         java.lang.Object event,
         Node node,
         byte pid,
         long priority)
Add a new event, to be scheduled at the specified time, specifying also the priority of the event, should there be other events scheduled at the same time. If both time and priority is the same for an event, then the scheduling order is unspecified.

Parameters:
time - The time at which this event should be scheduled. It is guaranteed to be non-negative (so no extra checks are needed)
event - the object describing the event
node - the node at which the event has to be delivered
pid - the protocol that handles the event
priority - if for two events the "time" value is the same, this value should be used to order them. Lower value means higher priority. Like with time, non-negativity as assumed.

removeFirst

PriorityQ.Event removeFirst()
Removes the first event in the heap and returns it. The returned object is not guaranteed to be a freshly generated object, that is, we allow for an implementation that keeps one copy of an event object and always returns a reference to that copy.

Returns:
first event or null if size is zero

maxTime

long maxTime()
Maximal value of time this interpretation can represent.


maxPriority

long maxPriority()
Maximal value of priority this interpretation can deal with. That is, the number of different priority levels is maxPriority()+1 because 0 is also a valid level.

See Also:
add(long,Object,Node,byte,long)