deque - STL C++

deque<X, A>::reverse_iterator

Declaration

typedef (unspecified) deque<X, A>::reverse_iterator;

Description

This is a type definition of the data type reverse_iterator for the deque class template. This type is used to sequentially access elements in the reverse order with respect to the deque container.

Header Include

#include <deque>

Example

#include <iostream>
#include <deque>

int main()
{
	using namespace std;

	// Create a deque and add four elements to it
	deque<int> qDeque;
	qDeque.push_back(5);
	qDeque.push_back(101);
	qDeque.push_back(-4);
	qDeque.push_back(32);

	// Use the reverse iterator to access and output the elements
	deque<int>::reverse_iterator qIter;
	for (qIter = qDeque.rbegin(); qIter != qDeque.rend(); ++qIter) {
		cout << "Deque entry = " << *qIter << endl;
		// Set the entry to 30 and output it again
		*qIter = 30;
		cout << "Deque entry after it is set = " << *qIter << endl;
	}

	// Keep the window open
	cin.get();
	return 0;
}

Output

deque<X, A>::reverse_iterator Output
 

© 2007–2024 XoaX.net LLC. All rights reserved.