PHP | SplDoublyLinkedList getIteratorMode() Function
The SplDoublyLinkedList::getIteratorMode() function is an inbuilt function in PHP which is used to return the mode of iteration.
Syntax:
int SplDoublyLinkedList::getIteratorMode( void )
Parameters: This function does not accept any parameters.
Return Value: This function returns the different modes and flags that affect the iteration.
Below programs illustrate the SplDoublyLinkedList::getIteratorMode() function in PHP:
Program 1:
<?php // Declare an empty SplDoublyLinkedList $list = new SplDoublyLinkedList(); // Add the element into SplDoublyLinkedList $list ->setIteratorMode(SplDoublyLinkedList::IT_MODE_FIFO); // Use getIteratorMode() function $mode = $list ->getIteratorMode(); var_dump( $mode ); // Add the element into SplDoublyLinkedList $list ->setIteratorMode(SplDoublyLinkedList::IT_MODE_DELETE); // Use getIteratorMode() function $mode = $list ->getIteratorMode(); var_dump( $mode ); // Add the element into SplDoublyLinkedList $list ->setIteratorMode(SplDoublyLinkedList::IT_MODE_LIFO); // Use getIteratorMode() function $mode = $list ->getIteratorMode(); var_dump( $mode ); ?> |
Output:
int(0) int(1) int(2)
Program 2:
<?php // Declare an empty SplDoublyLinkedList $list = new SplDoublyLinkedList(); // Add the element into SplDoublyLinkedList $list ->setIteratorMode(SplDoublyLinkedList::IT_MODE_FIFO | SplDoublyLinkedList::IT_MODE_DELETE | SplDoublyLinkedList::IT_MODE_LIFO); $mode = $list ->getIteratorMode(); var_dump( $mode & SplDoublyLinkedList::IT_MODE_FIFO); var_dump( $mode & SplDoublyLinkedList::IT_MODE_LIFO); var_dump( $mode & SplDoublyLinkedList::IT_MODE_DELETE); var_dump( $mode & SplDoublyLinkedList::IT_MODE_KEEP); ?> |
Output:
int(0) int(2) int(1) int(0)
Reference: https://www.php.net/manual/en/spldoublylinkedlist.getiteratormode.php
Please Login to comment...