@CanIgnoreReturnValue @Override public boolean addAll(Collection<? extends E> newElements) { boolean modified = false; for (E element : newElements) { offer(element); modified = true; } return modified; }
/** * Adds the given element to this queue. If this queue has a maximum size, * after adding {@code element} the queue will automatically evict its * greatest element (according to its comparator), which may be {@code * element} itself. * * @return {@code true} always */ @CanIgnoreReturnValue @Override public boolean add(E element) { offer(element); return true; }
/** * Builds a new min-max priority queue using the previously specified * options, and having the given initial elements. */ public <T extends B> MinMaxPriorityQueue<T> create(Iterable<? extends T> initialContents) { MinMaxPriorityQueue<T> queue = new MinMaxPriorityQueue<T>( this, initialQueueSize(expectedSize, maximumSize, initialContents)); for (T element : initialContents) { queue.offer(element); } return queue; }