main page
modules
namespaces
classes
files
Gecode home
Generated on Mon Jul 27 2020 00:00:00 for Gecode by
doxygen
1.8.18
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
* This file is part of Gecode, the generic constraint
13
* development environment:
14
* http://www.gecode.org
15
*
16
* Permission is hereby granted, free of charge, to any person obtaining
17
* a copy of this software and associated documentation files (the
18
* "Software"), to deal in the Software without restriction, including
19
* without limitation the rights to use, copy, modify, merge, publish,
20
* distribute, sublicense, and/or sell copies of the Software, and to
21
* permit persons to whom the Software is furnished to do so, subject to
22
* the following conditions:
23
*
24
* The above copyright notice and this permission notice shall be
25
* included in all copies or substantial portions of the Software.
26
*
27
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
28
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
29
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
30
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
31
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
32
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
33
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
34
*
35
*/
36
37
namespace
Gecode
{
namespace
Iter {
namespace
Values {
38
44
template
<
class
BS>
45
class
BitSetOffset
{
46
protected
:
48
const
BS&
bs
;
50
int
cur
;
52
int
limit
;
54
void
move
(
void
);
55
public
:
57
58
BitSetOffset
(
const
BS&
bs
);
61
BitSetOffset
(
const
BS&
bs
,
int
n
,
int
m);
63
65
66
bool
operator ()
(
void
)
const
;
69
void
operator ++
(
void
);
71
73
74
int
val
(
void
)
const
;
77
};
78
79
80
template
<
class
BS>
81
forceinline
82
BitSetOffset<BS>::BitSetOffset
(
const
BS& bs0)
83
: bs(bs0), cur(bs.next(bs0.offset())), limit(bs.offset()+bs.
size
()) {
84
}
85
86
template
<
class
BS>
87
forceinline
88
BitSetOffset<BS>::BitSetOffset
(
const
BS& bs0,
int
n
,
int
m)
89
: bs(bs0),
90
cur(bs.next(
n
)),
91
limit(
std
::
min
(bs.offset()+bs.
size
(),m+1)) {
92
}
93
94
template
<
class
BS>
95
forceinline
void
96
BitSetOffset<BS>::operator ++
(
void
) {
97
cur=bs.next(cur+1);
98
}
99
template
<
class
BS>
100
forceinline
bool
101
BitSetOffset<BS>::operator ()
(
void
)
const
{
102
return
cur < limit;
103
}
104
105
template
<
class
BS>
106
forceinline
int
107
BitSetOffset<BS>::val
(
void
)
const
{
108
return
static_cast<
int
>
(cur);
109
}
110
111
}}}
112
113
// STATISTICS: iter-any
Gecode::Iter::Values::BitSetOffset::cur
int cur
Current value.
Definition:
values-bitsetoffset.hpp:50
Gecode::Iter::Values::BitSetOffset::bs
const BS & bs
Bitset.
Definition:
values-bitsetoffset.hpp:48
Gecode::Iter::Ranges::size
unsigned int size(I &i)
Size of all ranges of range iterator i.
Definition:
ranges-operations.hpp:74
Gecode::Iter::Values::BitSetOffset::limit
int limit
Limit value.
Definition:
values-bitsetoffset.hpp:52
Gecode::Iter::Values::BitSetOffset::val
int val(void) const
Return current value.
Definition:
values-bitsetoffset.hpp:107
Gecode
Gecode toplevel namespace
Gecode::Iter::Values::BitSetOffset
Value iterator for values in an offset bitset.
Definition:
values-bitsetoffset.hpp:45
std
Definition:
flatzinc.cpp:52
Gecode::Iter::Values::BitSetOffset::BitSetOffset
BitSetOffset(const BS &bs)
Initialize with bitset bs.
Definition:
values-bitsetoffset.hpp:82
Gecode::Iter::Values::BitSetOffset::operator++
void operator++(void)
Move iterator to next value (if possible)
Definition:
values-bitsetoffset.hpp:96
forceinline
#define forceinline
Definition:
config.hpp:185
Gecode::Iter::Values::BitSetOffset::move
void move(void)
Move to next set bit.
Gecode::min
void min(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Definition:
arithmetic.cpp:67
n
int n
Number of negative literals for node type.
Definition:
bool-expr.cpp:234
Gecode::Iter::Values::BitSetOffset::operator()
bool operator()(void) const
Test whether iterator is still at a value or done.
Definition:
values-bitsetoffset.hpp:101