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)
142 init_node(new_node = &node[N], idx, offset);
144 if (pnode->idx > idx) {
145 new_node->right = -p;
149 new_node->right = pnode->right;
159 static void init_node(
NODE * node,
int idx,
int offset)
164 count = node->count = (
long *)
G_calloc(i = NCATS,
sizeof(
long));
168 node->count[offset] = 1;
199 return (*count != 0);
218 idx = -((-cat) >>
SHIFT) - 1;
219 offset = cat + ((-idx) <<
SHIFT) - 1;
223 offset = cat - (idx <<
SHIFT);
230 return (*count != 0);
389 for (i = 1; i <= s->
N; i++)
void Rast_init_cell_stats(struct Cell_stats *s)
Initialize cell stats.
void G_free(void *)
Free allocated memory.
int Rast_rewind_cell_stats(struct Cell_stats *s)
Reset/rewind cell stats.
void Rast_free_cell_stats(struct Cell_stats *s)
Free cell stats structure.
int Rast_update_cell_stats(const CELL *cell, int n, struct Cell_stats *s)
Add data to 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.
void Rast_get_stats_for_null_value(long *count, const struct Cell_stats *s)
Get number of null values.
struct Cell_stats::Cell_stats_node * node
#define Rast_is_c_null_value(cellVal)