Generated on Thu Jan 16 2025 00:00:00 for Gecode by doxygen 1.14.0
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
37namespace Gecode { namespace Iter { namespace Values {
38
44 template<class BS>
46 protected:
48 const BS& bs;
50 int cur;
52 int limit;
54 void move(void);
55 public:
57
58
59 BitSetOffset(const BS& bs);
61 BitSetOffset(const BS& bs, int n, int m);
63
65
66
67 bool operator ()(void) const;
69 void operator ++(void);
71
73
74
75 int val(void) const;
77 };
78
79
80 template<class BS>
83 : bs(bs0), cur(bs.next(bs0.offset())), limit(bs.offset()+bs.size()) {
84 }
85
86 template<class BS>
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
97 cur=bs.next(cur+1);
98 }
99 template<class BS>
100 forceinline bool
102 return cur < limit;
103 }
104
105 template<class BS>
106 forceinline int
108 return static_cast<int>(cur);
109 }
110
111}}}
112
113// STATISTICS: iter-any
int val(void) const
Return current value.
void operator++(void)
Move iterator to next value (if possible)
void move(void)
Move to next set bit.
BitSetOffset(const BS &bs)
Initialize with bitset bs.
bool operator()(void) const
Test whether iterator is still at a value or done.
int offset(void) const
Integer-precision integer scale view.
Definition view.hpp:642
Value iterators.
Definition iter.hh:45
Range and value iterators.
Definition iter.hh:41
Gecode toplevel namespace
void min(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
#define forceinline
Definition config.hpp:194