make_heap的意义是什么? [英] What is the point of make_heap?

查看:281
本文介绍了make_heap的意义是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以告诉我STL堆函数模板(如std::make_heap)的要点吗?为什么有人会使用它们?有实际用途吗?

Can someone please tell me the point of the STL heap function templates like std::make_heap? Why would anyone ever use them? Is there a practical use?

推荐答案

如果要创建,那么您可以使用make_heap:

If you want to make a priority queue out from a list, well, you can use make_heap:

在内部,堆是一棵树, 每个节点链接到的值不大于 超过其自身价值.在生成的堆中 通过make_heap,具体位置 树中的一个元素而不是 由内存消耗决定 链接由其绝对值确定 序列中的位置,带* first 始终是 堆.

Internally, a heap is a tree where each node links to values not greater than its own value. In heaps generated by make_heap, the specific position of an element in the tree rather than being determined by memory-consuming links is determined by its absolute position in the sequence, with *first being always the highest value in the heap.

堆允许添加或删除元素 从对数时间通过使用 函数push_heap和pop_heap, 保留其堆属性.

Heaps allow to add or remove elements from it in logarithmic time by using functions push_heap and pop_heap, which preserve its heap properties.

这篇关于make_heap的意义是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆