Generated on Tue Feb 11 2025 17:33:26 for Gecode by doxygen 1.12.0
values-array.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, 2007
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
34namespace Gecode { namespace Iter { namespace Values {
35
46 class Array {
47 protected:
49 int* v;
51 unsigned int c;
53 unsigned int n;
54 public:
56
57
58 Array(void);
60 Array(int* v, unsigned int n);
62 Array(int* v, int n);
64 void init(int* v, unsigned int n);
66 void init(int* v, int n);
68
70
71
72 bool operator ()(void) const;
74 void operator ++(void);
76 void reset(void);
78
80
81
82 int val(void) const;
84 };
85
86
88 Array::Array(void) {}
89
91 Array::Array(int* v0, unsigned int n0)
92 : v(v0), c(0U), n(n0) {}
93
95 Array::Array(int* v0, int n0)
96 : v(v0), c(0U), n(static_cast<unsigned int>(n0)) {}
97
98 forceinline void
99 Array::init(int* v0, unsigned int n0) {
100 v=v0; c=0U; n=n0;
101 }
102
103 forceinline void
104 Array::init(int* v0, int n0) {
105 v=v0; c=0U; n=static_cast<unsigned int>(n0);
106 }
107
108 forceinline void
110 c++;
111 }
112 forceinline bool
113 Array::operator ()(void) const {
114 return c<n;
115 }
116 forceinline void
118 c=0;
119 }
120
121 forceinline int
122 Array::val(void) const {
123 return v[c];
124 }
125
126}}}
127
128// STATISTICS: iter-any
129
int n
Number of negative literals for node type.
Value iterator for array of integers
int val(void) const
Return current value.
unsigned int c
Current value.
Array(void)
Default constructor.
void init(int *v, unsigned int n)
Initialize with n ranges from v.
void operator++(void)
Move iterator to next value (if possible)
int * v
Array for values.
unsigned int n
Number of values in array.
void reset(void)
Reset iterator to start from beginning.
bool operator()(void) const
Test whether iterator is still at a value or done.
Gecode toplevel namespace
#define forceinline
Definition config.hpp:187