名前空間
変種
操作

std::is_heap

提供: cppreference.com
< cpp‎ | algorithm

 
 
アルゴリズムライブラリ
機能します
Original:
Functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
シーケンス動作を非改変
Original:
Non-modifying sequence operations
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
シーケンス動作を変更する
Original:
Modifying sequence operations
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
操作を仕切る
Original:
Partitioning operations
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
(ソートされた範囲で)ソート操作
Original:
Sorting operations (on sorted ranges)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
バイナリ検索操作(ソート範囲で)
Original:
Binary search operations (on sorted ranges)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
(ソートされた範囲で)操作を設定します
Original:
Set operations (on sorted ranges)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
ヒープ操作
Original:
Heap operations
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
is_heap
is_heap_until(C++11)
make_heap
最小値/最大値操作
Original:
Minimum/maximum operations
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
数値演算
Original:
Numeric operations
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Cライブラリ
Original:
C library
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
 
Defined in header <algorithm>
template< class RandomIt >
bool is_heap( RandomIt first, RandomIt last );
(1)
template< class RandomIt, class Compare >
bool is_heap( RandomIt first, RandomIt last, Compare comp );
(2)
範囲内の要素かどうかをチェックし[first, last)ヒープアール.
Original:
Checks if the elements in range [first, last) are a heap.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
第二はis_heap与えられた比較関数を使用するのに対しoperator<の最初のバージョンでは、要素を比較するためにcompを使用しています.
Original:
The first version of is_heap uses operator< to compare elements, whereas the second uses the given comparison function comp.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

目次

[編集] パラメータ

first, last -
検討する要素の範囲
Original:
the range of elements to examine
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
comp - comparison function which returns ​true if the first argument is less than the second.

The signature of the comparison function should be equivalent to the following:

 bool cmp(const Type1 &a, const Type2 &b);

The signature does not need to have const &, but the function must not modify the objects passed to it.
The types Type1 and Type2 must be such that an object of type RandomIt can be dereferenced and then implicitly converted to both of them. ​

Type requirements
-
RandomIt must meet the requirements of RandomAccessIterator.

[編集] 値を返します

true範囲がヒープの場合falseその他のとき.
Original:
true if the range is heap, false otherwise.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[編集] 複雑

firstlastとの間の距離の線形
Original:
Linear in the distance between first and last
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[編集] ノート

'ヒープは、要素の範囲です[f,l)それは、次のプロパティがあります
Original:
A heap is a range of elements [f,l) that has the following properties:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
  • *f範囲内の最大要素である
    Original:
    *f is the largest element in the range
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • 新しい要素がstd::push_heap()を使用して追加できます
    Original:
    a new element can be added using std::push_heap()
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • 最初の要素はstd::pop_heap()を用いて除去することができる
    Original:
    the first element can be removed using std::pop_heap()
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
要素の実際の配置は、実装定義です.
Original:
The actual arrangement of the elements is implementation defined.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[編集]

#include <iostream>
#include <algorithm>
 
int main()
{
    std::vector<int> v { 3, 1, 4, 1, 5, 9 };
 
    std::cout << "initially, v: ";
    for (auto i : v) std::cout << i << ' ';
    std::cout << '\n';
 
    if (!std::is_heap(v.begin(), v.end())) {
        std::cout << "making heap...\n";
        std::make_heap(v.begin(), v.end());
    }
 
    std::cout << "after make_heap, v: ";
    for (auto i : v) std::cout << i << ' ';
    std::cout << '\n';
}

Output:

initially, v: 3 1 4 1 5 9 
making heap...
after make_heap, v: 9 5 4 1 1 3

[編集] も参照してください

ヒープで最大の部分範囲を見つけることができます
Original:
finds the largest subrange that is heap
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(関数テンプレート) [edit]