flat_multimap::emplace_hint

flat_multimap::emplace_hint (힌트 제자리 삽입)

힌트 반복자와 함께 키-값 쌍을 제자리 생성해 삽입하는 멤버 함수예요. <flat_map> 헤더, C++23부터.

출처: cppreference

본문

emplace_hint는 힌트 위치를 참고해 제자리 삽입을 수행해요.

template< class... Args >
iterator emplace_hint( const_iterator hint, Args&&... args );
  • hint는 삽입 위치 근처를 가리켜 탐색을 빠르게 할 수 있어요.
  • 반환 값: 삽입된 요소를 가리키는 반복자.
  • flat_multimap은 중복 키를 허용하므로 항상 삽입돼요.
std::flat_multimap<std::string, int> m;
auto it = m.emplace_hint(m.end(), "banana", 5);

삽입 위치를 어느 정도 알고 있을 때 탐색 비용을 줄여 삽입하는 함수예요.

더 알아보기 (Learn more)

cppreference