PHP | Ds\Deque unshift() Function Last Updated : 20 Mar, 2023 Comments Improve Suggest changes Like Article Like Report The Ds\Deque::unshift() function is an inbuilt function in PHP which is used to add the value in front of the deque. Syntax: void Ds\Deque::unshift( $values ) Parameters: This function accepts single parameter $values which holds the values to add in the front of the deque. Return Value: This function does not return any values. Below programs illustrate the Ds\Deque::unshift() function in PHP: Program 1: php <?php // Declare a deque $deq = new \Ds\Deque([10, 20, 30, 40]); // Use Ds\Deque::unshift() function $deq -> unshift(5); $deq -> unshift(7); $deq -> unshift(8); print_r($deq); ?> Output:Ds\Deque Object ( [0] => 8 [1] => 7 [2] => 5 [3] => 10 [4] => 20 [5] => 30 [6] => 40 ) Program 2: php <?php // Declare a deque $deq = new \Ds\Deque(); // Use Ds\Deque::unshift() function $deq -> unshift("Welcome"); $deq -> unshift("to"); $deq -> unshift("GeeksforGeeks"); var_dump($deq); // Declare another deque $deq = new \Ds\Deque(['G', 'E', 'E', 'K', 'S']); // Use Ds\Deque::unshift() function $deq -> unshift("1"); $deq -> unshift("2"); $deq -> unshift("3"); var_dump($deq); ?> Output:object(Ds\Deque)#1 (3) { [0]=> string(13) "GeeksforGeeks" [1]=> string(2) "to" [2]=> string(7) "Welcome" } object(Ds\Deque)#2 (8) { [0]=> string(1) "3" [1]=> string(1) "2" [2]=> string(1) "1" [3]=> string(1) "G" [4]=> string(1) "E" [5]=> string(1) "E" [6]=> string(1) "K" [7]=> string(1) "S" } Reference: https://www.php.net/manual/en/ds-deque.unshift.php Comment More infoAdvertise with us Next Article PHP | DsDeque shift() Function jit_t Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-ds_deque Similar Reads PHP | DsDeque unshift() Function The Ds\Deque::unshift() function is an inbuilt function in PHP which is used to add the value in front of the deque. Syntax: void Ds\Deque::unshift( $values ) Parameters: This function accepts single parameter $values which holds the values to add in the front of the deque. Return Value: This functi 2 min read PHP | DsDeque shift() Function The Ds\Deque::shift() function is an inbuilt function in PHP which is used to remove and return the first value of deque. Syntax: mixed Ds\Deque::shift( void ) Parameters: This function does not accept any parameters. Return Value: This function returns the first value of deque which was removed. Be 1 min read PHP | DsSequence unshift() Function The Ds\Sequence::unshift() function is an inbuilt function in PHP which is used to add values to the font of the sequence. Syntax: void abstract public Ds\Sequence::unshift( $values ) Parameters: This function accepts a single parameter $values which contains values to add in the font of the sequenc 1 min read PHP | DsSequence shift() Function The Ds\Sequence::shift() function is an inbuilt function in PHP which is used to removes the first element from the sequence and return it. Syntax: mixed abstract public Ds\Sequence::shift ( void ) Parameters: This function does not accepts any parameter. Return values: This function returns the fir 1 min read PHP | DsDeque push() Function The Ds\Deque::push() function is an inbuilt function in PHP which is used to add the elements to the Deque by appending an element at the end of the Deque. Syntax: public Ds\Deque::push( $values ) : void Parameters: This function accepts single parameter $values which holds the elements to be added 2 min read PHP | DsVector unshift() Function The Ds\Vector::unshift() function is an inbuilt function in PHP which is used to adds elements to the front of vector. This function moves all the elements in the vector towards forward and adds the new element to the front. Syntax: void public Ds\Vector::unshift( $values ) Parameters: This function 2 min read PHP | DsDeque set() Function The Ds\Deque::set() function is an inbuilt function in PHP which is used to set the value at the given index in the Deque. Syntax: public Ds\Deque::set( $index, $value ) : void Parameters: This function accept two parameters as mentioned above and described below: index: This parameter holds the ind 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 PHP | DsSequence push() Function The Ds\Sequence::push() function is an inbuilt function in PHP which adds values to the end of the sequence. Syntax: void abstract public Ds\Sequence::push( $values ) Parameters: This function accepts single parameter $values which contains one or more values. It hold the value to be added in the se 2 min read PHP | DsDeque slice() Function The Ds\Deque::slice() function is an inbuilt function in PHP which is used to return a sub-Deque which contains elements of the Deque within the index range. Syntax: public Ds\Deque::slice( $index, $length ) : Ds\Deque Parameters: This function accept two parameters as mentioned above and described 2 min read Like