Generated on Thu Feb 21 2013 23:11:47 for Gecode by doxygen 1.8.3.1
ranges-size.hpp
Go to the documentation of this file.
1 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2 /*
3  * Main authors:
4  * Guido Tack <tack@gecode.org>
5  *
6  * Copyright:
7  * Guido Tack, 2006
8  *
9  * Last modified:
10  * $Date: 2010-07-29 01:35:33 +1000 (Thu, 29 Jul 2010) $ by $Author: schulte $
11  * $Revision: 11294 $
12  *
13  * This file is part of Gecode, the generic constraint
14  * development environment:
15  * http://www.gecode.org
16  *
17  * Permission is hereby granted, free of charge, to any person obtaining
18  * a copy of this software and associated documentation files (the
19  * "Software"), to deal in the Software without restriction, including
20  * without limitation the rights to use, copy, modify, merge, publish,
21  * distribute, sublicense, and/or sell copies of the Software, and to
22  * permit persons to whom the Software is furnished to do so, subject to
23  * the following conditions:
24  *
25  * The above copyright notice and this permission notice shall be
26  * included in all copies or substantial portions of the Software.
27  *
28  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
29  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
30  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
31  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
32  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
33  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
34  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
35  *
36  */
37 
38 namespace Gecode { namespace Iter { namespace Ranges {
39 
49  template<class I>
50  class Size {
51  protected:
53  I i;
55  unsigned int _size;
56  public:
58 
59 
60  Size(void);
62  Size(I& i);
64  void init(I& i);
66 
68 
69 
70  bool operator ()(void);
72  void operator ++(void);
74 
76 
77 
78  int min(void) const;
80  int max(void) const;
82  unsigned int width(void) const;
84 
86 
87 
88  unsigned int size(void) const;
90  };
91 
92 
93  template<class I>
96  : _size(0) {}
97 
98  template<class I>
99  inline void
100  Size<I>::init(I& i0) {
101  i.init(i0);
102  _size = 0;
103  }
104 
105  template<class I>
106  inline
107  Size<I>::Size(I& i0) : i(i0), _size(0) {}
108 
109  template<class I>
110  forceinline void
112  _size += i.width();
113  ++i;
114  }
115  template<class I>
116  forceinline bool
118  return i();
119  }
120 
121  template<class I>
122  forceinline int
123  Size<I>::min(void) const {
124  return i.min();
125  }
126  template<class I>
127  forceinline int
128  Size<I>::max(void) const {
129  return i.max();
130  }
131  template<class I>
132  forceinline unsigned int
133  Size<I>::width(void) const {
134  return i.width();
135  }
136 
137  template<class I>
138  forceinline unsigned int
139  Size<I>::size(void) const {
140  return _size;
141  }
142 
143 }}}
144 
145 // STATISTICS: iter-any
146