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
       );
  • 相关阅读:
    springboot之异步调用@Async
    springboot之约定大约配置
    springboot之定时任务@Scheduled
    百度地图API
    JS触发服务器控件的单击事件
    jquery复选框 选中事件 及其判断是否被选中
    NopCommerce源码架构详解--初识高性能的开源商城系统cms
    基于dapper的通用泛型分页
    基于JQuery 的消息提示框效果代码
    kindeditor支持flv视频播放方法
  • 原文地址:https://www.cnblogs.com/freewater/p/2948169.html
Copyright © 2011-2022 走看看