PHP | Ds\Deque rotate() Function Last Updated : 14 Aug, 2019 Comments Improve Suggest changes Like Article Like Report The Ds\Deque::rotate() function is an inbuilt function in PHP which is used to rotate the elements of Deque by the given number of rotations. Syntax: public Ds\Deque::rotate( $rotations ) : void Parameters: This function accepts single parameter $rotations which holds the number of rotation of the elements in Deque is to be rotated. Return value: This function does not return any value. Below programs illustrate the Ds\Deque::rotate() function in PHP: Program 1: PHP <?php // Declare a deque $deck = new \Ds\Deque([1, 2, 3, 4, 5, 6]); echo("Elements of Deque\n"); // Display the Deque elements print_r($deck); // Rotating the deque by 2 positions $deck->rotate(2); echo("Rotated Deque\n"); // Display the Deque elements print_r($deck); ?> Output: Elements of Deque Ds\Deque Object ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 [5] => 6 ) Rotated Deque Ds\Deque Object ( [0] => 3 [1] => 4 [2] => 5 [3] => 6 [4] => 1 [5] => 2 ) Program 2: PHP <?php // Declare a deque $deck = new \Ds\Deque(["geeks", "for", "geeks", "practice"]); echo("Elements of Deque\n"); // Display the Deque elements print_r($deck); // Rotating the deque by 2 positions $deck->rotate(2); echo("Rotated Deque\n"); // Display the Deque elements print_r($deck); ?> Output: Elements of Deque Ds\Deque Object ( [0] => geeks [1] => for [2] => geeks [3] => practice ) Rotated Deque Ds\Deque Object ( [0] => geeks [1] => practice [2] => geeks [3] => for ) Reference: http://php.net/manual/en/ds-deque.rotate.php Comment More infoAdvertise with us Next Article PHP | DsSequence rotate() Function B barykrg Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-ds_deque Similar Reads PHP | DsDeque rotate() Function The Ds\Deque::rotate() function is an inbuilt function in PHP which is used to rotate the elements of Deque by the given number of rotations. Syntax: public Ds\Deque::rotate( $rotations ) : void Parameters: This function accepts single parameter $rotations which holds the number of rotation of the e 2 min read PHP | DsSequence rotate() Function The Ds\Sequence::rotate() function is an inbuilt function in PHP which is used to rotate the sequence element by a given number of rotations. Syntax: void abstract public Ds\Sequence::rotate ( int $rotations ) Parameters: This function accepts single parameter $rotations which holds the number of ro 2 min read PHP | DsDeque remove() Function The Ds\Deque::remove() function is an inbuilt function in PHP which is used to remove and return the index value. Syntax: public Ds\Deque::remove( $index ) : mixed Parameters: This function accepts single parameter $index which holds the index of Deque for which the element is to be returned and rem 2 min read PHP | DsDeque sorted() Function The Ds\Deque::sorted() function is an inbuilt function in PHP which is used to return a copy of Deque which contains the element in the original Deque in increasing order. Syntax: public Ds\Deque::sorted( $comparator ) : Ds\Deque Parameters: This function accepts single parameter $comparator which h 2 min read PHP | DsVector rotate() Function The Ds\Vector::rotate() function is an inbuilt function in PHP which is used to rotate the array elements by a given number of rotation. Rotations also happen in-place. Syntax: void public Ds\Vector::rotate( $rotations ) Parameters: This function accepts single parameter $rotations which holds the n 2 min read PHP | DsDeque sort() Function The Ds\Deque::sort() function is an inbuilt function in PHP which is used to sort the Deque in place by arranging the elements in increasing order. Syntax: public Ds\Deque::sort( $comparator ) : void Parameters::This function accepts single parameter $comparator which holds the function to decides h 2 min read Like