Code example for PriorityQueue

Methods: add

0
  public void placeInstructionMessageOntoQueue(InstructionMessage instructionMessage) throws InvalidExceptionMessage { 
    if (!instructionMessage.isValid()) { 
      throw new InvalidExceptionMessage(); 
    } 
    else {       
      queue.add(instructionMessage); 
    } 
  } 
   
  public void removeInstructionFromTheQueue(InstructionMessage instructionMessage) { 
    queue.remove(instructionMessage); 
  } 
   
  public boolean isQueueEmpty() { 
    return queue.isEmpty();  
  } 
 
  InstructionMessage retrieveInstructionMessageAtFrontOfQueue() { 
    return queue.poll(); 
  } 
}