Aracılığıyla paylaş


PriorityQueue Class

Definition

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

Remarks

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.

Constructors

PriorityQueue()

Creates a PriorityQueue with the default initial capacity (11) that orders its elements according to their Comparable natural ordering.

PriorityQueue(ICollection)

Creates a PriorityQueue containing the elements in the specified collection.

PriorityQueue(IComparator)

Creates a PriorityQueue with the default initial capacity and whose elements are ordered according to the specified comparator.

PriorityQueue(Int32, IComparator)

Creates a PriorityQueue with the specified initial capacity that orders its elements according to the specified comparator.

PriorityQueue(Int32)

Creates a PriorityQueue with the specified initial capacity that orders its elements according to their Comparable natural ordering.

PriorityQueue(IntPtr, JniHandleOwnership)

A constructor used when creating managed representations of JNI objects; called by the runtime.

PriorityQueue(ISortedSet)

Creates a PriorityQueue containing the elements in the specified sorted set.

PriorityQueue(PriorityQueue)

Creates a PriorityQueue containing the elements in the specified priority queue.

Properties

Class

Returns the runtime class of this Object.

(Inherited from Object)
Handle

The handle to the underlying Android instance.

(Inherited from Object)
IsEmpty

To be added

(Inherited from AbstractCollection)
JniIdentityHashCode (Inherited from Object)
JniPeerMembers
PeerReference (Inherited from Object)
ThresholdClass

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

ThresholdType

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

Methods

Add(Object)

To be added

(Inherited from AbstractCollection)
AddAll(ICollection)

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 null if this queue is sorted according to the Comparable natural ordering of its elements.

Contains(Object)

To be added

(Inherited from AbstractCollection)
ContainsAll(ICollection)

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)
ForEach(IConsumer)
GetHashCode()

Returns a hash code value for the object.

(Inherited from Object)
Iterator()

Returns an iterator over the elements in this queue.

JavaFinalize()

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)
NotifyAll()

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)
RemoveAll(ICollection)

To be added

(Inherited from AbstractCollection)
RemoveIf(IPredicate)
RetainAll(ICollection)

To be added

(Inherited from AbstractCollection)
SetHandle(IntPtr, JniHandleOwnership)

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> Spliterator over the elements in this queue.

ToArray()

To be added

(Inherited from AbstractCollection)
ToArray(Object[])

To be added

(Inherited from AbstractCollection)
ToArray<T>() (Inherited from Object)
ToString()

Returns a string representation of the object.

(Inherited from Object)
UnregisterFromRuntime() (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)

Explicit Interface Implementations

IJavaPeerable.Disposed() (Inherited from Object)
IJavaPeerable.DisposeUnlessReferenced() (Inherited from Object)
IJavaPeerable.Finalized() (Inherited from Object)
IJavaPeerable.JniManagedPeerState (Inherited from Object)
IJavaPeerable.SetJniIdentityHashCode(Int32) (Inherited from Object)
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) (Inherited from Object)
IJavaPeerable.SetPeerReference(JniObjectReference) (Inherited from Object)

Extension Methods

JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject)
GetJniTypeName(IJavaPeerable)
ToEnumerable(IIterable)
ToEnumerable<T>(IIterable)

Applies to