PHP SplHeap __construct() Function Last Updated : 07 Mar, 2024 Comments Improve Suggest changes Like Article Like Report 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 property must be recursively true for all sub-trees in that Binary Tree.Min-Heap: In a Min-Heap, the key present at the root node must be minimum among the keys present at all of its children. The same property must be recursively true for all sub-trees in that Binary Tree. Syntax: public SplHeap::__construct() Parameters: This function does not accept any parameter. Return Value: This function does not return any value. Below programs illustrate the SplMaxHeap::__construct() function in PHP: Example 1: PHP <?php // Create a new empty Min Heap $heap = new SplMinHeap(); $heap->insert('System'); $heap->insert('GFG'); $heap->insert('ALGO'); $heap->insert('C'); $heap->insert('Geeks'); $heap->insert('GeeksforGeeks'); // Loop to display the current element of heap for ($heap->top(); $heap->valid(); $heap->next()) { echo $heap->current() . "\n"; } ?> Output: ALGO C GFG Geeks GeeksforGeeks System Example 2: PHP <?php // Create a new empty Max Heap $heap = new SplMaxHeap(); $heap->insert('System'); $heap->insert('GFG'); $heap->insert('ALGO'); $heap->insert('C'); $heap->insert('Geeks'); $heap->insert('GeeksforGeeks'); // Loop to display the current element of heap for ($heap->top(); $heap->valid(); $heap->next()) { echo $heap->current() . "\n"; } ?> Output: System GeeksforGeeks Geeks GFG C ALGO Comment More infoAdvertise with us Next Article PHP SplHeap __construct() Function A ashokjaiswal Follow Improve Article Tags : Web Technologies PHP PHP-function Similar Reads PHP SplQueue::__construct() Function 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 val 1 min read PHP | SplHeap count() Function The SplHeap::count() function is an inbuilt function in PHP which is used to count the elements in the heap. Generally, Heap can be 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 property must be recursi 2 min read PHP SplHeap extract() Function The SplHeap::extract() function is an inbuilt function in PHP which is used to extract a node from top of the heap and sift up. 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 childre 1 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 | SplHeap current() Function The SplHeap::current() function is an inbuilt function in PHP which is used to get the current element pointed by the iterator. 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 2 min read PHP | Imagick __construct() Function The Imagick::__construct() function is an Imagick class constructor which takes the image path or image URL as parameter to instantiate the Imagick object for a specific image or a set of images. Syntax: Imagick::__construct( $files ) Parameters: This function accepts single parameter $files which h 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 | DsPair __construct() Function The Ds\Pair::__construct() function is an inbuilt function in PHP which is used to create a new instance. Syntax: public Ds\Pair::__construct( $key, $value ) Parameters: This function accepts two parameters as mentioned above and described below: $key: This parameter holds the key of the pair elemen 2 min read PHP SplHeap key() Function The SplHeap::key() function is an inbuilt function in PHP which is used to get the current node index. 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 property must 2 min read PHP SplHeap top() Function The SplHeap::top() function is an inbuilt function in PHP that is used to display the peek node from the top of the heap. Generally, the Heap Data Structure is 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 s 2 min read Like