Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

PHP - Queue Class Functions



In PHP, Queue is a linear data structure that follows the FIFO (First In, First Out) principle, which means that the first element added is the first one to be removed. This is useful, where you need to handle tasks, requests, or any sequence of data processing that requires order.

Syntax

Following is the syntax to create Queue in PHP −

$queue = new \Ds\Queue([values...mixed]);
or
$queue = new \Ds\Queue();

Where, the values can be any type such as numbers, characters, strings, and so on.

List of Functions

Below is the list of functions provided by the Queue class in PHP −

Sr.No Functions & Description
1

Ds\Queue::allocate() Function

This function can allocate enough memory for the required capacity.

2

Ds\Queue::capacity() Function

This function can return the current capacity.

3

Ds\Queue::clear() Function

This function can remove all values from a queue.

4

Ds\Queue::__construct() Function

This function can create a new instance.

5

Ds\Queue::copy() Function

This function can return the shallow copy of a queue.

6

Ds\Queue::count() Function

This unction can be used to get the count of elements present in a queue.

7

Ds\Queue::isEmpty() Function

This function can return whether the queue is empty.

8

Ds\Queue::jsonSerialize() Function

This function can return a representation that can be converted to JSON.

9

Ds\Queue::peek() Function

This function can return a value at the front of a queue.

10

Ds\Queue::pop() Function

This function can remove and return a value at the front of a queue.

11

Ds\Queue::push() Function

This function can push the values into a queue.

12

Ds\Queue::toArray() Function

This function can convert the queue to an array.

php_function_reference.htm
Advertisements