deque::rend()是C++ STL中的内置函数,它返回一个反向迭代器,该反向迭代器指向双端队列的开始之前的位置(被视为双端队列的反向结束)。
用法:
deque_name.rend()
参数:该函数不接受任何参数。
返回值:它返回一个反向迭代器,该迭代器指向双端队列开始之前的位置。
以下示例程序旨在说明上述函数:
示例1:
// C++ program to illustrate the 
// deque::rend() function 
#include <bits/stdc++.h> 
using namespace std; 
  
int main() 
{ 
    deque<int> dq = { 10, 20, 30, 40, 50 }; 
  
    cout << "The deque in reverse order: "; 
  
    // prints the elements in reverse order 
    for (auto it = dq.rbegin(); it != dq.rend(); ++it) 
        cout << *it << " "; 
  
    return 0; 
}
输出:
The deque in reverse order: 50 40 30 20 10
示例2:
// C++ program to illustrate the 
// deque::rend() function 
#include <bits/stdc++.h> 
using namespace std; 
  
int main() 
{ 
    deque<char> dq = { 'a', 'b', 'c', 'd', 'e' }; 
  
    cout << "The deque in reverse order: "; 
  
    // prints the elements in reverse order 
    for (auto it = dq.rbegin(); it != dq.rend(); ++it) 
        cout << *it << " "; 
  
    return 0; 
}
输出:
The deque in reverse order: e d c b a
相关用法
- C++ map rend()用法及代码示例
 - C++ list rbegin()、rend()用法及代码示例
 - C++ multiset rbegin()、rend()用法及代码示例
 - C++ vector rbegin()、rend()用法及代码示例
 - C++ deque max_size()用法及代码示例
 - C++ deque resize()用法及代码示例
 - C++ deque insert()用法及代码示例
 - C++ deque rbegin()用法及代码示例
 - C++ deque assign()用法及代码示例
 - C++ deque::emplace_front()、deque::emplace_back()用法及代码示例
 - C++ deque::pop_front()、deque::pop_back()用法及代码示例
 - C++ deque::clear()、deque::erase()用法及代码示例
 - C++ deque::front()、deque::back()用法及代码示例
 - C++ deque::empty()、deque::size()用法及代码示例
 - C++ set::rbegin()、set::rend()用法及代码示例
 
注:本文由纯净天空筛选整理自rupesh_rao大神的英文原创作品 deque rend() function in C++ STL。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。
