flat_multimap::contains

flat_multimap::contains (키 존재 확인)

flat_multimap에 특정 키가 존재하는지 확인하는 멤버 함수예요. <flat_map> 헤더, C++23부터.

출처: cppreference

본문

contains는 컨테이너에 키가 하나라도 존재하면 true를 반환해요.

bool contains( const Key& key ) const;
template< class K > bool contains( const K& x ) const;
    1. key와 동등한 키가 있으면 true.
    1. 투명 비교를 지원할 때 x와 동등한 키가 있으면 true.
std::flat_multimap<std::string, int> m{{"a",1},{"a",2}};
bool has = m.contains("a");   // true
bool has2 = m.contains("z");  // false

flat_multimap은 중복 키를 허용하므로, 존재 여부는 0보다 큰 개수가 있는지로 판정해요. 정렬 벡터라 이진 탐색으로 동작해요.

더 알아보기 (Learn more)

cppreference