main page
modules
namespaces
classes
files
Gecode home
Generated on Wed Jan 1 2020 10:37:59 for Gecode by
doxygen
1.8.16
gecode
iter
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
34
namespace
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
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
bool
operator ()
(
void
)
const
;
74
void
operator ++
(
void
);
76
void
reset
(
void
);
78
80
81
int
val
(
void
)
const
;
84
};
85
86
87
forceinline
88
Array::Array
(
void
) {}
89
90
forceinline
91
Array::Array
(
int
* v0,
unsigned
int
n0)
92
:
v
(v0),
c
(0U),
n
(n0) {}
93
94
forceinline
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
109
Array::operator ++
(
void
) {
110
c
++;
111
}
112
forceinline
bool
113
Array::operator ()
(
void
)
const
{
114
return
c
<
n
;
115
}
116
forceinline
void
117
Array::reset
(
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
Gecode::Iter::Values::Array::init
void init(int *v, unsigned int n)
Initialize with n ranges from v.
Definition:
values-array.hpp:99
Gecode::Iter::Values::Array::val
int val(void) const
Return current value.
Definition:
values-array.hpp:122
Gecode::Iter::Values::Array
Value iterator for array of integers
Definition:
values-array.hpp:46
Gecode
Gecode toplevel namespace
Gecode::Iter::Values::Array::reset
void reset(void)
Reset iterator to start from beginning.
Definition:
values-array.hpp:117
Gecode::Iter::Values::Array::operator++
void operator++(void)
Move iterator to next value (if possible)
Definition:
values-array.hpp:109
Gecode::Iter::Values::Array::Array
Array(void)
Default constructor.
Definition:
values-array.hpp:88
Test::Int::Distinct::v
const int v[7]
Definition:
distinct.cpp:259
forceinline
#define forceinline
Definition:
config.hpp:185
Gecode::Iter::Values::Array::c
unsigned int c
Current value.
Definition:
values-array.hpp:51
Gecode::Iter::Values::Array::operator()
bool operator()(void) const
Test whether iterator is still at a value or done.
Definition:
values-array.hpp:113
Test::Float::Arithmetic::c
Gecode::FloatVal c(-8, 8)
Gecode::Iter::Values::Array::v
int * v
Array for values.
Definition:
values-array.hpp:49
n
int n
Number of negative literals for node type.
Definition:
bool-expr.cpp:234
Gecode::Iter::Values::Array::n
unsigned int n
Number of values in array.
Definition:
values-array.hpp:53