From b03d66723210ae436b08f433848e1ae72361e916 Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Tue, 3 May 2005 18:16:40 +0000 Subject: add sort add sort --- src/Hill.H | 4 +++- src/Hill.cxx | 21 ++++++++++++++++++++- src/Panorama.cxx | 4 +++- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/Hill.H b/src/Hill.H index 71135d0..b850425 100644 --- a/src/Hill.H +++ b/src/Hill.H @@ -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 -- cgit v1.2.3