ranges-size.icc
Go to the documentation of this file.00001 /* 00002 * Main authors: 00003 * Guido Tack <tack@gecode.org> 00004 * 00005 * Copyright: 00006 * Guido Tack, 2006 00007 * 00008 * Last modified: 00009 * $Date: 2006-07-12 15:53:12 +0200 (Wed, 12 Jul 2006) $ by $Author: tack $ 00010 * $Revision: 3349 $ 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 template <class I> 00035 class Size { 00036 protected: 00038 I i; 00040 unsigned int _size; 00041 public: 00043 00044 00045 Size(void); 00047 Size(I& i); 00049 void init(I& i); 00051 00053 00054 00055 bool operator()(void); 00057 void operator++(void); 00059 00061 00062 00063 int min(void) const; 00065 int max(void) const; 00067 unsigned int width(void) const; 00069 00071 00072 00073 unsigned int size(void) const; 00075 }; 00076 00077 00078 template <class I> 00079 forceinline 00080 Size<I>::Size(void) 00081 : _size(0) {} 00082 00083 template <class I> 00084 inline void 00085 Size<I>::init(I& i0) { 00086 i.init(i0); 00087 _size = 0; 00088 } 00089 00090 template <class I> 00091 inline 00092 Size<I>::Size(I& i0) : i(i0), _size(0) {} 00093 00094 template <class I> 00095 forceinline void 00096 Size<I>::operator++(void) { 00097 _size += i.width(); 00098 ++i; 00099 } 00100 template <class I> 00101 forceinline bool 00102 Size<I>::operator()(void) { 00103 return i(); 00104 } 00105 00106 template <class I> 00107 forceinline int 00108 Size<I>::min(void) const { 00109 return i.min(); 00110 } 00111 template <class I> 00112 forceinline int 00113 Size<I>::max(void) const { 00114 return i.max(); 00115 } 00116 template <class I> 00117 forceinline unsigned int 00118 Size<I>::width(void) const { 00119 return i.width(); 00120 } 00121 00122 template <class I> 00123 forceinline unsigned int 00124 Size<I>::size(void) const { 00125 return _size; 00126 } 00127 00128 }}} 00129 00130 // STATISTICS: iter-any 00131