set.hpp
Go to the documentation of this file.00001 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */ 00002 /* 00003 * Main authors: 00004 * Guido Tack <tack@gecode.org> 00005 * 00006 * Copyright: 00007 * Guido Tack, 2005 00008 * 00009 * This file is part of Gecode, the generic constraint 00010 * development environment: 00011 * http://www.gecode.org 00012 * 00013 * Permission is hereby granted, free of charge, to any person obtaining 00014 * a copy of this software and associated documentation files (the 00015 * "Software"), to deal in the Software without restriction, including 00016 * without limitation the rights to use, copy, modify, merge, publish, 00017 * distribute, sublicense, and/or sell copies of the Software, and to 00018 * permit persons to whom the Software is furnished to do so, subject to 00019 * the following conditions: 00020 * 00021 * The above copyright notice and this permission notice shall be 00022 * included in all copies or substantial portions of the Software. 00023 * 00024 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 00025 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00026 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 00027 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 00028 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 00029 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 00030 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 00031 * 00032 */ 00033 00034 namespace Test { namespace Set { 00035 00036 inline 00037 std::string 00038 SetTest::str(int i) { 00039 std::stringstream s; 00040 s << i; 00041 return s.str(); 00042 } 00043 00044 inline 00045 std::string 00046 SetTest::str(Gecode::SetRelType srt) { 00047 switch (srt) { 00048 case Gecode::SRT_EQ: return "Eq"; 00049 case Gecode::SRT_LQ: return "Lq"; 00050 case Gecode::SRT_LE: return "Le"; 00051 case Gecode::SRT_GQ: return "Gq"; 00052 case Gecode::SRT_GR: return "Gr"; 00053 case Gecode::SRT_NQ: return "Nq"; 00054 case Gecode::SRT_SUB: return "Sub"; 00055 case Gecode::SRT_SUP: return "Sup"; 00056 case Gecode::SRT_DISJ: return "Disj"; 00057 case Gecode::SRT_CMPL: return "Cmpl"; 00058 } 00059 return ""; 00060 } 00061 00062 inline 00063 std::string 00064 SetTest::str(Gecode::SetOpType sot) { 00065 switch (sot) { 00066 case Gecode::SOT_UNION: return "Union"; 00067 case Gecode::SOT_DUNION: return "DUnion"; 00068 case Gecode::SOT_INTER: return "Inter"; 00069 case Gecode::SOT_MINUS: return "Minus"; 00070 } 00071 return ""; 00072 } 00073 00074 inline 00075 std::string 00076 SetTest::str(const Gecode::IntArgs& x) { 00077 std::string s = ""; 00078 for (int i=0; i<x.size()-1; i++) 00079 s += str(x[i]) + ","; 00080 return "[" + s + str(x[x.size()-1]) + "]"; 00081 } 00082 00083 inline 00084 SetRelTypes::SetRelTypes(void) 00085 : i(sizeof(srts)/sizeof(Gecode::SetRelType)-1) {} 00086 inline bool 00087 SetRelTypes::operator()(void) const { 00088 return i>=0; 00089 } 00090 inline void 00091 SetRelTypes::operator++(void) { 00092 i--; 00093 } 00094 inline Gecode::SetRelType 00095 SetRelTypes::srt(void) const { 00096 return srts[i]; 00097 } 00098 00099 inline 00100 SetOpTypes::SetOpTypes(void) 00101 : i(sizeof(sots)/sizeof(Gecode::SetOpType)-1) {} 00102 inline bool 00103 SetOpTypes::operator()(void) const { 00104 return i>=0; 00105 } 00106 inline void 00107 SetOpTypes::operator++(void) { 00108 i--; 00109 } 00110 inline Gecode::SetOpType 00111 SetOpTypes::sot(void) const { 00112 return sots[i]; 00113 } 00114 00115 }} 00116 00117 // STATISTICS: test-set