Ds\PriorityQueue::peek

(PECL ds >= 1.0.0)

Ds\PriorityQueue::peekReturns the value at the front of the queue

說明

public Ds\PriorityQueue::peek(): mixed

Returns the value at the front of the queue, but does not remove it.

參數(shù)

此函數(shù)沒有參數(shù)。

返回值

The value at the front of the queue.

錯(cuò)誤/異常

UnderflowException if empty.

范例

示例 #1 Ds\PriorityQueue::peek() example

<?php
$queue 
= new \Ds\PriorityQueue();

$queue->push("a",  5);
$queue->push("b"15);
$queue->push("c"10);

var_dump($queue->peek());
?>

以上例程的輸出類似于:

string(1) "b"