Code example for LinkedList

Methods: offer, peek

0
            if (e.getRefQueue() != null && e.getRefQueue() != this) {
                return; 
            } 
            // Reference to request. 
            e.setRefQueue(this);
            this.queue.offer(e);
            Collections.sort(this.queue);
            // Leader is changed. 
            if (this.queue.peek() == e) {
                this.leader = null;
                this.available.signal();
            } 
        } 
        finally { 
            lock.unlock();
        } 
    } 
 
 
    public int size() { 
        final Lock lock = this.lock;