最終更新日時(UTC):
が更新

履歴 編集

function
<unordered_set>

std::unordered_multiset::clear(C++11)

void clear() noexcept;

概要

コンテナ内のすべての要素を削除する。

要件

なし。

効果

コンテナ内のすべての要素を削除する。

事後条件

empty() == true

戻り値

なし。

例外

投げない。

計算量

本関数呼び出し前のコンテナの要素数(size())に比例

#include <iostream>
#include <unordered_set>

int main()
{
  std::unordered_multiset<int> ums{ 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, };

  std::cout << std::boolalpha;
  std::cout << ums.empty() << std::endl;
  ums.clear();
  std::cout << ums.empty() << std::endl;
}

出力

false
true

バージョン

言語

  • C++11

処理系

関連項目

名前 説明
empty コンテナが空かどうかを判定
emplace コンテナ内への要素の直接構築
emplace_hint 挿入位置のヒントを使用したコンテナ内への要素の直接構築
insert 要素の追加
erase 要素の削除
swap 内容の交換