From ea47a2973cd4b84017755841a167b86dd0d2ee5d Mon Sep 17 00:00:00 2001 From: mfranz Date: Fri, 28 Apr 2006 15:43:13 +0000 Subject: [PATCH] add method to delete any waypoint (last waypoint if n is out of range) --- simgear/route/route.hxx | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/simgear/route/route.hxx b/simgear/route/route.hxx index 90265b75..1eb57375 100644 --- a/simgear/route/route.hxx +++ b/simgear/route/route.hxx @@ -146,10 +146,16 @@ public: } /** Delete the front waypoint */ - inline void delete_first() { - if ( route.size() ) { - route.erase( route.begin() ); - } + inline void delete_first() { delete_waypoint(0); } + + /** Delete waypoint waypoint with index n (last one if n < 0) */ + void delete_waypoint( int n = 0 ) { + if ( !route.size() ) + return; + if ( n < 0 || n > (int)route.size() - 1 ) + n = route.size() - 1; + + route.erase( route.begin() + n ); } /** -- 2.39.5