#include <VastDefs.h>
Public Member Functions | |
HeapPQ () | |
void | PQinitialize (int sqrt_nsites, double ymin, double deltay) |
void | PQreset () |
void | PQinsert (Halfedge *he, Site *v, double offset) |
void | PQdelete (Halfedge *he) |
int | PQbucket (Halfedge *he) |
int | PQempty () |
Vector2D | PQ_min () |
Halfedge * | PQextractmin () |
Protected Attributes | |
int | PQcount |
int | PQmin |
int | PQhashsize |
double | ymin |
double | deltay |
Halfedge * | PQhash |
HeapPQ class.
Maintains a hash table in order to find halfedges in n*log(n) time.
Definition at line 100 of file VastDefs.h.
HeapPQ::HeapPQ | ( | ) |
Definition at line 73 of file VastDefs.cc.
00074 { 00075 PQhash = NULL; 00076 }
Vector2D HeapPQ::PQ_min | ( | ) |
Definition at line 138 of file VastDefs.cc.
Referenced by Vast::buildVoronoi().
int HeapPQ::PQbucket | ( | Halfedge * | he | ) |
Definition at line 122 of file VastDefs.cc.
Referenced by PQdelete(), and PQinsert().
00123 { 00124 int bucket; 00125 00126 bucket = (int)((he->ystar - ymin)/deltay) * PQhashsize; 00127 if(bucket < 0) bucket = 0; 00128 if(bucket >= PQhashsize) bucket = PQhashsize-1; 00129 if(bucket < PQmin) PQmin = bucket; 00130 return bucket; 00131 }
void HeapPQ::PQdelete | ( | Halfedge * | he | ) |
Definition at line 108 of file VastDefs.cc.
Referenced by Vast::buildVoronoi().
int HeapPQ::PQempty | ( | ) |
Definition at line 133 of file VastDefs.cc.
Referenced by Vast::buildVoronoi().
00134 { 00135 return PQcount==0; 00136 }
Halfedge * HeapPQ::PQextractmin | ( | ) |
void HeapPQ::PQinitialize | ( | int | sqrt_nsites, | |
double | ymin, | |||
double | deltay | |||
) |
Definition at line 78 of file VastDefs.cc.
Referenced by Vast::buildVoronoi().
00079 { 00080 PQcount = 0; 00081 PQmin = 0; 00082 PQhashsize = 4 * sqrt_nsites; 00083 PQhash = new Halfedge[PQhashsize]; 00084 this->ymin = ymin; 00085 this->deltay = deltay; 00086 }
Definition at line 93 of file VastDefs.cc.
Referenced by Vast::buildVoronoi().
00094 { 00095 Halfedge *last, *next; 00096 00097 he->vertex = v; 00098 he->ystar = v->coord.y + offset; 00099 last = &PQhash[PQbucket(he)]; 00100 while((next = last->PQnext) != NULL && (he->ystar > next->ystar || (he->ystar == next->ystar && v->coord.x > next->vertex->coord.x))) { 00101 last = next; 00102 } 00103 he->PQnext = last->PQnext; 00104 last->PQnext = he; 00105 PQcount++; 00106 }
void HeapPQ::PQreset | ( | ) |
Definition at line 88 of file VastDefs.cc.
Referenced by Vast::buildVoronoi().
00089 { 00090 delete[] PQhash; 00091 }
double HeapPQ::deltay [protected] |
Definition at line 115 of file VastDefs.h.
Referenced by PQbucket().
int HeapPQ::PQcount [protected] |
Definition at line 114 of file VastDefs.h.
Referenced by PQdelete(), PQempty(), PQextractmin(), PQinitialize(), and PQinsert().
Halfedge* HeapPQ::PQhash [protected] |
Definition at line 116 of file VastDefs.h.
Referenced by HeapPQ(), PQ_min(), PQdelete(), PQextractmin(), PQinitialize(), PQinsert(), and PQreset().
int HeapPQ::PQhashsize [protected] |
Definition at line 114 of file VastDefs.h.
Referenced by PQbucket(), and PQinitialize().
int HeapPQ::PQmin [protected] |
Definition at line 114 of file VastDefs.h.
Referenced by PQ_min(), PQbucket(), PQextractmin(), and PQinitialize().
double HeapPQ::ymin [protected] |
Definition at line 115 of file VastDefs.h.
Referenced by PQbucket().