std::flat_multiset<Key,Compare,KeyContainer>::clear
From cppreference.com
< cpp | container | flat multiset
| void clear() noexcept; |
(C++23から) | |
コンテナアダプターからすべての要素を消去します。この呼び出しの後、size() はゼロを返します。
コンテナ内の要素を参照する、すべての参照、ポインタ、およびイテレータを無効にします。
[編集] 複雑性
コンテナアダプターのサイズ、すなわち要素数に線形です。
[編集] 例
このコードを実行
#include <iostream> #include <string_view> #include <flat_set> void print_info(std::string_view rem, const std::flat_multiset<int>& v) { std::cout << rem << "{ "; for (const auto& value : v) std::cout << value << ' '; std::cout << "}\n"; std::cout << "Size=" << v.size() << '\n'; } int main() { std::flat_multiset<int> container{1, 2, 3}; print_info("Before clear: ", container); container.clear(); print_info("After clear: ", container); }
出力
Before clear: { 1 2 3 }
Size=3
After clear: { }
Size=0[編集] 関連項目
| 要素を削除する (公開メンバ関数) |