Generated on Tue Jan 19 2021 06:15:49 for Gecode by doxygen 1.8.13
val-set.hh
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, 2011
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 #ifndef __GECODE_INT_VALSET_HH__
35 #define __GECODE_INT_VALSET_HH__
36 
37 #include <gecode/int.hh>
38 
39 namespace Gecode { namespace Int {
40 
44  class ValSet {
45  protected:
51  int n;
52  public:
54  ValSet(void);
56  void add(Space& home, int v);
58  int size(void) const;
60  bool empty(void) const;
62  int min(void) const;
64  int max(void) const;
66  template<class View>
69  template<class View>
70  bool subset(View x) const;
72  void update(Space& home, ValSet& vs);
74  void flush(void);
76  void dispose(Space& home);
78  class Ranges {
80  const RangeList* c;
81  public:
83 
84  Ranges(const ValSet& vs);
87 
89 
90  bool operator ()(void) const;
93  void operator ++(void);
95 
97 
98  int min(void) const;
101  int max(void) const;
103  unsigned int width(void) const;
105  };
106  };
107 
108 }}
109 
110 #include <gecode/int/val-set.hpp>
111 
112 #endif
113 
114 // STATISTICS: int-other
unsigned int width(void) const
Return width of range (distance between minimum and maximum)
Definition: val-set.hpp:155
RangeList * fst
First element of range list.
Definition: val-set.hh:47
int max(void) const
Return largest value (provided the set is not empty)
Definition: val-set.hpp:96
bool empty(void) const
Test whether set is empty.
Definition: val-set.hpp:86
bool operator()(void) const
Test whether iterator is still at a range or done.
Definition: val-set.hpp:136
RangeList * lst
Last element of range list.
Definition: val-set.hh:49
Computation spaces.
Definition: core.hpp:1701
void dispose(Space &home)
Dispose value set.
Definition: val-set.hpp:126
Iterator over ranges.
Definition: val-set.hh:78
int size(void) const
Return size (number of values)
Definition: val-set.hpp:81
void flush(void)
Flush entries.
Definition: val-set.hpp:121
Ranges(const ValSet &vs)
Initialize.
Definition: val-set.hpp:132
CompareStatus
Comapre two iterators with each other.
void update(Space &home, ValSet &vs)
Update value set during cloning.
Definition: val-set.hpp:101
void operator++(void)
Move iterator to next range (if possible)
Definition: val-set.hpp:141
const int v[7]
Definition: distinct.cpp:259
int n
Number of stored values (integer precision is sufficient)
Definition: val-set.hh:51
Iter::Ranges::CompareStatus compare(View x) const
Compare view x with value set.
Definition: val-set.hpp:161
int min(void) const
Return smallest value (provided the set is not empty)
Definition: val-set.hpp:91
Post propagator for SetVar x
Definition: set.hh:767
Class for storing values of already assigned views.
Definition: val-set.hh:44
int max(void) const
Return largest value of range.
Definition: val-set.hpp:150
int min(void) const
Return smallest value of range.
Definition: val-set.hpp:146
Lists of ranges (intervals)
Definition: range-list.hpp:49
Gecode toplevel namespace
ValSet(void)
Initialize.
Definition: val-set.hpp:41
bool subset(View x) const
Whether all values of x are included in the value set.
Definition: val-set.hpp:171
void add(Space &home, int v)
Add value v to value set.
Definition: val-set.hpp:45