OverSim
HeapPQ Class Reference

HeapPQ class. More...

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

{
PQhash = NULL;
}

Member Function Documentation

Vector2D HeapPQ::PQ_min ( )

Definition at line 138 of file VastDefs.cc.

Referenced by Vast::buildVoronoi().

{
Vector2D answer;
while(PQhash[PQmin].PQnext == NULL) PQmin++;
answer.x = PQhash[PQmin].PQnext->vertex->coord.x;
answer.y = PQhash[PQmin].PQnext->ystar;
return answer;
}
int HeapPQ::PQbucket ( Halfedge he)

Definition at line 122 of file VastDefs.cc.

Referenced by PQdelete(), and PQinsert().

{
int bucket;
bucket = (int)((he->ystar - ymin)/deltay) * PQhashsize;
if(bucket < 0) bucket = 0;
if(bucket >= PQhashsize) bucket = PQhashsize-1;
if(bucket < PQmin) PQmin = bucket;
return bucket;
}
void HeapPQ::PQdelete ( Halfedge he)

Definition at line 108 of file VastDefs.cc.

Referenced by Vast::buildVoronoi().

{
Halfedge *last;
if(he->vertex != NULL) {
last = &PQhash[PQbucket(he)];
while(last->PQnext != he) last = last->PQnext;
last->PQnext = he->PQnext;
he->vertex = NULL;
}
}
int HeapPQ::PQempty ( )

Definition at line 133 of file VastDefs.cc.

Referenced by Vast::buildVoronoi().

{
return PQcount==0;
}
Halfedge * HeapPQ::PQextractmin ( )

Definition at line 149 of file VastDefs.cc.

Referenced by Vast::buildVoronoi().

{
Halfedge *curr;
curr = PQhash[PQmin].PQnext;
return curr;
}
void HeapPQ::PQinitialize ( int  sqrt_nsites,
double  ymin,
double  deltay 
)

Definition at line 78 of file VastDefs.cc.

Referenced by Vast::buildVoronoi().

{
PQcount = 0;
PQmin = 0;
PQhashsize = 4 * sqrt_nsites;
this->ymin = ymin;
this->deltay = deltay;
}
void HeapPQ::PQinsert ( Halfedge he,
Site v,
double  offset 
)

Definition at line 93 of file VastDefs.cc.

Referenced by Vast::buildVoronoi().

{
Halfedge *last, *next;
he->vertex = v;
he->ystar = v->coord.y + offset;
last = &PQhash[PQbucket(he)];
while((next = last->PQnext) != NULL && (he->ystar > next->ystar || (he->ystar == next->ystar && v->coord.x > next->vertex->coord.x))) {
last = next;
}
he->PQnext = last->PQnext;
last->PQnext = he;
}
void HeapPQ::PQreset ( )

Definition at line 88 of file VastDefs.cc.

Referenced by Vast::buildVoronoi().

{
delete[] PQhash;
}

Member Data Documentation

double HeapPQ::deltay
protected

Definition at line 115 of file VastDefs.h.

Referenced by PQbucket(), and PQinitialize().

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(), and PQinitialize().


The documentation for this class was generated from the following files: