summaryrefslogtreecommitdiff
path: root/src/Hill.cxx
diff options
context:
space:
mode:
authorJohannes Hofmann <johannes.hofmann@gmx.de>2005-06-22 18:40:35 +0000
committerJohannes Hofmann <johannes.hofmann@gmx.de>2005-06-22 18:40:35 +0000
commitf2a189d28629dcd052790efbabdbc24847cb886c (patch)
treef765b2cc0c864c9f942a1d55ada3107cb7e332c3 /src/Hill.cxx
parent1934ed1b8509760359a8fc3ff47e7758f66a05a6 (diff)
sort menuitems by name
sort menuitems by name
Diffstat (limited to 'src/Hill.cxx')
-rw-r--r--src/Hill.cxx33
1 files changed, 32 insertions, 1 deletions
diff --git a/src/Hill.cxx b/src/Hill.cxx
index 08d834f..4057524 100644
--- a/src/Hill.cxx
+++ b/src/Hill.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Hill.cxx,v 1.16 2005/06/22 19:47:20 hofmann Exp $"
+// "$Id: Hill.cxx,v 1.17 2005/06/22 20:40:35 hofmann Exp $"
//
// Hill routines.
//
@@ -67,6 +67,16 @@ Hills::Hills() {
deg2rad = pi_d / 180.0;
}
+Hills::Hills(const Hills *h) {
+ num = h->num;
+ cap = h->cap;
+ m = (Hill **) malloc(cap * sizeof(Hill *));
+ memcpy(m, h->m, cap * sizeof(Hill *));
+
+ pi_d = asin(1.0) * 2.0;
+ deg2rad = pi_d / 180.0;
+}
+
int
Hills::load(const char *file) {
FILE *fp;
@@ -184,6 +194,18 @@ comp_mountains_phi(const void *n1, const void *n2) {
}
}
+static int
+comp_mountains_name(const void *n1, const void *n2) {
+ Hill *m1 = *(Hill **)n1;
+ Hill *m2 = *(Hill **)n2;
+
+ if (m1 && m2) {
+ return strcmp(m1->name, m2->name);
+ } else {
+ return 0;
+ }
+}
+
void
Hills::sort() {
if (!m) {
@@ -203,6 +225,15 @@ Hills::sort_phi() {
}
void
+Hills::sort_name() {
+ if (!m) {
+ return;
+ }
+
+ qsort(m, num, sizeof(Hill *), comp_mountains_name);
+}
+
+void
Hills::clear() {
if (m) {
free(m);