From 79508696623a2c3c0418a6f86328c12c8f5dea80 Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Sat, 23 May 2015 09:51:02 +0200 Subject: [PATCH] pn,pv aka FK01,2 have no effect when j would exceed the allowed range --- pub/trivia/vector_ops.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pub/trivia/vector_ops.cpp b/pub/trivia/vector_ops.cpp index af1dc865..b03c308d 100644 --- a/pub/trivia/vector_ops.cpp +++ b/pub/trivia/vector_ops.cpp @@ -89,15 +89,16 @@ vector<size_t> triv::sorted_indices(vector<double> const& V) } -//! Increments all members, or deletes them if they exceed the range 0...siz. +//! Increments all members, provided they remain in the range 0...siz. void triv::increment_indices( vector<int>& v, int incr, int siz ) { vector<int> ret; for( int k: v ){ int kout = k+incr; - if ( 0<=kout && kout<siz ) - ret.push_back( kout ); + if ( kout<0 || kout>=siz ) + return; // leave v unchanged + ret.push_back( kout ); } v = ret; } -- GitLab