Deque operators
Syntax:
#include <deque> TYPE& operator[]( size_type index ); const TYPE& operator[]( size_type index ) const; deque operator=(const deque& c2); bool operator==(const deque& c1, const deque& c2); bool operator!=(const deque& c1, const deque& c2); bool operator<(const deque& c1, const deque& c2); bool operator>(const deque& c1, const deque& c2); bool operator<=(const deque& c1, const deque& c2); bool operator>=(const deque& c1, const deque& c2);
All of the C++ containers can be compared and assigned with the standard comparison operators: ==, !=, ⇐, >=, <, >, and =. Individual elements of a deque can be examined with the [] operator.
Performing a comparison or assigning one deque to another takes linear time.
The [] operator runs in constant time.
Two deques are equal if:
- Their size is the same, and
- Each member in location i in one deque is equal to the the member in location i in the other deque.
Comparisons among deques are done lexicographically.
For example, the following code uses the [] operator to access all of the elements of a deque:
deque<int> dq( 5, 1 ); for( size_t i = 0; i < dq.size(); i++ ) { cout << "Element " << i << " is " << dq[i] << '\n'; }
Related Topics: at