PostGIS  2.2.7dev-r@@SVN_REVISION@@
static void down ( MINHEAP tree,
areanode arealist,
int  parent 
)
static

Sift Down.

Definition at line 109 of file effectivearea.c.

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

Referenced by minheap_pop(), and minheap_update().

110 {
111  LWDEBUG(2, "Entered down");
112  areanode **treearray=tree->key_array;
113  int left=parent*2+1;
114  int right = left +1;
115  void *tmp;
116  int swap=parent;
117  double leftarea=0;
118  double rightarea=0;
119 
120  double parentarea=((areanode*) treearray[parent])->area;
121 
122  if(left<tree->usedSize)
123  {
124  leftarea=((areanode*) treearray[left])->area;
125  if(parentarea>leftarea)
126  swap=left;
127  }
128  if(right<tree->usedSize)
129  {
130  rightarea=((areanode*) treearray[right])->area;
131  if(rightarea<parentarea&&rightarea<leftarea)
132  swap=right;
133  }
134  if(swap>parent)
135  {
136  /*ok, we have to swap something*/
137  tmp=treearray[parent];
138  treearray[parent]=treearray[swap];
139  /*Update reference*/
140  ((areanode*) treearray[parent])->treeindex=parent;
141  treearray[swap]=tmp;
142  /*Update reference*/
143  ((areanode*) treearray[swap])->treeindex=swap;
144  if(swap<tree->usedSize)
145  down(tree,arealist,swap);
146  }
147  return;
148 }
This structure is placed in an array with one member per point.
Definition: effectivearea.h:24
double area
Definition: effectivearea.h:26
#define LWDEBUG(level, msg)
Definition: lwgeom_log.h:50
int treeindex
Definition: effectivearea.h:27
areanode ** key_array
Definition: effectivearea.h:42
static void down(MINHEAP *tree, areanode *arealist, int parent)
Sift Down.

Here is the caller graph for this function: