PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ down()

static void down ( MINHEAP tree,
areanode arealist,
int  parent 
)
static

Sift Down.

Definition at line 123 of file effectivearea.c.

References areanode::area, MINHEAP::key_array, LWDEBUG, and areanode::treeindex.

Referenced by minheap_pop(), and minheap_update().

124 {
125  LWDEBUG(2, "Entered down");
126  areanode **treearray=tree->key_array;
127  int left=parent*2+1;
128  int right = left +1;
129  void *tmp;
130  int swap=parent;
131  double leftarea=0;
132  double rightarea=0;
133 
134  double parentarea=((areanode*) treearray[parent])->area;
135 
136  if(left<tree->usedSize)
137  {
138  leftarea=((areanode*) treearray[left])->area;
139  if(parentarea>leftarea)
140  swap=left;
141  }
142  if(right<tree->usedSize)
143  {
144  rightarea=((areanode*) treearray[right])->area;
145  if(rightarea<parentarea&&rightarea<leftarea)
146  swap=right;
147  }
148  if(swap>parent)
149  {
150  /*ok, we have to swap something*/
151  tmp=treearray[parent];
152  treearray[parent]=treearray[swap];
153  /*Update reference*/
154  ((areanode*) treearray[parent])->treeindex=parent;
155  treearray[swap]=tmp;
156  /*Update reference*/
157  ((areanode*) treearray[swap])->treeindex=swap;
158  if(swap<tree->usedSize)
159  down(tree,arealist,swap);
160  }
161  return;
162 }
This structure is placed in an array with one member per point.
Definition: effectivearea.h:38
double area
Definition: effectivearea.h:40
#define LWDEBUG(level, msg)
Definition: lwgeom_log.h:83
int treeindex
Definition: effectivearea.h:41
areanode ** key_array
Definition: effectivearea.h:56
static void down(MINHEAP *tree, areanode *arealist, int parent)
Sift Down.
Here is the caller graph for this function: