ranges-minmax.icc
Go to the documentation of this file.00001 /* 00002 * Main authors: 00003 * Christian Schulte <schulte@gecode.org> 00004 * 00005 * Copyright: 00006 * Christian Schulte, 2004 00007 * 00008 * Last modified: 00009 * $Date: 2006-08-04 16:05:50 +0200 (Fri, 04 Aug 2006) $ by $Author: schulte $ 00010 * $Revision: 3515 $ 00011 * 00012 * This file is part of Gecode, the generic constraint 00013 * development environment: 00014 * http://www.gecode.org 00015 * 00016 * See the file "LICENSE" for information on usage and 00017 * redistribution of this file, and for a 00018 * DISCLAIMER OF ALL WARRANTIES. 00019 * 00020 */ 00021 00022 namespace Gecode { namespace Iter { namespace Ranges { 00023 00036 class MinMax { 00037 protected: 00039 int mi; 00041 int ma; 00043 void finish(void); 00044 public: 00046 00047 00048 MinMax(void); 00050 MinMax(int min, int max); 00052 00054 00055 00056 bool operator()(void) const; 00058 00060 00061 00062 int min(void) const; 00064 int max(void) const; 00066 unsigned int width(void) const; 00068 }; 00069 00070 forceinline void 00071 MinMax::finish(void) { 00072 mi = 1; ma = 0; 00073 } 00074 00075 forceinline 00076 MinMax::MinMax(void) {} 00077 00078 forceinline 00079 MinMax::MinMax(int min, int max) 00080 : mi(min), ma(max) {} 00081 00082 forceinline bool 00083 MinMax::operator()(void) const { 00084 return mi <= ma; 00085 } 00086 00087 forceinline int 00088 MinMax::min(void) const { 00089 return mi; 00090 } 00091 forceinline int 00092 MinMax::max(void) const { 00093 return ma; 00094 } 00095 forceinline unsigned int 00096 MinMax::width(void) const { 00097 return ma-mi+1; 00098 } 00099 00100 }}} 00101 00102 // STATISTICS: iter-any 00103