Syntax:int public DsSet::capacity (void)
Parameter: This function takes no parameters.Return Value:This function returns the current capacity of the set.The following programs illustrate the Ds / Set function: : acity()in PHP:Program 1:
// Declare an empty set
$set
=
new
DsSet();
echo
(
" Default size of Set: "
);
// Show current capacity
var_dump (
$set
-> capacity());
// Allocate space for 50 values
$set
-> allocate (50);
echo
(
" Allocated size of Set: "
);
// Show current capacity
var_dump (
$set
-> capacity());
?>
Exit:Default size of Set: int (8) Allocated size of Set: int (64)
Program 2:
// Declare the set
$set
=
new
DsSet ([1, 2, 3, 4, 5, 6]);
echo
(
" Elements of Set "
);
// Show Set Elements
var_dump (
$set
);
echo
(
" Capacity of Set: "
);
// Show capacity Set
var_dump (
$set
-> capacity());
?>
Exit:Elements of Set object (DsSet) # 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)
Link: http://php.net/manual/en/ds-set.capacity.php