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

履歴 編集

function
<queue>

std::priority_queue::size

size_type size() const;

概要

priority_queueに格納されている要素の個数を返す。

内部のコンテナの size() メンバ関数を呼ぶ。

効果

return c.size();

戻り値

priority_queue の内部のコンテナに含まれている要素の個数。

size_type は符号なし汎整数型。

#include <iostream>
#include <queue>

int main()
{
  std::priority_queue<int> que;

  que.push(1);
  que.push(2);
  que.push(3);

  std::size_t n = que.size();
  std::cout << n << std::endl;
}

出力

3

参照