Code example for PriorityQueue

Methods: peek, size

0
        if (newPresentTime <= presentTime)
            throw new IllegalArgumentException();
 
        presentTime = newPresentTime;
 
        while (sendQueue.size() > 0
            && sendQueue.peek().getDelay() <= presentTime) {
            NetworkRequest nextRequest = sendQueue.poll();
            clients.get(nextRequest.getTo()).receiveNetworkEvent(nextRequest);
        } 
    } 
 
    public void addClient(NetworkEventHandler remote) {
        if (!clients.containsKey(remote.getUser().getJID())) {
            clients.put(remote.getUser().getJID(), remote);
        } 
    } 
 
    public void removeClient(NetworkEventHandler remote) {
        clients.remove(remote.getUser().getJID());
    }