#include <pr_queue.h>

Classes | |
| struct | pq_node |
Public Member Functions | |
| ANNpr_queue (int max) | |
| ~ANNpr_queue () | |
| ANNbool | empty () |
| ANNbool | non_empty () |
| void | reset () |
| void | insert (PQkey kv, PQinfo inf) |
| void | extr_min (PQkey &kv, PQinfo &inf) |
Definition at line 54 of file pr_queue.h.
| ANNpr_queue::ANNpr_queue | ( | int | max ) | [inline] |
Definition at line 65 of file pr_queue.h.
References QuadProgPP::max().
| ANNpr_queue::~ANNpr_queue | ( | ) | [inline] |
Definition at line 72 of file pr_queue.h.
{ delete [] pq; }
| ANNbool ANNpr_queue::empty | ( | ) | [inline] |
Definition at line 102 of file pr_queue.h.
References ANN_FLOP.
Referenced by ANNkd_tree::annkPriSearch().
{
kv = pq[1].key; // key of min item
inf = pq[1].info; // information of min item
register PQkey kn = pq[n--].key;// last item in queue
register int p = 1; // p points to item out of position
register int r = p<<1; // left child of p
while (r <= n) { // while r is still within the heap
ANN_FLOP(2) // increment floating ops
// set r to smaller child of p
if (r < n && pq[r].key > pq[r+1].key) r++;
if (kn <= pq[r].key) // in proper order
break;
pq[p] = pq[r]; // else swap with child
p = r; // advance pointers
r = p<<1;
}
pq[p] = pq[n+1]; // insert last item in proper place
}
Definition at line 84 of file pr_queue.h.
References ANN_FLOP, ANNabort, and annError().
Referenced by ANNkd_split::ann_pri_search(), ANNbd_shrink::ann_pri_search(), and ANNkd_tree::annkPriSearch().
{
if (++n > max_size) annError("Priority queue overflow.", ANNabort);
register int r = n;
while (r > 1) { // sift up new item
register int p = r/2;
ANN_FLOP(1) // increment floating ops
if (pq[p].key <= kv) // in proper order
break;
pq[r] = pq[p]; // else swap with parent
r = p;
}
pq[r].key = kv; // insert new item at final location
pq[r].info = inf;
}
| ANNbool ANNpr_queue::non_empty | ( | ) | [inline] |
Definition at line 78 of file pr_queue.h.
References ANNfalse, and ANNtrue.
Referenced by ANNkd_tree::annkPriSearch().
| void ANNpr_queue::reset | ( | ) | [inline] |
Definition at line 81 of file pr_queue.h.
{ n = 0; }
1.7.2