Generated on Sat Oct 20 2018 12:43:45 for Gecode by doxygen 1.8.13
ranges-singleton-append.hpp
Go to the documentation of this file.
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 
36 namespace Gecode { namespace Iter { namespace Ranges {
37 
46  template<class J>
47  class SingletonAppend : public MinMax {
48  protected:
50  J j;
51  public:
53 
54  SingletonAppend(void);
57  SingletonAppend(int i0, int i1, J& j);
59  void init(int i0, int i1, J& j);
61 
63 
64  void operator ++(void);
67  };
68 
69 
70  /*
71  * Binary SingletonAppend
72  *
73  */
74 
75  template<class J>
76  inline 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>
90 
91  template<class J>
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 
void init(int i0, int i1, J &j)
Initialize with singleton (i0, i1) and iterator j.
Base for range iterators with explicit min and max.
#define forceinline
Definition: config.hpp:185
Range iterator for appending a singleton with a range iterator
void finish(void)
Set range such that iteration stops
void operator++(void)
Move iterator to next range (if possible)
int mi
Minimum of current range.
Gecode toplevel namespace
int ma
Maximum of current range.