C++ Deque crbegin()30 Aug 2024 | 1 min read C++ Deque crbegin() function returns a constant reverse iterator referring to the last element of the deque. An iterator can be incremented or decremented but it cannot modify the content of deque. Where, crbegin() stands for constant reverse beginning. SyntaxParameterIt does not contain any parameter. Return valueIt returns a constant reverse iterator pointing to the last element in the deque container. Example 1Let's see a simple example Output: 50 40 30 20 10 In this example, crbegin() function is used to return an iterator of the last element and for loop is iterated till it reaches the first element of the deque. Example 2Let's see a simple example when iterator is incremented. Output: mechanical In this example, constant reverse iterator is incremented by one. Therefore, it access the second element from backwards. Next TopicC++ Deque |
C++ Deque rend() C++ returns a reverse iterator referring to the element preceding the first element in the deque container. An iterator can be incremented or decremented just like end() function. Where, rend() stands for reverse end. Syntax reverse_iterator rend(); Parameter It does not contain any parameter. Return value It returns a reverse...
1 min read
C++ Deque erase() C++ removes the element from the specified position or range and this effectively reduces the size of the deque by the number of elements removed. Syntax iterator erase(iterator pos); iterator erase(iterator first,iterator last); Parameter pos: It defines the position at which the element to be removed from the...
2 min read
C++ Deque cend() C++ returns a constant iterator pointing to the past-the-last element. An iterator can be incremented or decremented but it cannot modify the content of a deque. If the container is empty then cend() function returns the same as cbegin() function. Syntax const_iterator cend(); Parameter It does not contain...
1 min read
C++ Deque cbegin() C++ returns a constant iterator pointing to the first element of the deque container. This iterator can be incremented or decremented just like the iterator returned by the begin() function. If the container is empty then the returned iterator will be equal to...
1 min read
C++ Deque at() C++ is used to access the element at specified position pos. Note: If pos is greater than the size of the container, then the function throws an exception i.e "out of range". Syntax reference at(size_type pos); Parameter pos: It defines the position of an element which is...
1 min read
C++ Deque insert() C++ inserts new element just before the specified position pos and the size of the container increases by the number of elements are inserted. Insertion of an element can be done either from front or from the back. Syntax iterator insert(iterator pos, value_type val); ...
1 min read
C++ Deque assign() C++ assigns new contents to the deque container and the size of the container is modified accordingly. Syntax void assign(InputIterator first, InputIterator last); void assign(int n,value_type val); Parameter (first,last): It defines the range between which the new elements to be inserted. n: It defines the new size of...
1 min read
C++ Deque end() C++ returns an iterator pointing to the "past-the-last" element of deque. If the deque container is empty then the end() function returns the same as the begin() function. where, past-the-last: The "past-the-last" is the element that follows the last element and it does not...
1 min read
C++ Deque crend() C++ is used to return an iterator pointing to the element preceding the first element of the deque container. An iterator can be incremented or decremented but it cannot modify the content of deque. Syntax const_reverse_iterator crend(); Parameter It does not contain any parameter. Return value It returns a...
1 min read
C++ Deque operator[]() C++ Deque operator[] function is used to access the element at specified position pos. If position pos is greater than the size of container then it returns a value 0. Difference between operator[]() & at() When position pos is greater than the size of the container...
1 min read
We request you to subscribe our newsletter for upcoming updates.
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India