forked from jontodd/r.refine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqsort.c
51 lines (48 loc) · 1.24 KB
/
qsort.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/* ************************************************************
*
* MODULE: r.refine
*
* Authors: Jon Todd <[email protected]>, Laura Toma <[email protected]>
* Bowdoin College, USA
*
* Purpose: convert grid data to TIN
*
* COPYRIGHT:
* This program is free software under the GNU General Public
* License (>=v2). Read the file COPYING that comes with GRASS
* for details.
*
*
************************************************************ */
/******************************************************************************
*
* qsort.c contains compare function for use with the GNU quicksort function
*
* AUTHOR(S): Jonathan Todd - <[email protected]>
*
* UPDATED: jt 2005-08-15
*
* COMMENTS: man qsort for more info
*
*****************************************************************************/
#include "qsort.h"
//
// comare point a and b to determine order, sort first by x then by y
//
int QS_compPoints(R_POINT **p1, R_POINT **p2){
R_POINT *a = *p1;
R_POINT *b = *p2;
if(a->x < b->x)
return -1;
else if(a->x > b->x)
return 1;
else{ // x's are the same so compare y's
if(a->y < b->y)
return -1;
else if(a->y > b->y)
return 1;
else{
return 0;
}
}
}