PHP | Ds\设置容量()函数
Ds\Set::capacity()函数是PHP中的一个内置函数,用于返回集合的容量。
句法:
int public Ds\Set::capacity( void )
参数:此函数不接受任何参数。
返回值:该函数返回set的当前容量。
下面的程序说明了PHP中的Ds\Set::capacity()函数:
方案一:
capacity());
// Allocating space for 50 values
$set->allocate(50);
echo("Allocated size of Set: ");
// Display the current capacity
var_dump($set->capacity());
?>
输出:
Default size of Set: int(8)
Allocated size of Set: int(64)
方案二:
capacity());
?>
输出:
Elements of Set
object(Ds\Set)#1 (6) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
[3]=>
int(4)
[4]=>
int(5)
[5]=>
int(6)
}
Capacity of Set: int(8)
参考: http: PHP。 PHP