ranges-array.icc
Go to the documentation of this file.00001 /* 00002 * Main authors: 00003 * Christian Schulte <schulte@gecode.org> 00004 * 00005 * Copyright: 00006 * Christian Schulte, 2006 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 00034 class Array { 00035 public: 00037 class Range { 00038 public: 00039 int min; int max; 00040 }; 00041 protected: 00043 Range* r; 00045 int c; 00047 int n; 00048 public: 00050 00051 00052 Array(void); 00054 Array(Range* r, int n); 00056 void init(Range* r, int n); 00058 00060 00061 00062 bool operator()(void) const; 00064 void operator++(void); 00066 void reset(void); 00068 00070 00071 00072 int min(void) const; 00074 int max(void) const; 00076 unsigned int width(void) const; 00078 }; 00079 00080 00081 forceinline 00082 Array::Array(void) {} 00083 00084 forceinline 00085 Array::Array(Range* r0, int n0) 00086 : r(r0), c(0), n(n0) {} 00087 00088 forceinline void 00089 Array::init(Range* r0, int n0) { 00090 r=r0; c=0; n=n0; 00091 } 00092 00093 forceinline void 00094 Array::operator++(void) { 00095 c++; 00096 } 00097 forceinline bool 00098 Array::operator()(void) const { 00099 return c < n; 00100 } 00101 00102 forceinline void 00103 Array::reset(void) { 00104 c=0; 00105 } 00106 00107 forceinline int 00108 Array::min(void) const { 00109 return r[c].min; 00110 } 00111 forceinline int 00112 Array::max(void) const { 00113 return r[c].max; 00114 } 00115 forceinline unsigned int 00116 Array::width(void) const { 00117 return r[c].max-r[c].min+1; 00118 } 00119 00120 }}} 00121 00122 // STATISTICS: iter-any 00123