向量堆排序
Heap Sorting With Vectors
我有一个结构体:
struct incorrect
{
unsigned short question;
unsigned short answerChoice;
}
和堆排序函数:
template <typename iterator>
void heapSort(iterator begin,iterator end)
{
make_heap(begin,end);
sort_heap(begin,end);
}
和一个函数来合并问题的向量的结构"不正确"。我面临的问题是,当我尝试使用以下语法对结构为"不正确"的向量进行排序时:
heapSort(omitKey1.question.begin(),omitKey1.question.end());
我收到错误,问题不是不正确的成员。我该如何解决这个问题?(我也试过移除"。问题(但这似乎没有帮助)
我想你有一些像
vector<struct incorrect>omitKey1
所以,使用sort(omitKey1.begin(),omitKey1.end(),compare);
与return structure1.question < structure2.question
同样,这只是排序vector
,而不是heap
,所以我可能没有排序堆的答案。
同时看看http://www.cplusplus.com/reference/algorithm/sort_heap/
相关文章:
- 计算排序向量的向量中唯一值的计数
- 无法在我的堆排序代码中找到错误.无法正确执行.C++
- 查找两个排序向量中共有的元素
- 对的排序向量 (std::vector<pair<int, int>>) 按对的第一个元素搜索并更新第二个元素值
- 存储在堆分配向量中的指针的免费存储
- 如何从C++的对的排序向量中获取有关给定值的相应对
- 对象接收堆栈溢出异常 c++ 的排序向量
- "x"的所有元素都存在于"y"(排序向量)中吗?
- 指向指针排序向量的指针向量的 C++ 向量
- 未排序向量上的lower_bound/upper_bound
- 智能指针的排序向量:神秘崩溃
- 按类型排序向量并按类型或派生类型搜索
- 堆排序,我无法弄清楚我的代码出了什么问题,输出顺序不正确
- 如何在不使用标准算法的情况下在排序向量中添加 c 元素?
- 堆排序它不起作用或计算不正确
- C++排序向量<double>与在<Object>双成员变量上键控的向量
- 字符串指针的排序向量
- 堆排序从介绍到算法在c++中使用向量实现
- 堆排序向量的客户端,传递迭代器不正确
- 向量堆排序