main page
modules
namespaces
classes
files
Gecode home
Generated on Sun Aug 9 2020 05:34:08 for Gecode by
doxygen
1.8.18
gecode
iter
ranges-negative.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
* 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
#include <algorithm>
35
36
namespace
Gecode
{
namespace
Iter {
namespace
Ranges {
37
46
template
<
class
I,
bool
strict=false>
47
class
Negative
{
48
protected
:
50
I
i
;
51
public
:
53
54
Negative
(
void
);
57
Negative
(I&
i
);
59
void
init
(I&
i
);
61
63
64
bool
operator ()
(
void
)
const
;
67
void
operator ++
(
void
);
69
71
72
int
min
(
void
)
const
;
75
int
max
(
void
)
const
;
77
unsigned
int
width
(
void
)
const
;
79
};
80
81
82
template
<
class
I,
bool
strict>
83
forceinline
84
Negative<I,strict>::Negative
(
void
) {}
85
86
template
<
class
I,
bool
strict>
87
forceinline
void
88
Negative<I,strict>::init
(I& i0) {
89
i
=i0;
90
}
91
92
template
<
class
I,
bool
strict>
93
forceinline
94
Negative<I,strict>::Negative
(I& i0) :
i
(i0) {}
95
96
template
<
class
I,
bool
strict>
97
forceinline
void
98
Negative<I,strict>::operator ++
(
void
) {
99
++
i
;
100
}
101
template
<
class
I,
bool
strict>
102
forceinline
bool
103
Negative<I,strict>::operator ()
(
void
)
const
{
104
if
(strict) {
105
return
i
() && (
i
.min() < 0);
106
}
else
{
107
return
i
() && (
i
.min() <= 0);
108
}
109
}
110
111
template
<
class
I,
bool
strict>
112
forceinline
int
113
Negative<I,strict>::min
(
void
)
const
{
114
return
i
.min();
115
}
116
template
<
class
I,
bool
strict>
117
forceinline
int
118
Negative<I,strict>::max
(
void
)
const
{
119
if
(strict) {
120
return
std::min
(
i
.max(),-1);
121
}
else
{
122
return
std::min
(
i
.max(),0);
123
}
124
}
125
template
<
class
I,
bool
strict>
126
forceinline
unsigned
int
127
Negative<I,strict>::width
(
void
)
const
{
128
return
static_cast<
unsigned
int
>
(
max
()-
min
()+1);
129
}
130
131
}}}
132
133
// STATISTICS: iter-any
Gecode::Iter::Ranges::Negative::i
I i
Input iterator.
Definition:
ranges-negative.hpp:50
Gecode::Iter::Ranges::Negative::width
unsigned int width(void) const
Return width of range (distance between minimum and maximum)
Definition:
ranges-negative.hpp:127
Gecode::max
void max(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Definition:
arithmetic.cpp:49
Gecode::Float::Limits::min
const FloatNum min
Smallest allowed float value.
Definition:
float.hh:846
Gecode
Gecode toplevel namespace
Gecode::Iter::Ranges::Negative::min
int min(void) const
Return smallest value of range.
Definition:
ranges-negative.hpp:113
Gecode::Iter::Ranges::Negative::max
int max(void) const
Return largest value of range.
Definition:
ranges-negative.hpp:118
Gecode::Iter::Ranges::Negative
Range iterator for negative part of a range iterator.
Definition:
ranges-negative.hpp:47
forceinline
#define forceinline
Definition:
config.hpp:185
Gecode::min
void min(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
Definition:
arithmetic.cpp:67
Gecode::Iter::Ranges::Negative::Negative
Negative(void)
Default constructor.
Definition:
ranges-negative.hpp:84
Test::Int::Basic::i
Gecode::IntArgs i({1, 2, 3, 4})
Gecode::Iter::Ranges::Negative::operator()
bool operator()(void) const
Test whether iterator is still at a range or done.
Definition:
ranges-negative.hpp:103
Gecode::Iter::Ranges::Negative::init
void init(I &i)
Initialize with ranges from i.
Definition:
ranges-negative.hpp:88
Gecode::Iter::Ranges::Negative::operator++
void operator++(void)
Move iterator to next range (if possible)
Definition:
ranges-negative.hpp:98