this repo has no description
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
46 SetTest::str(Gecode::SetRelType srt) {
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
64 SetTest::str(Gecode::SetOpType sot) {
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
76 SetTest::str(const Gecode::IntArgs& x) {
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
84 SetRelTypes::SetRelTypes(void)
85 : i(sizeof(srts)/sizeof(Gecode::SetRelType)-1) {}
86 inline bool
87 SetRelTypes::operator()(void) const {
88 return i>=0;
89 }
90 inline void
91 SetRelTypes::operator++(void) {
92 i--;
93 }
94 inline Gecode::SetRelType
95 SetRelTypes::srt(void) const {
96 return srts[i];
97 }
98
99 inline
100 SetOpTypes::SetOpTypes(void)
101 : i(sizeof(sots)/sizeof(Gecode::SetOpType)-1) {}
102 inline bool
103 SetOpTypes::operator()(void) const {
104 return i>=0;
105 }
106 inline void
107 SetOpTypes::operator++(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