PriorityQueue Class
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
An unbounded priority Queue queue based on a priority heap.
[Android.Runtime.Register("java/util/PriorityQueue", DoNotGenerateAcw=true)]
[Java.Interop.JavaTypeParameters(new System.String[] { "E" })]
public class PriorityQueue : Java.Util.AbstractQueue, IDisposable, Java.Interop.IJavaPeerable, Java.IO.ISerializable
[<Android.Runtime.Register("java/util/PriorityQueue", DoNotGenerateAcw=true)>]
[<Java.Interop.JavaTypeParameters(new System.String[] { "E" })>]
type PriorityQueue = class
inherit AbstractQueue
interface ISerializable
interface IJavaObject
interface IDisposable
interface IJavaPeerable
- Inheritance
- Attributes
- Implements
An unbounded priority Queue queue based on a priority heap. The elements of the priority queue are ordered according to their Comparable natural ordering, or by a Comparator
provided at queue construction time, depending on which constructor is used. A priority queue does not permit null
elements. A priority queue relying on natural ordering also does not permit insertion of non-comparable objects (doing so may result in ClassCastException
).
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 poll
, remove
, peek
, and element
access the element at the head of the queue.
A priority queue is unbounded, but has an internal capacity 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.
This class and its iterator implement all of the <em>optional</em> methods of the Collection
and Iterator
interfaces. The Iterator provided in method #iterator()
and the Spliterator provided in method #spliterator()
are <em>not</em> guaranteed to traverse the elements of the priority queue in any particular order. If you need ordered traversal, consider using Arrays.sort(pq.toArray())
.
<strong>Note that this implementation is not synchronized.</strong> Multiple threads should not access a PriorityQueue
instance concurrently if any of the threads modifies the queue. Instead, use the thread-safe java.util.concurrent.PriorityBlockingQueue
class.
Implementation note: this implementation provides O(log(n)) time for the enqueuing and dequeuing methods (offer
, poll
, remove()
and add
); linear time for the remove(Object)
and contains(Object)
methods; and constant time for the retrieval methods (peek
, element
, and size
).
This class is a member of the Java Collections Framework.
Added in 1.5.
Java documentation for java.util.PriorityQueue
.
Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.
Priority |
Creates a |
Priority |
Creates a |
Priority |
Creates a |
Priority |
Creates a |
Priority |
Creates a |
Priority |
A constructor used when creating managed representations of JNI objects; called by the runtime. |
Priority |
Creates a |
Priority |
Creates a |
Class |
Returns the runtime class of this |
Handle |
The handle to the underlying Android instance. (Inherited from Object) |
Is |
To be added (Inherited from AbstractCollection) |
Jni |
(Inherited from Object) |
Jni |
|
Peer |
(Inherited from Object) |
Threshold |
This API supports the Mono for Android infrastructure and is not intended to be used directly from your code. |
Threshold |
This API supports the Mono for Android infrastructure and is not intended to be used directly from your code. |
Add(Object) |
To be added (Inherited from AbstractCollection) |
Add |
To be added (Inherited from AbstractCollection) |
Clear() |
To be added (Inherited from AbstractCollection) |
Clone() |
Creates and returns a copy of this object. (Inherited from Object) |
Comparator() |
Returns the comparator used to order the elements in this
queue, or |
Contains(Object) |
To be added (Inherited from AbstractCollection) |
Contains |
To be added (Inherited from AbstractCollection) |
Dispose() | (Inherited from Object) |
Dispose(Boolean) | (Inherited from Object) |
Element() |
Retrieves, but does not remove, the head of this queue. (Inherited from AbstractQueue) |
Equals(Object) |
Indicates whether some other object is "equal to" this one. (Inherited from Object) |
For |
|
Get |
Returns a hash code value for the object. (Inherited from Object) |
Iterator() |
Returns an iterator over the elements in this queue. |
Java |
Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. (Inherited from Object) |
Notify() |
Wakes up a single thread that is waiting on this object's monitor. (Inherited from Object) |
Notify |
Wakes up all threads that are waiting on this object's monitor. (Inherited from Object) |
Offer(Object) |
Inserts the specified element into this priority queue. |
Peek() |
Gets but does not remove the head of the queue. |
Poll() |
Gets and removes the head of the queue. |
Remove() |
Retrieves and removes the head of this queue. (Inherited from AbstractQueue) |
Remove(Object) |
To be added (Inherited from AbstractCollection) |
Remove |
To be added (Inherited from AbstractCollection) |
Remove |
|
Retain |
To be added (Inherited from AbstractCollection) |
Set |
Sets the Handle property. (Inherited from Object) |
Size() |
Gets the size of the priority queue. |
Spliterator() |
Creates a <em>late-binding</em>
and <em>fail-fast</em> |
To |
To be added (Inherited from AbstractCollection) |
To |
To be added (Inherited from AbstractCollection) |
To |
(Inherited from Object) |
To |
Returns a string representation of the object. (Inherited from Object) |
Unregister |
(Inherited from Object) |
Wait() |
Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>. (Inherited from Object) |
Wait(Int64, Int32) |
Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed. (Inherited from Object) |
Wait(Int64) |
Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed. (Inherited from Object) |
IJava |
(Inherited from Object) |
IJava |
(Inherited from Object) |
IJava |
(Inherited from Object) |
IJava |
(Inherited from Object) |
IJava |
(Inherited from Object) |
IJava |
(Inherited from Object) |
IJava |
(Inherited from Object) |
Java |
Performs an Android runtime-checked type conversion. |
Java |
|
Get |
|
To |
|
To |