back
Syntax:
#include <deque> TYPE& back(); const TYPE& back() const;
The back() function returns a reference to the last element in the deque. For example:
deque<int> dq; for( int i = 0; i < 5; i++ ) { dq.push_back(i); } cout << "The first element is " << dq.front() << " and the last element is " << dq.back() << endl;
This code produces the following output:
The first element is 0 and the last element is 4
The back() function runs in constant time.