Generated on Sat Feb 7 2015 02:01:22 for Gecode by doxygen 1.8.9.1
set.hpp
Go to the documentation of this file.
1 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2 /*
3  * Main authors:
4  * Guido Tack <tack@gecode.org>
5  *
6  * Copyright:
7  * Guido Tack, 2005
8  *
9  * Last modified:
10  * $Date: 2011-08-24 16:34:16 +0200 (Wed, 24 Aug 2011) $ by $Author: tack $
11  * $Revision: 12346 $
12  *
13  * This file is part of Gecode, the generic constraint
14  * development environment:
15  * http://www.gecode.org
16  *
17  * Permission is hereby granted, free of charge, to any person obtaining
18  * a copy of this software and associated documentation files (the
19  * "Software"), to deal in the Software without restriction, including
20  * without limitation the rights to use, copy, modify, merge, publish,
21  * distribute, sublicense, and/or sell copies of the Software, and to
22  * permit persons to whom the Software is furnished to do so, subject to
23  * the following conditions:
24  *
25  * The above copyright notice and this permission notice shall be
26  * included in all copies or substantial portions of the Software.
27  *
28  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
29  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
30  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
31  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
32  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
33  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
34  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
35  *
36  */
37 
38 namespace Test { namespace Set {
39 
40  inline
41  std::string
42  SetTest::str(int i) {
43  std::stringstream s;
44  s << i;
45  return s.str();
46  }
47 
48  inline
49  std::string
51  switch (srt) {
52  case Gecode::SRT_EQ: return "Eq";
53  case Gecode::SRT_LQ: return "Lq";
54  case Gecode::SRT_LE: return "Le";
55  case Gecode::SRT_GQ: return "Gq";
56  case Gecode::SRT_GR: return "Gr";
57  case Gecode::SRT_NQ: return "Nq";
58  case Gecode::SRT_SUB: return "Sub";
59  case Gecode::SRT_SUP: return "Sup";
60  case Gecode::SRT_DISJ: return "Disj";
61  case Gecode::SRT_CMPL: return "Cmpl";
62  }
63  return "";
64  }
65 
66  inline
67  std::string
69  switch (sot) {
70  case Gecode::SOT_UNION: return "Union";
71  case Gecode::SOT_DUNION: return "DUnion";
72  case Gecode::SOT_INTER: return "Inter";
73  case Gecode::SOT_MINUS: return "Minus";
74  }
75  return "";
76  }
77 
78  inline
79  std::string
81  std::string s = "";
82  for (int i=0; i<x.size()-1; i++)
83  s += str(x[i]) + ",";
84  return "[" + s + str(x[x.size()-1]) + "]";
85  }
86 
87  inline
89  : i(sizeof(srts)/sizeof(Gecode::SetRelType)-1) {}
90  inline bool
92  return i>=0;
93  }
94  inline void
96  i--;
97  }
98  inline Gecode::SetRelType
99  SetRelTypes::srt(void) const {
100  return srts[i];
101  }
102 
103  inline
105  : i(sizeof(sots)/sizeof(Gecode::SetOpType)-1) {}
106  inline bool
108  return i>=0;
109  }
110  inline void
112  i--;
113  }
114  inline Gecode::SetOpType
115  SetOpTypes::sot(void) const {
116  return sots[i];
117  }
118 
119 }}
120 
121 // STATISTICS: test-set
SetRelType
Common relation types for sets.
Definition: set.hh:644
int size(void) const
Return size of array (number of elements)
Definition: array.hpp:1662
static std::string str(Gecode::SetRelType srt)
Map set relation to string.
Definition: set.hpp:50
SetOpType
Common operations for sets.
Definition: set.hh:661
Superset ( )
Definition: set.hh:648
Complement.
Definition: set.hh:650
Difference.
Definition: set.hh:665
SetRelTypes(void)
Initialize iterator.
Definition: set.hpp:88
Gecode::SetOpType sot(void) const
Return current operation type.
Definition: set.hpp:115
Gecode::IntArgs i(4, 1, 2, 3, 4)
SetOpTypes(void)
Initialize iterator.
Definition: set.hpp:104
bool operator()(void) const
Test whether iterator is done.
Definition: set.hpp:91
Less or equal ( )
Definition: set.hh:651
void operator++(void)
Increment to next operation type.
Definition: set.hpp:111
Subset ( )
Definition: set.hh:647
Intersection
Definition: set.hh:664
Less ( )
Definition: set.hh:652
Passing integer arguments.
Definition: int.hh:607
General test support.
Definition: afc.cpp:43
Union.
Definition: set.hh:662
Greater or equal ( )
Definition: set.hh:653
Node * x
Pointer to corresponding Boolean expression node.
Definition: bool-expr.cpp:253
Disjoint union.
Definition: set.hh:663
bool operator()(void) const
Test whether iterator is done.
Definition: set.hpp:107
Greater ( )
Definition: set.hh:654
Equality ( )
Definition: set.hh:645
Disjoint ( )
Definition: set.hh:649
Gecode::SetRelType srt(void) const
Return current relation type.
Definition: set.hpp:99
Disequality ( )
Definition: set.hh:646
Gecode toplevel namespace
void operator++(void)
Increment to next relation type.
Definition: set.hpp:95