Uredi

Deli z drugimi prek


PriorityQueue<TElement,TPriority>.DequeueEnqueue Method

Definition

Removes the minimal element and then immediately adds the specified element with associated priority to the PriorityQueue<TElement,TPriority>.

public:
 TElement DequeueEnqueue(TElement element, TPriority priority);
public TElement DequeueEnqueue (TElement element, TPriority priority);
member this.DequeueEnqueue : 'Element * 'Priority -> 'Element
Public Function DequeueEnqueue (element As TElement, priority As TPriority) As TElement

Parameters

element
TElement

The element to add to the PriorityQueue<TElement,TPriority>.

priority
TPriority

The priority with which to associate the new element.

Returns

TElement

The minimal element removed before performing the enqueue operation.

Exceptions

The queue is empty.

Remarks

Implements an extract-then-insert heap operation that is generally more efficient than sequencing Dequeue and Enqueue operations: in the worst case scenario only one shift-down operation is required.

Applies to