std::flat_multimap<Key,T,Compare,KeyContainer,MappedContainer>:: clear
From cppreference.net
<
cpp
|
container
|
flat multimap
C++
Containers library
|
(C++17)
|
||||
| Sequence | ||||
|
(C++11)
|
||||
|
(C++26)
|
||||
|
(C++26)
|
||||
|
(C++11)
|
||||
| Associative | ||||
| Unordered associative | ||||
|
(C++11)
|
||||
|
(C++11)
|
||||
|
(C++11)
|
||||
|
(C++11)
|
||||
| Adaptors | ||||
|
(C++23)
|
||||
|
(C++23)
|
||||
|
(C++23)
|
||||
|
(C++23)
|
||||
| Views | ||||
|
(C++20)
|
||||
|
(C++23)
|
||||
| Tables | ||||
| Iterator invalidation | ||||
| Member function table | ||||
| Non-member function table |
std::flat_multimap
| Member types | ||||
| Member functions | ||||
| Non-member functions | ||||
| Helper classes | ||||
| Tags | ||||
| Deduction guides | ||||
|
void
clear
(
)
noexcept
;
|
(C++23부터)
(C++26부터 constexpr) |
|
컨테이너 어댑터의 모든 요소를 지웁니다. 이 호출 이후에는 size() 가 0을 반환합니다.
포함된 요소를 참조하는 모든 참조, 포인터 및 반복자를 무효화합니다.
복잡도
컨테이너 어댑터의 크기에 선형적으로 비례, 즉 요소의 개수에 비례합니다.
예제
이 코드 실행
#include <iostream> #include <string_view> #include <flat_map> void print_info(std::string_view rem, const std::flat_multimap<int, char>& v) { std::cout << rem << "{ "; for (const auto& [key, value] : v) std::cout << '[' << key << "]:" << value << ' '; std::cout << "}\n"; std::cout << "Size=" << v.size() << '\n'; } int main() { std::flat_multimap<int, char> container{{1, 'x'}, {2, 'y'}, {3, 'z'}}; print_info("Before clear: ", container); container.clear(); print_info("After clear: ", container); }
출력:
Before clear: { [1]:x [2]:y [3]:z }
Size=3
After clear: { }
Size=0
참고 항목
|
요소를 삭제합니다
(public member function) |