7 static int NCATS = 1 << 
SHIFT;
 
    9 #define NODE struct Cell_stats_node 
   11 static int next_node(
struct Cell_stats *);
 
   12 static int init_node(
NODE *, 
int, 
int);
 
   38     s->node = (
NODE *) G_malloc(s->tlen * 
sizeof(
NODE));
 
   39     s->null_data_count = 0;
 
   73     register NODE *node, *pnode;
 
   74     register NODE *new_node;
 
   82     if ((N = s->N) == 0) {
 
   93                 offset = cat + ((-idx) << 
SHIFT) - 1;
 
   97                 offset = cat - (idx << 
SHIFT);
 
  100             init_node(&node[1], idx, offset);
 
  108             s->null_data_count++;
 
  113             offset = cat + ((-idx) << 
SHIFT) - 1;
 
  117             offset = cat - (idx << 
SHIFT);
 
  122             pnode = &node[p = 
q];
 
  123             if (pnode->idx == idx) {
 
  124                 pnode->count[offset]++;
 
  127             if (pnode->idx > idx)
 
  141                 (
NODE *) G_realloc((
char *)node,
 
  147         init_node(new_node = &node[N], idx, offset);
 
  149         if (pnode->idx > idx) {
 
  150             new_node->right = -p;       
 
  154             new_node->right = pnode->right;     
 
  164 static int init_node(
NODE * node, 
int idx, 
int offset)
 
  166     register long *
count;
 
  169     count = node->count = (
long *)G_calloc(i = NCATS, 
sizeof(
long));
 
  173     node->count[offset] = 1;
 
  212         *count = s->null_data_count;
 
  213         return (*count != 0);
 
  233         offset = cat + ((-idx) << 
SHIFT) - 1;
 
  237         offset = cat - (idx << 
SHIFT);
 
  242         if (s->node[q].idx == idx) {
 
  243             *count = s->node[
q].count[offset];
 
  244             return (*count != 0);
 
  246         if (s->node[q].idx > idx)
 
  249             q = s->node[
q].right;       
 
  273     while ((q = s->node[s->curp].left))
 
  280 static int next_node(
struct Cell_stats *
s)
 
  285     s->curp = s->node[s->curp].right;
 
  291         s->curp = -(s->curp);
 
  295     while ((q = s->node[s->curp].left)) 
 
  357         if (s->curoffset >= NCATS) {
 
  363         if ((*count = s->node[s->curp].count[s->curoffset])) {
 
  364             idx = s->node[s->curp].idx;
 
  373                 *cat = -((-idx) << 
SHIFT) + s->curoffset + 1;
 
  375                 *cat = (idx << 
SHIFT) + s->curoffset;
 
  398     *count = s->null_data_count;
 
  417     for (i = 1; i <= s->N; i++)
 
int G_is_c_null_value(const CELL *cellVal)
Returns 1 if cell is NULL, 0 otherwise. This will test if the value cell is the largest int...
int G_free_cell_stats(struct Cell_stats *s)
free cell stats 
void G_free(void *buf)
Free allocated memory. 
int G_next_cell_stat(CELL *cat, long *count, struct Cell_stats *s)
retrieve sorted cell stats 
int G_get_stats_for_null_value(long *count, const struct Cell_stats *s)
Get a number of null values from stats structure. Note: when reporting values which appear in a map u...
int G_find_cell_stat(CELL cat, long *count, const struct Cell_stats *s)
random query of cell stats 
int G_update_cell_stats(const CELL *cell, int n, struct Cell_stats *s)
add data to cell stats 
int G_rewind_cell_stats(struct Cell_stats *s)
reset/rewind cell stats 
int G_init_cell_stats(struct Cell_stats *s)
initialize cell stats