描述
C++ 函數std::multimap::cend()返回一個指向的常量迭代器past-the-end多圖的元素。
聲明
以下是 std::multimap::cend() 函數形式 std::map 頭的聲明。
C++11
const_iterator cend() const noexcept;
參數
空
返回值
返回一個常量迭代器。
異常
此成員函數從不拋出異常。
時間複雜度
常數,即 O(1)
示例
下麵的例子展示了 std::multimap::cend() 函數的用法。
#include <iostream>
#include <map>
using namespace std;
int main(void) {
/* Multimap with duplicates */
multimap<char, int> m {
{'a', 1},
{'a', 2},
{'b', 3},
{'c', 4},
{'c', 5},
};
cout << "Multimap contains following elements:" << endl;
for (auto it = m.cbegin(); it != m.cend(); ++it)
cout << it->first << " = " << it->second << endl;
return 0;
}
讓我們編譯並運行上麵的程序,這將產生以下結果——
Multimap contains following elements: a = 1 a = 2 b = 3 c = 4 c = 5
相關用法
- C++ Map crend()用法及代碼示例
- C++ Map count()用法及代碼示例
- C++ Map clear()用法及代碼示例
- C++ Map crbegin()用法及代碼示例
- C++ Map cbegin()用法及代碼示例
- C++ Map erase()用法及代碼示例
- C++ Map rend()用法及代碼示例
- C++ Map multimap()用法及代碼示例
- C++ Map emplace()用法及代碼示例
- C++ Map at()用法及代碼示例
- C++ Map size()用法及代碼示例
- C++ Map end()用法及代碼示例
- C++ Map get_allocator()用法及代碼示例
- C++ Map max_size()用法及代碼示例
- C++ Map begin()用法及代碼示例
- C++ Map map()用法及代碼示例
- C++ Map rbegin()用法及代碼示例
- C++ Map upper_bound()用法及代碼示例
- C++ Map key_comp()用法及代碼示例
- C++ Map value_comp()用法及代碼示例
注:本文由純淨天空篩選整理自 C++ Map Library - cend() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。