名稱空間
變體
操作

std::multimap<Key,T,Compare,Allocator>::count

來自 cppreference.com
< cpp‎ | 容器‎ | multimap
 
 
 
 
size_type count( const Key& key ) const;
(1)
template< class K >
size_type count( const K& x ) const;
(2) (C++14 起)

返回與指定引數“等價”的鍵的元素數量。

1) 返回鍵為 key 的元素數量。
2) 返回鍵與值 x 比較等價的元素數量。此過載僅在限定 ID Compare::is_transparent 有效並表示一種型別時才參與過載決議。它允許不構造 Key 的例項即可呼叫此函式。

目錄

[編輯] 引數

key - 要計數的元素的鍵值
x - 與鍵比較的備用值

[編輯] 返回值

鍵與 keyx 比較等價的元素數量。

[編輯] 複雜度

對容器大小呈對數複雜度,加上對找到的元素數量呈線性複雜度。

注意

特性測試 標準 特性
__cpp_lib_generic_associative_lookup 201304L (C++14) 關聯容器中的異構比較查詢;過載 (2)

[編輯] 示例

[編輯] 參閱

查詢具有特定鍵的元素
(public member function) [edit]
返回與特定鍵匹配的元素範圍
(public member function) [edit]