this repo has no description
at develop 2.9 kB view raw
1/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */ 2/* 3 * Main authors: 4 * Christian Schulte <schulte@gecode.org> 5 * Guido Tack <tack@gecode.org> 6 * 7 * Copyright: 8 * Christian Schulte, 2004 9 * Guido Tack, 2006 10 * 11 * This file is part of Gecode, the generic constraint 12 * development environment: 13 * http://www.gecode.org 14 * 15 * Permission is hereby granted, free of charge, to any person obtaining 16 * a copy of this software and associated documentation files (the 17 * "Software"), to deal in the Software without restriction, including 18 * without limitation the rights to use, copy, modify, merge, publish, 19 * distribute, sublicense, and/or sell copies of the Software, and to 20 * permit persons to whom the Software is furnished to do so, subject to 21 * the following conditions: 22 * 23 * The above copyright notice and this permission notice shall be 24 * included in all copies or substantial portions of the Software. 25 * 26 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 27 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 28 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 29 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 30 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 31 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 32 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 33 * 34 */ 35 36namespace Gecode { namespace Iter { namespace Ranges { 37 38 /** 39 * \brief %Range iterator for appending a singleton with a range iterator 40 * 41 * The singleton is not allowed to be adjacent to the iterator. 42 * 43 * \ingroup FuncIterRanges 44 */ 45 46 template<class J> 47 class SingletonAppend : public MinMax { 48 protected: 49 /// Iterator to be appended 50 J j; 51 public: 52 /// \name Constructors and initialization 53 //@{ 54 /// Default constructor 55 SingletonAppend(void); 56 /// Initialize with singleton (\a i0, \a i1) and iterator \a j 57 SingletonAppend(int i0, int i1, J& j); 58 /// Initialize with singleton (\a i0, \a i1) and iterator \a j 59 void init(int i0, int i1, J& j); 60 //@} 61 62 /// \name Iteration control 63 //@{ 64 /// Move iterator to next range (if possible) 65 void operator ++(void); 66 //@} 67 }; 68 69 70 /* 71 * Binary SingletonAppend 72 * 73 */ 74 75 template<class J> 76 inline void 77 SingletonAppend<J>::operator ++(void) { 78 if (j()) { 79 mi = j.min(); ma = j.max(); 80 ++j; 81 } else { 82 finish(); 83 } 84 } 85 86 87 template<class J> 88 forceinline 89 SingletonAppend<J>::SingletonAppend(void) {} 90 91 template<class J> 92 forceinline 93 SingletonAppend<J>::SingletonAppend(int i0, int i1, J& j0) 94 : j(j0) { 95 mi=i0; ma=i1; 96 } 97 98 template<class J> 99 forceinline void 100 SingletonAppend<J>::init(int i0, int i1, J& j0) { 101 mi=i0; ma=i1; j=j0; 102 } 103 104}}} 105 106// STATISTICS: iter-any 107