mirror of
https://github.com/CyC2018/Interview-Notebook.git
synced 2026-10-21 08:23:45 +00:00
auto commit
This commit is contained in:
@@ -1,82 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package java.util;
|
||||
|
||||
/**
|
||||
* An unbounded priority {@linkplain Queue queue} based on a priority heap.
|
||||
* The elements of the priority queue are ordered according to their
|
||||
* {@linkplain Comparable natural ordering}, or by a {@link Comparator}
|
||||
* provided at queue construction time, depending on which constructor is
|
||||
* used. A priority queue does not permit {@code null} elements.
|
||||
* A priority queue relying on natural ordering also does not permit
|
||||
* insertion of non-comparable objects (doing so may result in
|
||||
* {@code ClassCastException}).
|
||||
*
|
||||
* <p>The <em>head</em> of this queue is the <em>least</em> element
|
||||
* with respect to the specified ordering. If multiple elements are
|
||||
* tied for least value, the head is one of those elements -- ties are
|
||||
* broken arbitrarily. The queue retrieval operations {@code poll},
|
||||
* {@code remove}, {@code peek}, and {@code element} access the
|
||||
* element at the head of the queue.
|
||||
*
|
||||
* <p>A priority queue is unbounded, but has an internal
|
||||
* <i>capacity</i> governing the size of an array used to store the
|
||||
* elements on the queue. It is always at least as large as the queue
|
||||
* size. As elements are added to a priority queue, its capacity
|
||||
* grows automatically. The details of the growth policy are not
|
||||
* specified.
|
||||
*
|
||||
* <p>This class and its iterator implement all of the
|
||||
* <em>optional</em> methods of the {@link Collection} and {@link
|
||||
* Iterator} interfaces. The Iterator provided in method {@link
|
||||
* #iterator()} is <em>not</em> guaranteed to traverse the elements of
|
||||
* the priority queue in any particular order. If you need ordered
|
||||
* traversal, consider using {@code Arrays.sort(pq.toArray())}.
|
||||
*
|
||||
* <p> <strong>Note that this implementation is not synchronized.</strong>
|
||||
* Multiple threads should not access a {@code PriorityQueue}
|
||||
* instance concurrently if any of the threads modifies the queue.
|
||||
* Instead, use the thread-safe {@link
|
||||
* java.util.concurrent.PriorityBlockingQueue} class.
|
||||
*
|
||||
* <p>Implementation note: this implementation provides
|
||||
* O(log(n)) time for the enqueing and dequeing methods
|
||||
* ({@code offer}, {@code poll}, {@code remove()} and {@code add});
|
||||
* linear time for the {@code remove(Object)} and {@code contains(Object)}
|
||||
* methods; and constant time for the retrieval methods
|
||||
* ({@code peek}, {@code element}, and {@code size}).
|
||||
*
|
||||
* <p>This class is a member of the
|
||||
* <a href="{@docRoot}/../technotes/guides/collections/index.html">
|
||||
* Java Collections Framework</a>.
|
||||
*
|
||||
* @since 1.5
|
||||
* @author Josh Bloch, Doug Lea
|
||||
* @param <E> the type of elements held in this collection
|
||||
*/
|
||||
public class PriorityQueue<E> extends AbstractQueue<E>
|
||||
implements java.io.Serializable {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user