1 |
+ |
#ifndef lint |
2 |
+ |
static const char RCSid[] = "$Id$"; |
3 |
+ |
#endif |
4 |
|
#include <stdio.h> |
5 |
|
#include <stdlib.h> |
6 |
|
#include <string.h> |
85 |
|
fl->ipos = 0; |
86 |
|
} |
87 |
|
|
88 |
< |
static int comp_sort(const g3Float* v1,const g3Float* v2) |
89 |
< |
{ |
90 |
< |
if (v1< v2) |
88 |
> |
static int comp_sort(const void* __v1,const void* __v2) { |
89 |
> |
const g3Float *v1 = __v1; |
90 |
> |
const g3Float* v2 = __v2; |
91 |
> |
if (v1[0] < v2[0]) |
92 |
|
return -1; |
93 |
< |
if (v1 > v2) |
93 |
> |
if (v1[0] > v2[0]) |
94 |
|
return 1; |
95 |
|
return 0; |
96 |
|
} |
97 |
|
|
98 |
< |
int g3fl_sort(g3FList* fl,int cnum) |
98 |
> |
int g3fl_sort(g3FList* fl,int cnum) |
99 |
|
{ |
100 |
< |
if (cnum >= fl->comp_size) |
101 |
< |
return 0; |
102 |
< |
qsort((fl->list + cnum),fl->size,fl->comp_size*sizeof(g3Float),(int (*)(const void* v1,const void* v2)) comp_sort); |
103 |
< |
return 1; |
100 |
> |
g3Float* n; |
101 |
> |
if (cnum >= fl->comp_size) |
102 |
> |
return 0; |
103 |
> |
if (cnum > 0) /* brute force method to avoid using inline functions */ |
104 |
> |
for(n=g3fl_begin(fl);n != NULL;n=g3fl_next(fl)) |
105 |
> |
gb_swap(n[0], n[cnum]); |
106 |
> |
qsort(fl->list, fl->size, fl->comp_size*sizeof(g3Float), comp_sort); |
107 |
> |
if (cnum > 0) /* brute force method to avoid using inline functions */ |
108 |
> |
for(n=g3fl_begin(fl);n != NULL;n=g3fl_next(fl)) |
109 |
> |
gb_swap(n[0], n[cnum]); |
110 |
> |
return 1; |
111 |
|
} |
112 |
|
|
113 |
+ |
|
114 |
|
g3Float* g3fl_next(g3FList* fl) |
115 |
|
{ |
116 |
|
if (fl->ipos >= fl->size) |
159 |
|
for(i=0;i<10;i++) { |
160 |
|
n = g3fl_append_new(fl); |
161 |
|
n[0] = i; |
162 |
< |
n[1] = i; |
162 |
> |
n[1] = 10-i; |
163 |
|
} |
164 |
+ |
g3fl_sort(fl, 1); |
165 |
|
for(n=g3fl_begin(fl);n != NULL;n=g3fl_next(fl)) |
166 |
|
printf("%f %f\n",n[0],n[1]); |
167 |
|
g3fl_free(fl); |