20static const int NCATS = 1 <<
SHIFT;
22#define NODE struct Cell_stats_node
25static void init_node(
NODE *,
int,
int);
75 if ((
N = s->
N) == 0) {
85 idx = -((-cat) >>
SHIFT) - 1;
86 offset = cat + ((-idx) <<
SHIFT) - 1;
90 offset = cat - (idx <<
SHIFT);
93 init_node(&node[1], idx, offset);
105 idx = -((-cat) >>
SHIFT) - 1;
106 offset = cat + ((-idx) <<
SHIFT) - 1;
110 offset = cat - (idx <<
SHIFT);
115 pnode = &node[p = q];
116 if (pnode->idx == idx) {
117 pnode->count[offset]++;
120 if (pnode->idx > idx)
139 init_node(
new_node = &node[
N], idx, offset);
141 if (pnode->idx > idx) {
156static void init_node(
NODE *node,
int idx,
int offset)
161 count = node->count = (
long *)
G_calloc(i = NCATS,
sizeof(
long));
165 node->count[offset] = 1;
195 return (*
count != 0);
214 idx = -((-cat) >>
SHIFT) - 1;
215 offset = cat + ((-idx) <<
SHIFT) - 1;
219 offset = cat - (idx <<
SHIFT);
224 if (s->
node[q].idx == idx) {
226 return (*
count != 0);
228 if (s->
node[q].idx > idx)
231 q = s->
node[q].right;
384 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