00001 /* 00002 * All of the documentation and software included in the 00003 * Alchemy Software is copyrighted by Stanley Kok, Parag 00004 * Singla, Matthew Richardson, Pedro Domingos, Marc 00005 * Sumner, Hoifung Poon, Daniel Lowd, and Jue Wang. 00006 * 00007 * Copyright [2004-09] Stanley Kok, Parag Singla, Matthew 00008 * Richardson, Pedro Domingos, Marc Sumner, Hoifung 00009 * Poon, Daniel Lowd, and Jue Wang. All rights reserved. 00010 * 00011 * Contact: Pedro Domingos, University of Washington 00012 * (pedrod@cs.washington.edu). 00013 * 00014 * Redistribution and use in source and binary forms, with 00015 * or without modification, are permitted provided that 00016 * the following conditions are met: 00017 * 00018 * 1. Redistributions of source code must retain the above 00019 * copyright notice, this list of conditions and the 00020 * following disclaimer. 00021 * 00022 * 2. Redistributions in binary form must reproduce the 00023 * above copyright notice, this list of conditions and the 00024 * following disclaimer in the documentation and/or other 00025 * materials provided with the distribution. 00026 * 00027 * 3. All advertising materials mentioning features or use 00028 * of this software must display the following 00029 * acknowledgment: "This product includes software 00030 * developed by Stanley Kok, Parag Singla, Matthew 00031 * Richardson, Pedro Domingos, Marc Sumner, Hoifung 00032 * Poon, Daniel Lowd, and Jue Wang in the Department of 00033 * Computer Science and Engineering at the University of 00034 * Washington". 00035 * 00036 * 4. Your publications acknowledge the use or 00037 * contribution made by the Software to your research 00038 * using the following citation(s): 00039 * Stanley Kok, Parag Singla, Matthew Richardson and 00040 * Pedro Domingos (2005). "The Alchemy System for 00041 * Statistical Relational AI", Technical Report, 00042 * Department of Computer Science and Engineering, 00043 * University of Washington, Seattle, WA. 00044 * http://alchemy.cs.washington.edu. 00045 * 00046 * 5. Neither the name of the University of Washington nor 00047 * the names of its contributors may be used to endorse or 00048 * promote products derived from this software without 00049 * specific prior written permission. 00050 * 00051 * THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY OF WASHINGTON 00052 * AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 00053 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 00054 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 00055 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY 00056 * OF WASHINGTON OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 00057 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00058 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00059 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00060 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 00061 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00062 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00063 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 00064 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00065 * 00066 */ 00067 #ifndef STRINT_H_JUN_27_2005 00068 #define STRINT_H_JUN_21_2005 00069 00070 #include <cstdlib> 00071 #include <ext/hash_map> 00072 using namespace __gnu_cxx; 00073 00074 00075 struct StrInt 00076 { 00077 public: 00078 StrInt() : str_(NULL), ints_(NULL) {} 00079 00080 StrInt(const char* const & s, const int& i) 00081 { 00082 str_ = new char[strlen(s)+1]; 00083 strcpy(str_,s); 00084 ints_ = new Array<int>; 00085 ints_->append(i); 00086 } 00087 00088 StrInt(const char* const & s) 00089 { 00090 str_ = new char[strlen(s)+1]; 00091 strcpy(str_,s); 00092 ints_ = NULL; 00093 } 00094 00095 ~StrInt() { delete [] str_; delete ints_; } 00096 00097 void addInt(const int& i) 00098 { 00099 ints_->append(i); 00100 } 00101 00102 char* str_; 00103 Array<int>* ints_; 00104 }; 00105 00106 00107 class HashStrInt 00108 { 00109 public: 00110 size_t operator()(const StrInt* const & s) const 00111 { 00112 return hash<char const *>()(s->str_); 00113 } 00114 }; 00115 00116 00117 class EqualStrInt 00118 { 00119 public: 00120 bool operator()(const StrInt* const & s1, const StrInt* const & s2) const 00121 { 00122 return strcmp(s1->str_, s2->str_) == 0; 00123 } 00124 }; 00125 00126 00127 00128 #endif