Ds\Queue::allocate() 函數可以為所需的容量分配足夠的內存。
用法
public void Ds\Queue::allocate( int $capacity )
Ds\Queue::allocate() 函數以確保為所需容量分配足夠的內存。它可以消除在添加值時重新分配內部的需要。
Ds\Queue::allocate() 函數不返回任何值。
示例
<?php
$queue = new \Ds\Queue();
echo("The allocated space is:");
var_dump($queue->capacity());
echo("The allocated space is:");
$queue->allocate(20);
var_dump($q->capacity());
$queue->allocate(100);
var_dump($q->capacity());
?>
相關用法
- PHP Ds\Queue::push()用法及代碼示例
- PHP Ds\Queue::pop()用法及代碼示例
- PHP Ds\Queue::peek()用法及代碼示例
- 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::allocate() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。