PHP Ds PriorityQueue count()函数用法介绍

2021年3月13日15:46:55 发表评论 744 次浏览

Ds \ PriorityQueue :: count()PHP中的函数用于获取PriorityQueue实例中存在的元素数。

语法:

int public Ds\PriorityQueue::copy ( void )

参数:该函数不接受任何参数。

返回值:此函数计算PriorityQueue实例中存在的元素数并返回计数。

下面的程序说明了Ds \ PriorityQueue :: count()PHP中的功能:

程序1:

<?php 
  
// Declare new PriorityQueue 
$pq = new \Ds\PriorityQueue(); 
  
// Add elements to the PriorityQueue
$pq ->push( "One" , 1);
$pq ->push( "Two" , 2);
$pq ->push( "Three" , 3);
  
// Count the number of elements 
// in this PriorityQueue
print_r( $pq -> count ());
  
?>

输出如下:

3

程式2:

<?php 
  
// Declare new PriorityQueue 
$pq = new \Ds\PriorityQueue(); 
  
// Add elements to the PriorityQueue
$pq ->push( "Geeks" , 1);
$pq ->push( "for" , 2);
$pq ->push( "Geeks" , 3);
  
// Count the number of elements 
// in this PriorityQueue
print_r( $pq -> count ());
  
?>

输出如下:

3

参考: http://php.net/manual/en/ds-priorityqueue.count.php


木子山

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: