Ds\PriorityQueue::allocate() 函數可以為所需的容量分配足夠的內存。
用法
public void Ds\PriorityQueue::allocate( int $capacity )
Ds\PriorityQueue::allocate() 函數可以確保為所需的容量分配足夠的內存。它可以消除在添加值時重新分配內部的需要。
Ds\PriorityQueue::allocate() 函數不返回任何值。
示例
<?php
$pqueue = new \Ds\PriorityQueue();
echo("The allocated space is:");
var_dump($pqueue->capacity());
echo("The allocated space is:");
$pqueue->allocate(10);
var_dump($pqueue->capacity());
$pqueue->allocate(80);
var_dump($pqueue->capacity());
?>
相關用法
- PHP Ds\PriorityQueue::clear()用法及代碼示例
- PHP Ds\PriorityQueue::peek()用法及代碼示例
- PHP Ds\PriorityQueue::pop()用法及代碼示例
- PHP Ds\PriorityQueue pop()用法及代碼示例
- PHP Ds\PriorityQueue capacity()用法及代碼示例
- PHP Ds\PriorityQueue push()用法及代碼示例
- PHP Ds\PriorityQueue copy()用法及代碼示例
- PHP Ds\PriorityQueue count()用法及代碼示例
- PHP Ds\PriorityQueue toArray()用法及代碼示例
- PHP Ds\PriorityQueue clear()用法及代碼示例
- PHP Ds\PriorityQueue allocate()用法及代碼示例
- PHP Ds\PriorityQueue isEmpty()用法及代碼示例
- PHP Ds\PriorityQueue peek()用法及代碼示例
注:本文由純淨天空篩選整理自 PHP - Ds\PriorityQueue::allocate() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。