main page
modules
namespaces
classes
files
Gecode home
Generated on Thu Mar 7 2013 10:21:37 for Gecode by
doxygen
1.8.3.1
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
* 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
Values {
39
46
template
<
class
I,
class
J>
47
class
Inter
{
48
protected
:
50
I
i
;
52
J
j
;
54
void
next
(
void
);
55
public
:
57
58
59
Inter
(
void
);
61
Inter
(I&
i
, J&
j
);
63
void
init
(I&
i
, J&
j
);
65
67
68
69
bool
operator ()
(
void
)
const
;
71
void
operator ++
(
void
);
73
75
76
77
int
val
(
void
)
const
;
79
};
80
81
82
template
<
class
I,
class
J>
83
forceinline
84
Inter<I,J>::Inter
(
void
) {}
85
86
template
<
class
I,
class
J>
87
forceinline
void
88
Inter<I,J>::next
(
void
) {
89
do
{
90
while
(
i
() && j() && (
i
.val() < j.val()))
91
++
i
;
92
while
(
i
() && j() && (j.val() <
i
.val()))
93
++j;
94
}
while
(
i
() && j() && (
i
.val() != j.val()));
95
}
96
97
template
<
class
I,
class
J>
98
inline
void
99
Inter<I,J>::init
(I& i0, J& j0) {
100
i
=i0; j=j0; next();
101
}
102
103
template
<
class
I,
class
J>
104
forceinline
105
Inter<I,J>::Inter
(I& i0, J& j0) :
i
(i0), j(j0) {
106
next
();
107
}
108
109
template
<
class
I,
class
J>
110
forceinline
void
111
Inter<I,J>::operator ++
(
void
) {
112
++
i
; ++j; next();
113
}
114
115
template
<
class
I,
class
J>
116
forceinline
bool
117
Inter<I,J>::operator ()
(
void
)
const
{
118
return
i
() && j();
119
}
120
121
template
<
class
I,
class
J>
122
forceinline
int
123
Inter<I,J>::val
(
void
)
const
{
124
assert(
i
.val() == j.val());
125
return
i
.val();
126
}
127
128
}}}
129
130
// STATISTICS: iter-any