PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ quantile_llist_insert()

static struct quantile_llist_element* quantile_llist_insert ( struct quantile_llist_element element,
double  value,
uint32_t idx 
)
static

Definition at line 796 of file rt_statistics.c.

800  {
801  struct quantile_llist_element *qle = NULL;
802 
803  if (NULL == element) {
804  qle = rtalloc(sizeof(struct quantile_llist_element));
805  RASTER_DEBUGF(4, "qle @ %p is only element in list", qle);
806  if (NULL == qle) return NULL;
807 
808  qle->value = value;
809  qle->count = 1;
810 
811  qle->prev = NULL;
812  qle->next = NULL;
813 
814  if (NULL != idx) *idx = 0;
815  return qle;
816  }
817  else if (value > element->value) {
818  if (NULL != idx) *idx += 1;
819  if (NULL != element->next)
820  return quantile_llist_insert(element->next, value, idx);
821  /* insert as last element in list */
822  else {
823  qle = rtalloc(sizeof(struct quantile_llist_element));
824  RASTER_DEBUGF(4, "insert qle @ %p as last element", qle);
825  if (NULL == qle) return NULL;
826 
827  qle->value = value;
828  qle->count = 1;
829 
830  qle->prev = element;
831  qle->next = NULL;
832  element->next = qle;
833 
834  return qle;
835  }
836  }
837  /* insert before current element */
838  else {
839  qle = rtalloc(sizeof(struct quantile_llist_element));
840  RASTER_DEBUGF(4, "insert qle @ %p before current element", qle);
841  if (NULL == qle) return NULL;
842 
843  qle->value = value;
844  qle->count = 1;
845 
846  if (NULL != element->prev) element->prev->next = qle;
847  qle->next = element;
848  qle->prev = element->prev;
849  element->prev = qle;
850 
851  return qle;
852  }
853 }
void * rtalloc(size_t size)
Wrappers used for managing memory.
Definition: rt_context.c:171
#define RASTER_DEBUGF(level, msg,...)
Definition: librtcore.h:299
int value
Definition: genraster.py:61
static struct quantile_llist_element * quantile_llist_insert(struct quantile_llist_element *element, double value, uint32_t *idx)
struct quantile_llist_element * prev
Definition: librtcore.h:2413
struct quantile_llist_element * next
Definition: librtcore.h:2414

References quantile_llist_element::count, quantile_llist_element::next, quantile_llist_element::prev, RASTER_DEBUGF, rtalloc(), quantile_llist_element::value, and genraster::value.

Referenced by rt_band_get_quantiles_stream().

Here is the call graph for this function:
Here is the caller graph for this function: