HeapPQ Class Reference

HeapPQ class. More...

#include <VastDefs.h>

List of all members.

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 ()
HalfedgePQextractmin ()

Protected Attributes

int PQcount
int PQmin
int PQhashsize
double ymin
double deltay
HalfedgePQhash

Detailed Description

HeapPQ class.

Maintains a hash table in order to find halfedges in n*log(n) time.

Definition at line 100 of file VastDefs.h.


Constructor & Destructor Documentation

HeapPQ::HeapPQ (  ) 

Definition at line 73 of file VastDefs.cc.

00074 {
00075     PQhash = NULL;
00076 }


Member Function Documentation

Vector2D HeapPQ::PQ_min (  ) 

Definition at line 138 of file VastDefs.cc.

Referenced by Vast::buildVoronoi().

00139 {
00140     Vector2D answer;
00141 
00142     while(PQhash[PQmin].PQnext == NULL) PQmin++;
00143 
00144     answer.x = PQhash[PQmin].PQnext->vertex->coord.x;
00145     answer.y = PQhash[PQmin].PQnext->ystar;
00146     return answer;
00147 }

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().

00109 {
00110     Halfedge *last;
00111 
00112     if(he->vertex != NULL) {
00113         last = &PQhash[PQbucket(he)];
00114         while(last->PQnext != he) last = last->PQnext;
00115 
00116         last->PQnext = he->PQnext;
00117         PQcount--;
00118         he->vertex = NULL;
00119     }
00120 }

int HeapPQ::PQempty (  ) 

Definition at line 133 of file VastDefs.cc.

Referenced by Vast::buildVoronoi().

00134 {
00135     return PQcount==0;
00136 }

Halfedge * HeapPQ::PQextractmin (  ) 

Definition at line 149 of file VastDefs.cc.

Referenced by Vast::buildVoronoi().

00150 {
00151     Halfedge *curr;
00152 
00153     curr = PQhash[PQmin].PQnext;
00154     PQhash[PQmin].PQnext = curr->PQnext;
00155     PQcount--;
00156     return curr;
00157 }

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 }

void HeapPQ::PQinsert ( Halfedge he,
Site v,
double  offset 
)

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 }


Member Data Documentation

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().


The documentation for this class was generated from the following files:
Generated on Wed May 26 16:21:17 2010 for OverSim by  doxygen 1.6.3