diff options
author | Johannes Hofmann <johannes.hofmann@gmx.de> | 2005-05-03 18:16:40 +0000 |
---|---|---|
committer | Johannes Hofmann <johannes.hofmann@gmx.de> | 2005-05-03 18:16:40 +0000 |
commit | b03d66723210ae436b08f433848e1ae72361e916 (patch) | |
tree | 67a678969357e9876910b05a414f2a2f34cf2e97 /src | |
parent | 16c6d891d2236a30bb742c5bd4d0ac4e56bb901e (diff) |
add sort
add sort
Diffstat (limited to 'src')
-rw-r--r-- | src/Hill.H | 4 | ||||
-rw-r--r-- | src/Hill.cxx | 21 | ||||
-rw-r--r-- | src/Panorama.cxx | 4 |
3 files changed, 26 insertions, 3 deletions
@@ -1,5 +1,5 @@ // -// "$Id: Hill.H,v 1.7 2005/05/03 20:04:14 hofmann Exp $" +// "$Id: Hill.H,v 1.8 2005/05/03 20:16:40 hofmann Exp $" // // X11 header file for the Fast Light Tool Kit (FLTK). // @@ -71,6 +71,8 @@ class Mountains { void add(Mountain *m); + void sort(); + void clear(); void clobber(); diff --git a/src/Hill.cxx b/src/Hill.cxx index 8d9c4f8..b0c738f 100644 --- a/src/Hill.cxx +++ b/src/Hill.cxx @@ -1,5 +1,5 @@ // -// "$Id: Hill.cxx,v 1.5 2005/05/03 20:04:14 hofmann Exp $" +// "$Id: Hill.cxx,v 1.6 2005/05/03 20:16:40 hofmann Exp $" // // PSEditWidget routines. // @@ -120,6 +120,25 @@ Mountains::add(Mountain *m1) { m[num++] = m1; } + +static int +comp_mountains(const void *m1, const void *m2) { + if (m1 && m2) { + return ((Mountain *)m1)->alph > ((Mountain *)m2)->alph; + } else { + return 0; + } +} + +void +Mountains::sort() { + if (!m) { + return; + } + + qsort(m, num, sizeof(class Mountain *), comp_mountains); +} + void Mountains::clear() { if (m) { diff --git a/src/Panorama.cxx b/src/Panorama.cxx index 670f96e..095db14 100644 --- a/src/Panorama.cxx +++ b/src/Panorama.cxx @@ -1,5 +1,5 @@ // -// "$Id: Panorama.cxx,v 1.21 2005/05/03 20:04:14 hofmann Exp $" +// "$Id: Panorama.cxx,v 1.22 2005/05/03 20:16:40 hofmann Exp $" // // PSEditWidget routines. // @@ -435,6 +435,8 @@ Panorama::update_visible_mountains() { } } } + + visible_mountains->sort(); } double |