Ds\Queue::peek() 函數可以在隊列的前麵返回一個值。
用法
public mixed Ds\Queue::peek( void )
Ds\Queue::peek() 函數可以在隊列的前麵返回一個值,但不刪除它。
Ds\Queue::peek() 函數沒有任何參數。
Ds\Queue::peek() 函數可以在為空時拋出 UnderflowException。
示例
<?php
$queue = new \Ds\Queue();
$queue->push("Tutorials");
$queue->push("Point");
$queue->push("India");
echo "The queue is:\n";
print_r($queue);
echo "\n The element at front is:";
print_r($queue->peek());
?>
相關用法
- PHP Ds\Queue::push()用法及代碼示例
- PHP Ds\Queue::pop()用法及代碼示例
- PHP Ds\Queue::allocate()用法及代碼示例
- PHP Ds\Queue::capacity()用法及代碼示例
- PHP Ds\Queue pop()用法及代碼示例
- PHP Ds\Queue push()用法及代碼示例
- PHP Ds\Queue clear()用法及代碼示例
- PHP Ds\Queue capacity()用法及代碼示例
- PHP Ds\Queue count()用法及代碼示例
- PHP Ds\Queue copy()用法及代碼示例
- PHP Ds\Queue isEmpty()用法及代碼示例
- PHP Ds\Queue allocate()用法及代碼示例
- PHP Ds\Queue toArray()用法及代碼示例
- PHP Ds\Queue peek()用法及代碼示例
注:本文由純淨天空篩選整理自 PHP - Ds\Queue::peek() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。