Returns the value at the front of the queue

Ds\Queue::peek

(PECL ds >= 1.0.0)

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

說明

public Ds\Queue::peek(): mixed

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

參數

此函式沒有參數。

返回值

The value at the front of the queue.

錯誤/異常

UnderflowException if empty.

範例

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

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

$queue->push("a");
$queue->push("b");
$queue->push("c");

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

以上例程的輸出類似於:

string(1) "a"

Leave a Reply

Your email address will not be published. Required fields are marked *