main page
modules
namespaces
classes
files
Gecode home
Generated on Tue Mar 24 2020 14:04:04 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
* This file is part of Gecode, the generic constraint
10
* development environment:
11
* http://www.gecode.org
12
*
13
* Permission is hereby granted, free of charge, to any person obtaining
14
* a copy of this software and associated documentation files (the
15
* "Software"), to deal in the Software without restriction, including
16
* without limitation the rights to use, copy, modify, merge, publish,
17
* distribute, sublicense, and/or sell copies of the Software, and to
18
* permit persons to whom the Software is furnished to do so, subject to
19
* the following conditions:
20
*
21
* The above copyright notice and this permission notice shall be
22
* included in all copies or substantial portions of the Software.
23
*
24
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31
*
32
*/
33
34
namespace
Gecode
{
namespace
Iter {
namespace
Ranges {
35
45
template
<
class
I>
46
class
Size
{
47
protected
:
49
I
i
;
51
unsigned
int
_size
;
52
public
:
54
55
Size
(
void
);
58
Size
(I&
i
);
60
void
init
(I&
i
);
62
64
65
bool
operator ()
(
void
);
68
void
operator ++
(
void
);
70
72
73
int
min
(
void
)
const
;
76
int
max
(
void
)
const
;
78
unsigned
int
width
(
void
)
const
;
80
82
83
unsigned
int
size
(
void
)
const
;
86
};
87
88
89
template
<
class
I>
90
forceinline
91
Size<I>::Size
(
void
)
92
: _size(0) {}
93
94
template
<
class
I>
95
inline
void
96
Size<I>::init
(I& i0) {
97
i
.init(i0);
98
_size = 0;
99
}
100
101
template
<
class
I>
102
inline
103
Size<I>::Size
(I& i0) :
i
(i0), _size(0) {}
104
105
template
<
class
I>
106
forceinline
void
107
Size<I>::operator ++
(
void
) {
108
_size +=
i
.width();
109
++
i
;
110
}
111
template
<
class
I>
112
forceinline
bool
113
Size<I>::operator ()
(
void
) {
114
return
i
();
115
}
116
117
template
<
class
I>
118
forceinline
int
119
Size<I>::min
(
void
)
const
{
120
return
i
.min();
121
}
122
template
<
class
I>
123
forceinline
int
124
Size<I>::max
(
void
)
const
{
125
return
i
.max();
126
}
127
template
<
class
I>
128
forceinline
unsigned
int
129
Size<I>::width
(
void
)
const
{
130
return
i
.width();
131
}
132
133
template
<
class
I>
134
forceinline
unsigned
int
135
Size<I>::size
(
void
)
const
{
136
return
_size;
137
}
138
139
}}}
140
141
// STATISTICS: iter-any
142
Gecode::Iter::Ranges::Size::max
int max(void) const
Return largest value of range.
Definition:
ranges-size.hpp:124
Gecode::Iter::Ranges::Size::init
void init(I &i)
Initialize with ranges from i.
Definition:
ranges-size.hpp:96
Gecode::Iter::Ranges::Size::Size
Size(void)
Default constructor.
Definition:
ranges-size.hpp:91
Gecode::Iter::Ranges::Size
Range iterator with size counting
Definition:
ranges-size.hpp:46
Gecode
Gecode toplevel namespace
Gecode::Iter::Ranges::Size::operator++
void operator++(void)
Move iterator to next range (if possible)
Definition:
ranges-size.hpp:107
Gecode::Iter::Ranges::Size::operator()
bool operator()(void)
Test whether iterator is still at a range or done.
Definition:
ranges-size.hpp:113
Gecode::Iter::Ranges::Size::_size
unsigned int _size
Accumulated size.
Definition:
ranges-size.hpp:51
Gecode::Iter::Ranges::Size::size
unsigned int size(void) const
Return accumulated size.
Definition:
ranges-size.hpp:135
Gecode::Iter::Ranges::Size::width
unsigned int width(void) const
Return width of range (distance between minimum and maximum)
Definition:
ranges-size.hpp:129
Gecode::Iter::Ranges::Size::min
int min(void) const
Return smallest value of range.
Definition:
ranges-size.hpp:119
Gecode::Iter::Ranges::Size::i
I i
Iterator to compute size of.
Definition:
ranges-size.hpp:49
forceinline
#define forceinline
Definition:
config.hpp:185
Test::Int::Basic::i
Gecode::IntArgs i({1, 2, 3, 4})