PHP SplQueue::__construct() Function Last Updated : 07 Mar, 2024 Comments Improve Suggest changes Like Article Like Report The SplQueue::__construct() function is an inbuilt function in PHP which is used to construct a queue which is implemented using a doubly-linked list. Syntax: void SplQueue::__construct(void) Parameters: This function does not accept any parameter. Return Value: This function does not return any value. Below programs illustrate the SplQueue::__construct() function in PHP: Program 1: php <?php // Create a new empty queue $q = new SplQueue(); $q[] = 1; $q[] = 2; $q[] = 3; // Print the queue elements echo $q[0] . "\n"; echo $q[1] . "\n"; echo $q[2] . "\n"; ?> Output: 1 2 3 Program 2: php <?php // Create some fixed size array $gfg = new SplQueue(); $gfg[] = 1; $gfg[] = 5; $gfg[] = 1; $gfg[] = 11; $gfg[] = 15; $gfg[] = 17; foreach ($gfg as $elem) { echo $elem . "\n"; } ?> Output: 1 5 1 11 15 17 Comment More infoAdvertise with us Next Article PHP SplQueue::__construct() Function R R_Raj Follow Improve Article Tags : Web Technologies PHP PHP-function Similar Reads PHP SplHeap __construct() Function The SplHeap::__construct() function is an inbuilt function in PHP that is used to create the heap data structure. Generally, the Heap Data Structure are of two types: Max-Heap: In a Max-Heap, the key present at the root node must be greatest among the keys present at all of its children. The same pr 2 min read PHP | SplFixedArray __construct() Function The SplFixedArray::__construct() function is an inbuilt function in PHP which is used to construct a new fixed size array. Syntax: void SplFixedArray::__construct( $size ) Parameters: This function accepts single parameter $size which specifies the size of an array. Return Value: This function does 1 min read PHP SplQueue::enqueue() Function The SplQueue::enqueue() function is an inbuilt function in PHP which is used to add the element to the queue. Syntax: void SplQueue::enqueue( $val ) Parameters: This function accepts a single parameter $val which specifies the value for add (enqueue) element. Return Value: This function does not ret 1 min read PHP SplPriorityQueue count() Function The SplPriorityQueue::count() function is an inbuilt function in PHP which is used to count the number of elements in the queue. Syntax: int SplPriorityQueue::count() Parameters: This function does not accept any parameters. Return Value: This function returns the number of elements in the queue. Ex 1 min read PHP SplQueue::dequeue() Function The SplQueue::dequeue() function is an inbuilt function in PHP which is used to dequeues the node from the queue. Syntax: mixed SplQueue::dequeue() Parameters: This function does not accept any parameter. Return Value: This function return the value of the dequeued node. Below programs illustrate th 1 min read PHP | SplDoublyLinkedList __construct() Function The SplDoublyLinkedList::__construct() function is an inbuilt function in PHP which is used to create a new empty doubly linked list. Syntax: public SplDoublyLinkedList::__construct( void ) Parameters: This function does not accept any parameter. Return Value: This function does not return any value 1 min read PHP SplPriorityQueue extract() Function The SplPriorityQueue::extract() function is an inbuilt function in PHP which is used to extract a node from top of the heap and sift up. Syntax: mixed SplPriorityQueue::extract() Parameters: This function does not accept any parameter. Return Value: This function returns the value/priority (or both) 1 min read PHP SplPriorityQueue current() Function The SplPriorityQueue::current() function is an inbuilt function in PHP which is used to return the current node pointed by the iterator. Syntax: mixed SplPriorityQueue::current() Parameters: This function does not accept any parameter. Return Value: This function returns the value/priority of the cu 1 min read PHP SplPriorityQueue compare() Function The SplPriorityQueue::compare() function is an inbuilt function in PHP which is used to compare the priority queue elements to place at a particular order in the heap data structure. Syntax: int SplPriorityQueue::compare( mixed $priority1 , mixed $priority2 ) Parameters: This function accepts two pa 2 min read Like