GRASS Programmer's Manual
6.5.svn(2014)-r66266
Main Page
Related Pages
Namespaces
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Pages
sort_cell.c
Go to the documentation of this file.
1
#include <stdlib.h>
2
#include <grass/gis.h>
3
#include <grass/stats.h>
4
5
static
int
ascending(
const
void
*aa,
const
void
*bb)
6
{
7
const
DCELL *a = aa, *
b
= bb;
8
9
if
(
G_is_d_null_value
((DCELL *) a) &&
G_is_d_null_value
((DCELL *) b))
10
return
0;
11
12
if
(
G_is_d_null_value
((DCELL *) a))
13
return
1;
14
15
if
(
G_is_d_null_value
((DCELL *) b))
16
return
-1;
17
18
return
(*a < *b) ? -1 : (*a > *
b
) ? 1 : 0;
19
}
20
21
int
sort_cell
(DCELL * array,
int
n
)
22
{
23
int
i;
24
25
qsort(array, n,
sizeof
(DCELL), ascending);
26
27
for
(i = 0; i <
n
; i++)
28
if
(
G_is_d_null_value
(&array[i]))
29
break
;
30
31
return
i;
32
}
33
34
int
sort_cell_w
(DCELL(*array)[2],
int
n
)
35
{
36
int
i;
37
38
qsort(array, n, 2 *
sizeof
(DCELL), ascending);
39
40
for
(i = 0; i <
n
; i++)
41
if
(
G_is_d_null_value
(&array[i][0]))
42
break
;
43
44
return
i;
45
}
b
float b
Definition:
named_colr.c:8
sort_cell_w
int sort_cell_w(DCELL(*array)[2], int n)
Definition:
sort_cell.c:34
G_is_d_null_value
int G_is_d_null_value(const DCELL *dcellVal)
Returns 1 if dcell is NULL, 0 otherwise. This will test if the value dcell is a NaN. Same test as in G_is_f_null_value().
Definition:
null_val.c:306
sort_cell
int sort_cell(DCELL *array, int n)
Definition:
sort_cell.c:21
n
int n
Definition:
dataquad.c:291
lib
stats
sort_cell.c
Generated on Sat Jan 2 2016 01:46:49 for GRASS Programmer's Manual by
1.8.5