[ Web Proxy ]
URL:
Viewing: http://ru.cppreference.com/cpp/algorithm/sort_heap [Back]  [Original]

std::sort_heap cppreference.com
cppreference.com

std::sort_heap

cppreference.com

<metanoindex/>

 
C++
(C++20)
(C++20)
(C++11)
(C++20)
/
(C++11)
(C++11)
(C++11)
(C++17)
 
(C++20)
, ranges::copy, ranges::sort, ...
(C++17)
(C++11)(C++11)(C++11)
(C++17)
(C++11)
( )
(C++11)
/
(C++11)
(C++17)

(C++17)
(C++17)
(C++17)
C
 
<tbody> </tbody>
template< class RandomIt > void sort_heap( RandomIt first, RandomIt last );
(1)
template< class RandomIt, class Compare > void sort_heap( RandomIt first, RandomIt last, Compare comp );
(2)
[first, last) . operator< , comp.
:
Sorts the elements in the heap [first, last) in ascending order. The first version of the function uses operator< to compare the elements, the second uses the given comparison function comp.
Google.
. .

first, last
:
the range of elements to sort
Google.
. .
comp (.. , Compare), true, "", .

:

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

noexcept ( C++11) . const&, . ( const) Type1 Type2 ( , Type1& , Type1, Type1 ( C++11)). Type1 Type2 , RandomIt .

-
RandomIt ValueSwappable RandomAccessIterator.
-
The type of dereferenced RandomIt must meet the requirements of MoveAssignable and MoveConstructible.

()

N (N) , N=std::distance(first, last).
:
At most N×log(N) comparisons where N=std::distance(first, last).
Google.
. .

' [f,l), :
:
A heap is a range of elements [f,l) that has the following properties:
Google.
. .
  • *f
    :
    *f is the largest element in the range
    Google.
    . .
  • std::push_heap()
    :
    a new element can be added using std::push_heap()
    Google.
    . .
  • std::pop_heap()
    :
    the first element can be removed using std::pop_heap()
    Google.
    . .
, .
:
The actual arrangement of the elements is implementation defined.
Google.
. .

.


( ) []

Web Proxy Viewer  |  New URL  |  Original Page