Generated on Thu Jan 16 2025 00:00:00 for Gecode by doxygen 1.14.0
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 * 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 Test { namespace Set {
35
36 inline
37 std::string
38 SetTest::str(int i) {
39 std::stringstream s;
40 s << i;
41 return s.str();
42 }
43
44 inline
45 std::string
47 switch (srt) {
48 case Gecode::SRT_EQ: return "Eq";
49 case Gecode::SRT_LQ: return "Lq";
50 case Gecode::SRT_LE: return "Le";
51 case Gecode::SRT_GQ: return "Gq";
52 case Gecode::SRT_GR: return "Gr";
53 case Gecode::SRT_NQ: return "Nq";
54 case Gecode::SRT_SUB: return "Sub";
55 case Gecode::SRT_SUP: return "Sup";
56 case Gecode::SRT_DISJ: return "Disj";
57 case Gecode::SRT_CMPL: return "Cmpl";
58 }
59 return "";
60 }
61
62 inline
63 std::string
65 switch (sot) {
66 case Gecode::SOT_UNION: return "Union";
67 case Gecode::SOT_DUNION: return "DUnion";
68 case Gecode::SOT_INTER: return "Inter";
69 case Gecode::SOT_MINUS: return "Minus";
70 }
71 return "";
72 }
73
74 inline
75 std::string
77 std::string s = "";
78 for (int i=0; i<x.size()-1; i++)
79 s += str(x[i]) + ",";
80 return "[" + s + str(x[x.size()-1]) + "]";
81 }
82
83 inline
85 : i(sizeof(srts)/sizeof(Gecode::SetRelType)-1) {}
86 inline bool
88 return i>=0;
89 }
90 inline void
92 i--;
93 }
95 SetRelTypes::srt(void) const {
96 return srts[i];
97 }
98
99 inline
101 : i(sizeof(sots)/sizeof(Gecode::SetOpType)-1) {}
102 inline bool
104 return i>=0;
105 }
106 inline void
108 i--;
109 }
110 inline Gecode::SetOpType
111 SetOpTypes::sot(void) const {
112 return sots[i];
113 }
114
115}}
116
117// STATISTICS: test-set
Passing integer arguments.
Definition int.hh:634
SetOpTypes(void)
Initialize iterator.
Definition set.hpp:100
Gecode::SetOpType sot(void) const
Return current operation type.
Definition set.hpp:111
void operator++(void)
Increment to next operation type.
Definition set.hpp:107
bool operator()(void) const
Test whether iterator is done.
Definition set.hpp:103
SetRelTypes(void)
Initialize iterator.
Definition set.hpp:84
void operator++(void)
Increment to next relation type.
Definition set.hpp:91
Gecode::SetRelType srt(void) const
Return current relation type.
Definition set.hpp:95
bool operator()(void) const
Test whether iterator is done.
Definition set.hpp:87
static std::string str(Gecode::SetRelType srt)
Map set relation to string.
Definition set.hpp:46
SetOpType
Common operations for sets.
Definition set.hh:666
SetRelType
Common relation types for sets.
Definition set.hh:649
@ SOT_MINUS
Difference.
Definition set.hh:670
@ SOT_DUNION
Disjoint union.
Definition set.hh:668
@ SOT_UNION
Union.
Definition set.hh:667
@ SOT_INTER
Intersection
Definition set.hh:669
@ SRT_GQ
Greater or equal ( )
Definition set.hh:658
@ SRT_CMPL
Complement.
Definition set.hh:655
@ SRT_GR
Greater ( )
Definition set.hh:659
@ SRT_LQ
Less or equal ( )
Definition set.hh:656
@ SRT_NQ
Disequality ( )
Definition set.hh:651
@ SRT_LE
Less ( )
Definition set.hh:657
@ SRT_EQ
Equality ( )
Definition set.hh:650
@ SRT_SUP
Superset ( )
Definition set.hh:653
@ SRT_DISJ
Disjoint ( )
Definition set.hh:654
@ SRT_SUB
Subset ( )
Definition set.hh:652
Gecode toplevel namespace
Testing finite sets.
Definition set.cpp:42
General test support.
Definition afc.cpp:39