https://gitlab.inria.fr/cado-nfs/cado-nfs
Tip revision: 132f63c1a343af4280df47cf9cc0453060d506b7 authored by Jérémie Detrey on 10 March 2014, 10:29:14 UTC
Fixed bug in total time and yield computations.
Fixed bug in total time and yield computations.
Tip revision: 132f63c
rowset_heap.cpp
#include "cado.h"
#include <stddef.h> /* ptrdiff_t */
#include <stdint.h>
#include <algorithm>
#include "rowset_heap.h"
int heap_index_compare(const struct bucket * a, const struct bucket * b)
{
return (int32_t) a->i - (int32_t) b->i;
}
int heap_compare(const struct bucket * a, const struct bucket * b)
{
/* Returns whether b is a better candidate to be on top of the heap
* IOW: Whether b is lighter than a
* */
if (b->room == 0) return 0;
if (a->room == 0) return 1;
return b->s < a->s;
}
struct hcmp {
bool operator() (const bucket& a, const bucket& b) const {
return heap_compare(&a, &b);
}
};
void push_heap(struct bucket * __first, struct bucket * __last)
{
std::push_heap(__first, __last, hcmp());
}
void pop_heap(struct bucket * __first, struct bucket * __last)
{
std::pop_heap(__first, __last, hcmp());
}
void make_heap(struct bucket * __first, struct bucket * __last)
{
std::make_heap(__first, __last, hcmp());
}
/* }}} */