values-ranges.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-04-11 15:58:37 +0200 (Tue, 11 Apr 2006) $ by $Author: tack $ 00010 * $Revision: 3188 $ 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 Values { 00023 00034 template <class I> 00035 class ToRanges : public Ranges::MinMax { 00036 protected: 00038 I i; 00039 public: 00041 00042 00043 ToRanges(void); 00045 ToRanges(I& i); 00047 void init(I& i); 00049 00051 00052 00053 void operator++(void); 00055 }; 00056 00057 template <class I> 00058 forceinline 00059 ToRanges<I>::ToRanges(void) {} 00060 00061 template <class I> 00062 forceinline void 00063 ToRanges<I>::operator++(void) { 00064 if (!i()) { 00065 finish(); return; 00066 } 00067 mi = i.val(); ma = i.val(); 00068 ++i; 00069 while (i() && (ma+1 >= i.val())) { 00070 ma = i.val(); ++i; 00071 } 00072 } 00073 00074 template <class I> 00075 forceinline 00076 ToRanges<I>::ToRanges(I& i0) 00077 : i(i0) { 00078 operator++(); 00079 } 00080 00081 template <class I> 00082 forceinline void 00083 ToRanges<I>::init(I& i0) { 00084 i = i0; 00085 operator++(); 00086 } 00087 00088 }}} 00089 00090 // STATISTICS: iter-any 00091