main page
modules
namespaces
classes
files
Gecode home
Generated on Tue Oct 22 2013 00:49:06 for Gecode by
doxygen
1.8.4
gecode
iter
values-bitsetoffset.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
* Converted into offset version:
10
* Christopher Mears <chris.mears@monash.edu>
11
*
12
* Last modified:
13
* $Date: 2013-03-07 02:18:29 +0100 (Thu, 07 Mar 2013) $ by $Author: mears $
14
* $Revision: 13455 $
15
*
16
* This file is part of Gecode, the generic constraint
17
* development environment:
18
* http://www.gecode.org
19
*
20
* Permission is hereby granted, free of charge, to any person obtaining
21
* a copy of this software and associated documentation files (the
22
* "Software"), to deal in the Software without restriction, including
23
* without limitation the rights to use, copy, modify, merge, publish,
24
* distribute, sublicense, and/or sell copies of the Software, and to
25
* permit persons to whom the Software is furnished to do so, subject to
26
* the following conditions:
27
*
28
* The above copyright notice and this permission notice shall be
29
* included in all copies or substantial portions of the Software.
30
*
31
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
32
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
33
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
34
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
35
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
36
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
37
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
38
*
39
*/
40
41
namespace
Gecode {
namespace
Iter {
namespace
Values {
42
48
template
<
class
BS>
49
class
BitSetOffset
{
50
protected
:
52
const
BS&
bs
;
54
int
cur
;
56
int
limit
;
58
void
move
(
void
);
59
public
:
61
62
BitSetOffset
(
const
BS&
bs
);
65
BitSetOffset
(
const
BS&
bs
,
int
n
,
int
m);
67
69
70
bool
operator ()
(
void
)
const
;
73
void
operator ++
(
void
);
75
77
78
int
val
(
void
)
const
;
81
};
82
83
84
template
<
class
BS>
85
forceinline
86
BitSetOffset<BS>::BitSetOffset
(
const
BS& bs0)
87
: bs(bs0), cur(bs.next(bs0.offset())), limit(bs.offset()+bs.
size
()) {
88
}
89
90
template
<
class
BS>
91
forceinline
92
BitSetOffset<BS>::BitSetOffset
(
const
BS& bs0,
int
n
,
int
m)
93
: bs(bs0),
94
cur(bs.next(n)),
95
limit(std::
min
(bs.offset()+bs.
size
(),m+1)) {
96
}
97
98
template
<
class
BS>
99
forceinline
void
100
BitSetOffset<BS>::operator ++
(
void
) {
101
cur=bs.next(cur+1);
102
}
103
template
<
class
BS>
104
forceinline
bool
105
BitSetOffset<BS>::operator ()
(
void
)
const
{
106
return
cur < limit;
107
}
108
109
template
<
class
BS>
110
forceinline
int
111
BitSetOffset<BS>::val
(
void
)
const
{
112
return
static_cast<
int
>
(cur);
113
}
114
115
}}}
116
117
// STATISTICS: iter-any