How to use Ds\Queue pop() function in PHP?

醉折花枝作酒筹
Release: 2023-03-10 07:32:02
forward
1654 people have browsed it

This article will introduce to you how to use the Ds\Queue pop() function in PHP. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to everyone.

How to use Ds\Queue pop() function in PHP?

The syntax is as follows:

mixed public DsPriorityQueue::pop ( void )
Copy after login

Parameters: This function does not accept any parameters.

Return value: This function returns the current value at the top of the Queue. The return type of the function is mixed and depends on the type of value stored in the queue.

Exception Note: If the Queue is empty, this function throws UnderflowException.

The following program illustrates the function of DsQueue::pop() in PHP:

Program 1:

push( "One" ); $q ->push( "Two" ); $q ->push( "Three" ); echo "Initial Queue is: n" ; print_r( $q ); // Pop an element echo "nPopped element is: " ; print_r( $q ->pop()); echo "nnFinal Queue is: n" ; print_r( $q ); ?>
Copy after login

The output is as follows:

Initial Queue is: DsQueue Object ( [0] => One [1] => Two [2] => Three ) Popped element is: One Final Queue is: DsQueue Object ( [0] => Two [1] => Three )
Copy after login

Program 2 :

push( "Geeks" ); $q ->push( "for" ); $q ->push( "Geeks" ); echo "Initial Queue is: n" ; print_r( $q ); // Pop an element echo "nPopped element is: " ; print_r( $q ->pop()); echo "nnFinal Queue is: n" ; print_r( $q ); ?>
Copy after login

The output is as follows:

Initial Queue is: DsQueue Object ( [0] => Geeks [1] => for [2] => Geeks ) Popped element is: Geeks Final Queue is: DsQueue Object ( [0] => for [1] => Geeks )
Copy after login

Recommended learning:php video tutorial

The above is the detailed content of How to use Ds\Queue pop() function in PHP?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:segmentfault.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!