Skip to content

Latest commit

 

History

History
94 lines (74 loc) · 3.05 KB

is_heap.md

File metadata and controls

94 lines (74 loc) · 3.05 KB

is_heap

  • algorithm[meta header]
  • std[meta namespace]
  • function template[meta id-type]
  • cpp11[meta cpp]
namespace std {
  template <class RandomAccessIterator>
  bool is_heap(RandomAccessIterator first,
               RandomAccessIterator last);           // (1) C++11

  template <class RandomAccessIterator>
  constexpr bool is_heap(RandomAccessIterator first,
                         RandomAccessIterator last); // (1) C++20

  template <class RandomAccessIterator, class Compare>
  bool is_heap(RandomAccessIterator first,
               RandomAccessIterator last,
               Compare comp);                        // (2) C++11

  template <class RandomAccessIterator, class Compare>
  constexpr bool is_heap(RandomAccessIterator first,
                         RandomAccessIterator last,
                         Compare comp);              // (2) C++20

  template <class ExecutionPolicy, class RandomAccessIterator>
  bool is_heap(ExecutionPolicy&& exec,
               RandomAccessIterator first,
               RandomAccessIterator last);           // (3) C++17

  template <class ExecutionPolicy, class RandomAccessIterator, class Compare>
  bool is_heap(ExecutionPolicy&& exec,
               RandomAccessIterator first,
               RandomAccessIterator last,
               Compare comp);                        // (4) C++17
}

概要

範囲がヒープ化されているか判定する。

戻り値

#include <iostream>
#include <vector>
#include <algorithm>

int main()
{
  std::vector<int> v = {3, 1, 4};

  std::cout << std::boolalpha;

  std::cout << "before: is heap? "
            << std::is_heap(v.begin(), v.end()) << std::endl;

  std::make_heap(v.begin(), v.end());
  std::cout << " after: is heap? "
            << std::is_heap(v.begin(), v.end()) << std::endl;
}
  • std::is_heap[color ff0000]
  • std::make_heap[link make_heap.md]

出力

before: is heap? false
 after: is heap? true

バージョン

言語

  • C++11

処理系

  • Clang: ??
  • GCC: 4.7.0
  • ICC: ??
  • Visual C++: 2010, 2012, 2013, 2015
    • 2008では、_HAS_TRADITIONAL_STLを1に定義してから<algorithm>をインクルードすると、stdext名前空間でis_heapが定義される。

参照