PostGIS  2.1.10dev-r@@SVN_REVISION@@
static struct quantile_llist_element* quantile_llist_index_search ( struct quantile_llist qll,
double  value,
uint32_t *  index 
)
static

Definition at line 4083 of file rt_api.c.

References quantile_llist_index::element, FLT_EQ, quantile_llist::head, quantile_llist::index, quantile_llist::index_max, RASTER_DEBUGF, and quantile_llist_element::value.

Referenced by rt_band_get_quantiles_stream().

4087  {
4088  uint32_t i = 0, j = 0;
4089  RASTER_DEBUGF(5, "searching index for value %f", value);
4090 
4091  for (i = 0; i < qll->index_max; i++) {
4092  if (NULL == qll->index[i].element) {
4093  if (i < 1) break;
4094  continue;
4095  }
4096  if (value > (qll->index[i]).element->value) continue;
4097 
4098  if (FLT_EQ(value, qll->index[i].element->value)) {
4099  RASTER_DEBUGF(5, "using index value at %d = %f", i, qll->index[i].element->value);
4100  *index = i * 100;
4101  return qll->index[i].element;
4102  }
4103  else if (i > 0) {
4104  for (j = 1; j < i; j++) {
4105  if (NULL != qll->index[i - j].element) {
4106  RASTER_DEBUGF(5, "using index value at %d = %f", i - j, qll->index[i - j].element->value);
4107  *index = (i - j) * 100;
4108  return qll->index[i - j].element;
4109  }
4110  }
4111  }
4112  }
4113 
4114  *index = 0;
4115  return qll->head;
4116 }
struct quantile_llist_element * element
Definition: rt_api.h:2335
#define RASTER_DEBUGF(level, msg,...)
Definition: rt_api.h:285
uint32_t index_max
Definition: rt_api.h:2320
#define FLT_EQ(x, y)
Definition: rt_api.h:2159
struct quantile_llist_index * index
Definition: rt_api.h:2319
struct quantile_llist_element * head
Definition: rt_api.h:2314

Here is the caller graph for this function: