main page
modules
namespaces
classes
files
Gecode home
Generated on Mon Feb 8 2021 00:00:00 for Gecode by
doxygen
1.8.20
gecode
iter
values-map.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
*
6
* Copyright:
7
* Christian Schulte, 2008
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
Values {
35
44
template
<
class
I,
class
M,
bool
strict=false>
45
class
Map
{
46
protected
:
48
I
i
;
50
M
m
;
51
public
:
53
54
Map
(
void
);
57
Map
(I&
i
);
59
Map
(I&
i
,
const
M&
m
);
61
void
init
(I&
i
);
63
void
init
(I&
i
,
const
M&
m
);
65
67
68
bool
operator ()
(
void
)
const
;
71
void
operator ++
(
void
);
73
75
76
int
val
(
void
)
const
;
79
};
80
81
82
template
<
class
I,
class
M,
bool
strict>
83
forceinline
84
Map<I,M,strict>::Map
(
void
) {}
85
86
template
<
class
I,
class
M,
bool
strict>
87
forceinline
88
Map<I,M,strict>::Map
(I& i0) :
i
(i0) {}
89
90
template
<
class
I,
class
M,
bool
strict>
91
forceinline
92
Map<I,M,strict>::Map
(I& i0,
const
M& m0) :
i
(i0), m(m0) {}
93
94
template
<
class
I,
class
M,
bool
strict>
95
forceinline
void
96
Map<I,M,strict>::init
(I& i0) {
97
i
=i0;
98
}
99
100
template
<
class
I,
class
M,
bool
strict>
101
forceinline
void
102
Map<I,M,strict>::init
(I& i0,
const
M& m0) {
103
i
=i0; m=m0;
104
}
105
106
template
<
class
I,
class
M,
bool
strict>
107
forceinline
void
108
Map<I,M,strict>::operator ++
(
void
) {
109
if
(strict) {
110
++
i
;
111
}
else
{
112
int
n
=m.val(
i
.val());
113
do
{
114
++
i
;
115
}
while
(
i
() && (
n
== m.val(
i
.val())));
116
}
117
}
118
template
<
class
I,
class
M,
bool
strict>
119
forceinline
bool
120
Map<I,M,strict>::operator ()
(
void
)
const
{
121
return
i
();
122
}
123
124
template
<
class
I,
class
M,
bool
strict>
125
forceinline
int
126
Map<I,M,strict>::val
(
void
)
const
{
127
return
m.val(
i
.val());
128
}
129
130
}}}
131
132
// STATISTICS: iter-any
Gecode::Iter::Values::Map::operator()
bool operator()(void) const
Test whether iterator is still at a value or done.
Definition:
values-map.hpp:120
Gecode::Iter::Values::Map::operator++
void operator++(void)
Move iterator to next value (if possible)
Definition:
values-map.hpp:108
Gecode::Iter::Values::Map::m
M m
Mapping object.
Definition:
values-map.hpp:50
Gecode::Iter::Values::Map::i
I i
Input iterator.
Definition:
values-map.hpp:48
Gecode::Iter::Values::Map
Value iterator for mapping values of a value iterator.
Definition:
values-map.hpp:45
Gecode::Iter::Values::Map::Map
Map(void)
Default constructor.
Definition:
values-map.hpp:84
Gecode
Gecode toplevel namespace
forceinline
#define forceinline
Definition:
config.hpp:192
n
int n
Number of negative literals for node type.
Definition:
bool-expr.cpp:234
Gecode::Iter::Values::Map::init
void init(I &i)
Initialize with values from i.
Definition:
values-map.hpp:96
Test::Int::Basic::i
Gecode::IntArgs i({1, 2, 3, 4})
Gecode::Iter::Values::Map::val
int val(void) const
Return current value.
Definition:
values-map.hpp:126