| 1 | /********************************************************************** |
| 2 | IndexValue.h: class to work with structs containing an index and a value |
| 3 | Author(s): [email protected] |
| 4 | Copyright (C) 2016-2020 European Union (Joint Research Centre) |
| 5 | |
| 6 | This file is part of jiplib. |
| 7 | |
| 8 | jiplib is free software: you can redistribute it and/or modify |
| 9 | it under the terms of the GNU General Public License as published by |
| 10 | the Free Software Foundation, either version 3 of the License, or |
| 11 | (at your option) any later version. |
| 12 | |
| 13 | jiplib is distributed in the hope that it will be useful, |
| 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | GNU General Public License for more details. |
| 17 | |
| 18 | You should have received a copy of the GNU General Public License |
| 19 | along with jiplib. If not, see <https://www.gnu.org/licenses/>. |
| 20 | ***********************************************************************/ |
| 21 | #ifndef _INDEXVALUE_H_ |
| 22 | #define _INDEXVALUE_H_ |
| 23 | |
| 24 | struct IndexValue{ |
| 25 | int position; |
| 26 | double value; |
| 27 | }; |
| 28 | class Compare_IndexValue{ |
| 29 | public: |
| 30 | int operator() (const IndexValue& pv1, const IndexValue& pv2) const{ |
| 31 | return pv1.value>pv2.value;//for decreasing order |
| 32 | } |
| 33 | }; |
| 34 | class Decrease_IndexValue{ |
| 35 | public: |
| 36 | int operator() (const IndexValue& pv1, const IndexValue& pv2) const{ |
| 37 | return pv1.value>pv2.value;//for decreasing order |
| 38 | } |
| 39 | }; |
| 40 | class Increase_IndexValue{ |
| 41 | public: |
| 42 | int operator() (const IndexValue& pv1, const IndexValue& pv2) const{ |
| 43 | return pv1.value<pv2.value;//for increasing order |
| 44 | } |
| 45 | }; |
| 46 | #endif /* _INDEXVALUE_H_ */ |