|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object edu.ksu.cis.cooprobot.simulator.communication.PriorityQueue
This PriorityQueue class is used to keep Message
in Queue in ascending order
of receivedTime. Robots have their own priorityqueue. It keeps incoming message
and wait for the owner call getMessage
operation to retrive
message from the queue.
This queue is implemented by LinkList. Message will be added to a queue in the right order.
Field Summary | |
private LinkedList |
list
A list of messages |
Constructor Summary | |
PriorityQueue()
PriorityQueue Constructor |
Method Summary | |
void |
add(Message msg)
Adding message to a queue in order of receivedTime |
Message |
get(int index)
Get specific message from the queue without deleting |
int |
getInsertIndex(long time)
Helper method to get the right adding position. |
boolean |
isEmpty()
Check if queue is empty |
Message |
remove(int index)
Removing specific message from the queue |
int |
size()
Get size of priority queue |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private LinkedList list
Constructor Detail |
public PriorityQueue()
Method Detail |
public void add(Message msg)
msg
- - message adding to a queuepublic int getInsertIndex(long time)
time
- - receive time of new message adding to a queuepublic Message remove(int index)
index
- - the position of removing message
public Message get(int index)
index
- - the position of message
public int size()
public boolean isEmpty()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |