22 static const int NCATS = 1 <<
SHIFT;
24 #define NODE struct Cell_stats_node
27 static void init_node(
NODE *,
int,
int);
77 if ((
N = s->
N) == 0) {
87 idx = -((-cat) >>
SHIFT) - 1;
88 offset = cat + ((-idx) <<
SHIFT) - 1;
92 offset = cat - (idx <<
SHIFT);
95 init_node(&node[1], idx, offset);
107 idx = -((-cat) >>
SHIFT) - 1;
108 offset = cat + ((-idx) <<
SHIFT) - 1;
112 offset = cat - (idx <<
SHIFT);
117 pnode = &node[p = q];
118 if (pnode->idx == idx) {
119 pnode->count[offset]++;
122 if (pnode->idx > idx)
141 init_node(new_node = &node[
N], idx, offset);
143 if (pnode->idx > idx) {
144 new_node->right = -p;
148 new_node->right = pnode->right;
158 static void init_node(
NODE *node,
int idx,
int offset)
163 count = node->count = (
long *)
G_calloc(i = NCATS,
sizeof(
long));
167 node->count[offset] = 1;
197 return (*
count != 0);
216 idx = -((-cat) >>
SHIFT) - 1;
217 offset = cat + ((-idx) <<
SHIFT) - 1;
221 offset = cat - (idx <<
SHIFT);
228 return (*
count != 0);
386 for (i = 1; i <= s->
N; i++)
int Rast_rewind_cell_stats(struct Cell_stats *s)
Reset/rewind cell stats.
int Rast_find_cell_stat(CELL cat, long *count, const struct Cell_stats *s)
Random query of cell stats.
int Rast_next_cell_stat(CELL *cat, long *count, struct Cell_stats *s)
Retrieve sorted cell stats.
int Rast_update_cell_stats(const CELL *cell, int n, struct Cell_stats *s)
Add data to cell stats.
void Rast_init_cell_stats(struct Cell_stats *s)
Initialize cell stats.
void Rast_get_stats_for_null_value(long *count, const struct Cell_stats *s)
Get number of null values.
void Rast_free_cell_stats(struct Cell_stats *s)
Free cell stats structure.
void G_free(void *)
Free allocated memory.
#define Rast_is_c_null_value(cellVal)
struct Cell_stats::Cell_stats_node * node