main page
modules
namespaces
classes
files
Gecode home
Generated on Tue Jan 28 2020 00:00:00 for Gecode by
doxygen
1.8.17
gecode
iter
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-28 17:35:33 +0200 (Wed, 28 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
Size
(
void
);
62
Size
(I&
i
);
64
void
init
(I&
i
);
66
68
69
bool
operator ()
(
void
);
72
void
operator ++
(
void
);
74
76
77
int
min
(
void
)
const
;
80
int
max
(
void
)
const
;
82
unsigned
int
width
(
void
)
const
;
84
86
87
unsigned
int
size
(
void
)
const
;
90
};
91
92
93
template
<
class
I>
94
forceinline
95
Size<I>::Size
(
void
)
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
111
Size<I>::operator ++
(
void
) {
112
_size +=
i
.width();
113
++
i
;
114
}
115
template
<
class
I>
116
forceinline
bool
117
Size<I>::operator ()
(
void
) {
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
forceinline
#define forceinline
Definition:
config.hpp:173
Gecode::Iter::Ranges::Size::max
int max(void) const
Return largest value of range.
Definition:
ranges-size.hpp:128
Gecode::Iter::Ranges::Size::init
void init(I &i)
Initialize with ranges from i.
Definition:
ranges-size.hpp:100
Test::Int::Basic::i
Gecode::IntArgs i(4, 1, 2, 3, 4)
Gecode::Iter::Ranges::Size::Size
Size(void)
Default constructor.
Definition:
ranges-size.hpp:95
Gecode::Iter::Ranges::Size
Range iterator with size counting
Definition:
ranges-size.hpp:50
Gecode
Gecode toplevel namespace
Gecode::Iter::Ranges::Size::operator++
void operator++(void)
Move iterator to next range (if possible)
Definition:
ranges-size.hpp:111
Gecode::Iter::Ranges::Size::operator()
bool operator()(void)
Test whether iterator is still at a range or done.
Definition:
ranges-size.hpp:117
Gecode::Iter::Ranges::Size::_size
unsigned int _size
Accumulated size.
Definition:
ranges-size.hpp:55
Gecode::Iter::Ranges::Size::size
unsigned int size(void) const
Return accumulated size.
Definition:
ranges-size.hpp:139
Gecode::Iter::Ranges::Size::width
unsigned int width(void) const
Return width of range (distance between minimum and maximum)
Definition:
ranges-size.hpp:133
Gecode::Iter::Ranges::Size::min
int min(void) const
Return smallest value of range.
Definition:
ranges-size.hpp:123
Gecode::Iter::Ranges::Size::i
I i
Iterator to compute size of.
Definition:
ranges-size.hpp:53