zoukankan      html  css  js  c++  java
  • STL: heap相关算法

    make_heap

    Converts elements from a specified range into a heap in which the first element is the largest and for which a sorting criterion may be specified with a binary predicate.

    template<class RandomAccessIterator>
       void make_heap(
          RandomAccessIterator _First, 
          RandomAccessIterator _Last
       );
    template<class RandomAccessIterator, class BinaryPredicate>
       void make_heap(
          RandomAccessIterator _First, 
          RandomAccessIterator _Last,
          BinaryPredicate _Comp
       );

    pop_heap

    Removes the largest element from the front of a heap to the next-to-last position in the range and then forms a new heap from the remaining elements.

    template<class RandomAccessIterator>
       void pop_heap(
          RandomAccessIterator _First, 
          RandomAccessIterator _Last
       );
    template<class RandomAccessIterator, class BinaryPredicate>
       void pop_heap(
          RandomAccessIterator _First, 
          RandomAccessIterator _Last,
          BinaryPredicate _Comp
       );

    push_heap

    Adds an element that is at the end of a range to an existing heap consisting of the prior elements in the range.

    template<class RandomAccessIterator>
       void push_heap(
          RandomAccessIterator _First, 
          RandomAccessIterator _Last
       );
    template<class RandomAccessIterator, class BinaryPredicate>
       void push_heap(
          RandomAccessIterator _First, 
          RandomAccessIterator _Last,
          BinaryPredicate _Comp
       );

    注,The element must first be pushed back to the end of an existing heap and then the algorithm is used to add this element to the existing heap.

    sort_heap

    Converts a heap into a sorted range

    template<class RandomAccessIterator>
       void sort_heap(
          RandomAccessIterator _First, 
          RandomAccessIterator _Last
       );
    template<class RandomAccessIterator, class Predicate>
       void sort_heap(
          RandomAccessIterator _First, 
          RandomAccessIterator _Last,
          Predicate _Comp
       );
  • 相关阅读:
    Ubuntu16.04 配置SSH无密码登录
    Ubuntu16.04 配置SSH无密码登录
    Ubuntu 16.04 安装JDK
    Ubuntu 16.04 安装JDK
    8.1 mnist_soft,TensorFlow构建回归模型
    8.1 mnist_soft,TensorFlow构建回归模型
    Ubuntu16.04 安装Python开发环境
    Ubuntu16.04 安装Python开发环境
    HTML学习笔记(一) 基本介绍
    CSS学习笔记(五) 过渡与动画
  • 原文地址:https://www.cnblogs.com/freewater/p/2948169.html
Copyright © 2011-2022 走看看