PHP Ds / PriorityQueue copy () function

PHP

Syntax:
DsPriorityQueue public DsPriorityQueue::copy (void)
Parameters: This function takes no parameters.Return Value:This function creates a shallow copy of an existing PriorityQueue instance and returns it.The following programs illustrate the Ds / PriorityQueue::copy()in PHP:Program 1:  
// Declare a new PriorityQueue $pq = new DsPriorityQueue();  
// Add items to PriorityQueue $pq -> push ( "One" , 1); $pq -> push ( "Two" , 2); $pq -> push ( "Three" , 3);  
// Create a copy of this PriorityQueue
// copy and print it print_r ( $pq -> copy ());  
?>
Exit:
DsPriorityQueue Object ( [0] = > Three [1] = > Two [2] = > One)
Program 2:  
// Declare new PriorityQueue $pq = new DsPriorityQueue();  
// Add items to PriorityQueue $pq -> push ( "Geeks" , 1); $pq -> push ( "for" , 2); $pq -> push ( "Geeks" , 3);  
// Create a copy of this PriorityQueue
// copy and print it print_r ( $pq -> copy ());  
?>
Exit:
DsPriorityQueue Object ( [0] = > Geeks [1] = > for [2] = > Geeks)
Link: http://php.net/manual/en/ds-priorityqueue.copy.php



Get Solution for free from DataCamp guru