main page
modules
namespaces
classes
files
Gecode home
Generated on Sun Aug 9 2020 05:34:08 for Gecode by
doxygen
1.8.18
gecode
iter
values-inter.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
42
template
<
class
I,
class
J>
43
class
Inter
{
44
protected
:
46
I
i
;
48
J
j
;
50
void
next
(
void
);
51
public
:
53
54
Inter
(
void
);
57
Inter
(I&
i
, J&
j
);
59
void
init
(I&
i
, J&
j
);
61
63
64
bool
operator ()
(
void
)
const
;
67
void
operator ++
(
void
);
69
71
72
int
val
(
void
)
const
;
75
};
76
77
78
template
<
class
I,
class
J>
79
forceinline
80
Inter<I,J>::Inter
(
void
) {}
81
82
template
<
class
I,
class
J>
83
forceinline
void
84
Inter<I,J>::next
(
void
) {
85
do
{
86
while
(
i
() && j() && (
i
.val() < j.val()))
87
++
i
;
88
while
(
i
() && j() && (j.val() <
i
.val()))
89
++j;
90
}
while
(
i
() && j() && (
i
.val() != j.val()));
91
}
92
93
template
<
class
I,
class
J>
94
inline
void
95
Inter<I,J>::init
(I& i0, J& j0) {
96
i
=i0; j=j0; next();
97
}
98
99
template
<
class
I,
class
J>
100
forceinline
101
Inter<I,J>::Inter
(I& i0, J& j0) :
i
(i0), j(j0) {
102
next
();
103
}
104
105
template
<
class
I,
class
J>
106
forceinline
void
107
Inter<I,J>::operator ++
(
void
) {
108
++
i
; ++j; next();
109
}
110
111
template
<
class
I,
class
J>
112
forceinline
bool
113
Inter<I,J>::operator ()
(
void
)
const
{
114
return
i
() && j();
115
}
116
117
template
<
class
I,
class
J>
118
forceinline
int
119
Inter<I,J>::val
(
void
)
const
{
120
assert(
i
.val() == j.val());
121
return
i
.val();
122
}
123
124
}}}
125
126
// STATISTICS: iter-any
Gecode::Iter::Values::Inter::operator++
void operator++(void)
Move iterator to next value (if possible)
Definition:
values-inter.hpp:107
Gecode::Iter::Values::Inter::next
void next(void)
Find next element from intersection.
Definition:
values-inter.hpp:84
Gecode::Iter::Values::Inter::i
I i
First iterator.
Definition:
values-inter.hpp:46
Gecode::Iter::Values::Inter::init
void init(I &i, J &j)
Initialize with values from i and j.
Definition:
values-inter.hpp:95
Gecode
Gecode toplevel namespace
Gecode::Iter::Values::Inter::j
J j
Second iterator.
Definition:
values-inter.hpp:48
Gecode::Iter::Values::Inter
Value iterator for the intersection of two value iterators.
Definition:
values-inter.hpp:43
Gecode::Iter::Values::Inter::Inter
Inter(void)
Default constructor.
Definition:
values-inter.hpp:80
Gecode::Iter::Values::Inter::val
int val(void) const
Return current value.
Definition:
values-inter.hpp:119
forceinline
#define forceinline
Definition:
config.hpp:185
Test::Int::Basic::i
Gecode::IntArgs i({1, 2, 3, 4})
Gecode::Iter::Values::Inter::operator()
bool operator()(void) const
Test whether iterator is still at a value or done.
Definition:
values-inter.hpp:113