Simple Application Framework
1
|
00001 /* 00002 This file is part of Simple Application Framework (Saf) library. 00003 Copyright (C) 2010 - 2012 Ondrej Danek <ondrej.danek@gmail.com> 00004 00005 This library is free software: you can redistribute it and/or modify 00006 it under the terms of the GNU General Public License as published 00007 by the Free Software Foundation, either version 3 of the License, or 00008 (at your option) any later version. 00009 00010 Saf is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 GNU General Public License for more details. 00014 00015 You should have received a copy of the GNU General Public License 00016 along with Simple Application Framework library. If not, 00017 see <http://www.gnu.org/licenses/>. 00018 */ 00019 00028 #ifndef SAF_ALGO_PREDICATE_H 00029 #define SAF_ALGO_PREDICATE_H 00030 00031 #include "Function.h" 00032 00033 namespace Saf 00034 { 00035 namespace Algo 00036 { 00038 namespace Predicate 00039 { 00041 // Unary predicates 00043 00044 00046 // Binary predicates 00048 00050 template <class T> 00051 struct Equal 00052 : public BinaryFunction<T,T,bool> 00053 { 00054 bool operator()(const T& v1, const T& v2) const 00055 { 00056 return (v1 == v2); 00057 } 00058 }; 00059 00061 template <class T> 00062 struct NotEqual 00063 : public BinaryFunction<T,T,bool> 00064 { 00065 bool operator()(const T& v1, const T& v2) const 00066 { 00067 return (v1 != v2); 00068 } 00069 }; 00070 00072 template <class T> 00073 struct Less 00074 : public BinaryFunction<T,T,bool> 00075 { 00076 bool operator()(const T& v1, const T& v2) const 00077 { 00078 return (v1 < v2); 00079 } 00080 }; 00081 00083 template <class T> 00084 struct LessOrEqual 00085 : public BinaryFunction<T,T,bool> 00086 { 00087 bool operator()(const T& v1, const T& v2) const 00088 { 00089 return (v1 <= v2); 00090 } 00091 }; 00092 00094 template <class T> 00095 struct Greater 00096 : public BinaryFunction<T,T,bool> 00097 { 00098 bool operator()(const T& v1, const T& v2) const 00099 { 00100 return (v1 > v2); 00101 } 00102 }; 00103 00105 template <class T> 00106 struct GreaterOrEqual 00107 : public BinaryFunction<T,T,bool> 00108 { 00109 bool operator()(const T& v1, const T& v2) const 00110 { 00111 return (v1 >= v2); 00112 } 00113 }; 00114 } 00115 } 00116 } 00117 00118 #endif