C++ Deque cend()30 Aug 2024 | 1 min read C++ Deque cend() function 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. SyntaxParameterIt does not contain any parameter. Return valueIt returns a constant iterator referring to the past-the-last element in a deque. Example 1Let's see a simple example when deque containing character values. Output: j a v a T p o i n t In this example, cend() function is used to iterate throughout the deque container and the while loop executes until and unless 'itr' becomes equal to the ch.cend(). Example 2Let's see a simple example when deque contains integer values. Output: 100 200 300 400 500 In this example, cend() function is used to iterate throughout the deque container and the while loop executes until and unless 'itr' becomes equal to the ch.cend(). Next TopicC++ Deque |
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 swap() C++ exchanges the content of a given deque with the deque passed in the parameter of same type. Conditions: Type of deque cannot be different. Size of deque can vary. Syntax void swap(deque& second); Parameter second: It is an another deque container whose content is to be swapped with the...
2 min read
C++ Deque pop_back() C++ removes the last element from the the deque container and the size of the deque is reduced by one. Syntax void pop_back(); Parameter It does not contain any parameter. Return value It does not return any value. Example Let's see a simple example #include <iostream> #include<deque> using namespace std; int main() { ...
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 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 rbegin() C++ returns a reverse iterator pointing to the last element of the container. An iterator can be incremented or decremented but it cannot modify the content of deque. Where, rbegin() stands for reverse beginning. Note: Reverse iterators are those which iterate from backwards and move...
1 min read
C++ Deque resize() C++ changes the size of the deque container to the size given in the argument. Following are the conditions: If n is greater than the container size then the container size is extended to n elements by inserting new elements at the extended space. If n...
2 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 back() C++ is used to access the last element of the deque container. Syntax reference back(); Parameter It does not contain any parameter. Return value It returns a reference to the last element of the deque container. Example 1 Let's see a simple example #include <iostream> #include<deque> using namespace std; int main() { deque<int>...
1 min read
C++ Deque clear() C++ removes all the elements from the deque and the size of the deque is reduced to zero. Syntax void clear(); Parameter It does not contain any parameter. Return value It does not return any value. Example Let's see a simple example #include <iostream> #include<deque> using namespace std; int main() { deque<int>...
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