<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <title>CVC3: cvc_util.h Source File</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <link href="doxygen.css" rel="stylesheet" type="text/css"/> </head> <body> <!-- Generated by Doxygen 1.7.4 --> <div id="top"> <div id="titlearea"> <table cellspacing="0" cellpadding="0"> <tbody> <tr style="height: 56px;"> <td style="padding-left: 0.5em;"> <div id="projectname">CVC3 <span id="projectnumber">2.4.1</span></div> </td> </tr> </tbody> </table> </div> <div id="navrow1" class="tabs"> <ul class="tablist"> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="pages.html"><span>Related Pages</span></a></li> <li><a href="modules.html"><span>Modules</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li><a href="annotated.html"><span>Classes</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> </ul> </div> <div id="navrow2" class="tabs2"> <ul class="tablist"> <li><a href="files.html"><span>File List</span></a></li> <li><a href="globals.html"><span>File Members</span></a></li> </ul> </div> <div class="header"> <div class="headertitle"> <div class="title">cvc_util.h</div> </div> </div> <div class="contents"> <a href="cvc__util_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*****************************************************************************/</span><span class="comment"></span> <a name="l00002"></a>00002 <span class="comment">/*!</span> <a name="l00003"></a>00003 <span class="comment"> *\file cvc_util.h</span> <a name="l00004"></a>00004 <span class="comment"> *\brief basic helper utilities</span> <a name="l00005"></a>00005 <span class="comment"> *</span> <a name="l00006"></a>00006 <span class="comment"> * Author: Clark Barrett</span> <a name="l00007"></a>00007 <span class="comment"> *</span> <a name="l00008"></a>00008 <span class="comment"> * Created: Thu Dec 1 16:35:52 2005</span> <a name="l00009"></a>00009 <span class="comment"> *</span> <a name="l00010"></a>00010 <span class="comment"> * <hr></span> <a name="l00011"></a>00011 <span class="comment"> *</span> <a name="l00012"></a>00012 <span class="comment"> * License to use, copy, modify, sell and/or distribute this software</span> <a name="l00013"></a>00013 <span class="comment"> * and its documentation for any purpose is hereby granted without</span> <a name="l00014"></a>00014 <span class="comment"> * royalty, subject to the terms and conditions defined in the \ref</span> <a name="l00015"></a>00015 <span class="comment"> * LICENSE file provided with this distribution.</span> <a name="l00016"></a>00016 <span class="comment"> * </span> <a name="l00017"></a>00017 <span class="comment"> * <hr></span> <a name="l00018"></a>00018 <span class="comment"> */</span> <a name="l00019"></a>00019 <span class="comment">/*****************************************************************************/</span> <a name="l00020"></a>00020 <a name="l00021"></a>00021 <span class="preprocessor">#ifndef _cvc3__debug_h</span> <a name="l00022"></a>00022 <span class="preprocessor"></span><span class="preprocessor">#include "<a class="code" href="debug_8h.html" title="Description: Collection of debugging macros and functions.">debug.h</a>"</span> <a name="l00023"></a>00023 <span class="preprocessor">#endif</span> <a name="l00024"></a>00024 <span class="preprocessor"></span> <a name="l00025"></a>00025 <span class="preprocessor">#ifndef _cvc3__cvc_util_h</span> <a name="l00026"></a>00026 <span class="preprocessor"></span><span class="preprocessor">#define _cvc3__cvc_util_h</span> <a name="l00027"></a>00027 <span class="preprocessor"></span> <a name="l00028"></a>00028 <span class="keyword">namespace </span>CVC3 { <a name="l00029"></a>00029 <a name="l00030"></a><a class="code" href="namespaceCVC3.html#ac42ee3d1e39e0e5bbef72b5fc544db24">00030</a> <span class="keyword">inline</span> std::string <a class="code" href="namespaceCVC3.html#ac42ee3d1e39e0e5bbef72b5fc544db24">to_upper</a>(<span class="keyword">const</span> std::string & src){ <a name="l00031"></a>00031 std::string nameup; <a name="l00032"></a>00032 <span class="keywordflow">for</span>(std::string::const_iterator i=src.begin(), iend = src.end(); i!=iend ; i++){ <a name="l00033"></a>00033 nameup.push_back(toupper(*i)); <a name="l00034"></a>00034 } <a name="l00035"></a>00035 <span class="keywordflow">return</span> nameup; <a name="l00036"></a>00036 } <a name="l00037"></a>00037 <a name="l00038"></a><a class="code" href="namespaceCVC3.html#a8964cf9d9e2568f9bae1b51f8344032e">00038</a> <span class="keyword">inline</span> std::string <a class="code" href="namespaceCVC3.html#a8964cf9d9e2568f9bae1b51f8344032e">to_lower</a>(<span class="keyword">const</span> std::string & src){ <a name="l00039"></a>00039 std::string nameup; <a name="l00040"></a>00040 <span class="keywordflow">for</span>(std::string::const_iterator i=src.begin(), iend = src.end(); i!=iend ; i++){ <a name="l00041"></a>00041 nameup.push_back(tolower(*i)); <a name="l00042"></a>00042 } <a name="l00043"></a>00043 <span class="keywordflow">return</span> nameup; <a name="l00044"></a>00044 } <a name="l00045"></a>00045 <a name="l00046"></a><a class="code" href="namespaceCVC3.html#af69618103f1f0f2eadada0796a2a940c">00046</a> <span class="keyword">inline</span> std::string <a class="code" href="namespaceCVC3.html#af69618103f1f0f2eadada0796a2a940c">int2string</a>(<span class="keywordtype">int</span> n) { <a name="l00047"></a>00047 std::ostringstream ss; <a name="l00048"></a>00048 ss << n; <a name="l00049"></a>00049 <span class="keywordflow">return</span> ss.str(); <a name="l00050"></a>00050 } <a name="l00051"></a>00051 <a name="l00052"></a>00052 <span class="keyword">template</span><<span class="keyword">class</span> T> <a name="l00053"></a><a class="code" href="namespaceCVC3.html#a39fc111339d6dffdc98d6a25b68dff0e">00053</a> T <a class="code" href="namespaceCVC3.html#a39fc111339d6dffdc98d6a25b68dff0e">abs</a>(T t) { <span class="keywordflow">return</span> t < 0 ? -t : t; } <a name="l00054"></a>00054 <a name="l00055"></a>00055 <span class="keyword">template</span><<span class="keyword">class</span> T> <a name="l00056"></a><a class="code" href="namespaceCVC3.html#a03dcd07dcbd01da970af13f1dfc5e2dd">00056</a> T <a class="code" href="namespaceCVC3.html#a03dcd07dcbd01da970af13f1dfc5e2dd">max</a>(T a, T b) { <span class="keywordflow">return</span> a > b ? a : b; } <a name="l00057"></a>00057 <a name="l00058"></a><a class="code" href="structCVC3_1_1ltstr.html">00058</a> <span class="keyword">struct </span><a class="code" href="structCVC3_1_1ltstr.html">ltstr</a>{ <a name="l00059"></a><a class="code" href="structCVC3_1_1ltstr.html#a20589d553d4e0c2dac1eb0ae547b725f">00059</a> <span class="keywordtype">bool</span> <a class="code" href="structCVC3_1_1ltstr.html#a20589d553d4e0c2dac1eb0ae547b725f">operator()</a>(<span class="keyword">const</span> std::string& s1, <span class="keyword">const</span> std::string& s2)<span class="keyword"> const</span>{ <a name="l00060"></a>00060 <span class="keywordflow">return</span> s1.compare(s2) < 0; <a name="l00061"></a>00061 } <a name="l00062"></a>00062 }; <a name="l00063"></a>00063 <a name="l00064"></a>00064 <span class="keyword">template</span><<span class="keyword">class</span> T> <a name="l00065"></a><a class="code" href="classCVC3_1_1StrPairLess.html">00065</a> <span class="keyword">class </span><a class="code" href="classCVC3_1_1StrPairLess.html">StrPairLess</a> { <a name="l00066"></a>00066 <span class="keyword">public</span>: <a name="l00067"></a><a class="code" href="classCVC3_1_1StrPairLess.html#afa834b89a08f6921d098ed7345dd62c2">00067</a> <span class="keywordtype">bool</span> <a class="code" href="classCVC3_1_1StrPairLess.html#afa834b89a08f6921d098ed7345dd62c2">operator()</a>(<span class="keyword">const</span> std::pair<std::string,T>& p1, <a name="l00068"></a>00068 <span class="keyword">const</span> std::pair<std::string,T>& p2)<span class="keyword"> const </span>{ <a name="l00069"></a>00069 <span class="keywordflow">return</span> p1.first < p2.first; <a name="l00070"></a>00070 } <a name="l00071"></a>00071 }; <a name="l00072"></a>00072 <a name="l00073"></a>00073 <span class="keyword">template</span><<span class="keyword">class</span> T> <a name="l00074"></a><a class="code" href="namespaceCVC3.html#a43e7a2b69a281ee375acdaf82d1677fd">00074</a> std::pair<std::string,T> <a class="code" href="namespaceCVC3.html#a43e7a2b69a281ee375acdaf82d1677fd">strPair</a>(<span class="keyword">const</span> std::string& f, <span class="keyword">const</span> T& t) { <a name="l00075"></a>00075 <span class="keywordflow">return</span> std::pair<std::string,T>(f, t); <a name="l00076"></a>00076 } <a name="l00077"></a>00077 <a name="l00078"></a><a class="code" href="namespaceCVC3.html#a26c7481ff270baf00481e31107a46036">00078</a> <span class="keyword">typedef</span> std::pair<std::string,std::string> <a class="code" href="namespaceCVC3.html#a26c7481ff270baf00481e31107a46036">StrPair</a>; <a name="l00079"></a>00079 <span class="comment"></span> <a name="l00080"></a>00080 <span class="comment">//! Sort two vectors based on the first vector</span> <a name="l00081"></a>00081 <span class="comment"></span><span class="keyword">template</span><<span class="keyword">class</span> T> <a name="l00082"></a><a class="code" href="namespaceCVC3.html#ab21ee900e0b3494b1b8c26005436a5a4">00082</a> <span class="keywordtype">void</span> <a class="code" href="namespaceCVC3.html#ab21ee900e0b3494b1b8c26005436a5a4" title="Sort two vectors based on the first vector.">sort2</a>(std::vector<std::string>& keys, std::vector<T>& vals) { <a name="l00083"></a>00083 <a class="code" href="debug_8h.html#a40dac3bdb2166ffc852ee8b1489d2b56">DebugAssert</a>(keys.size()==vals.size(), <span class="stringliteral">"sort2()"</span>); <a name="l00084"></a>00084 <span class="comment">// Create std::vector of pairs</span> <a name="l00085"></a>00085 std::vector<std::pair<std::string,T> > pairs; <a name="l00086"></a>00086 <span class="keywordflow">for</span>(<span class="keywordtype">size_t</span> i=0, iend=keys.size(); i<iend; ++i) <a name="l00087"></a>00087 pairs.push_back(<a class="code" href="namespaceCVC3.html#a43e7a2b69a281ee375acdaf82d1677fd">strPair</a>(keys[i], vals[i])); <a name="l00088"></a>00088 <span class="comment">// Sort pairs</span> <a name="l00089"></a>00089 <a class="code" href="classCVC3_1_1StrPairLess.html">StrPairLess<T></a> comp; <a name="l00090"></a>00090 sort(pairs.begin(), pairs.end(), comp); <a name="l00091"></a>00091 <a class="code" href="debug_8h.html#a40dac3bdb2166ffc852ee8b1489d2b56">DebugAssert</a>(pairs.size() == keys.size(), <span class="stringliteral">"sort2()"</span>); <a name="l00092"></a>00092 <span class="comment">// Split the pairs back into the original vectors</span> <a name="l00093"></a>00093 <span class="keywordflow">for</span>(<span class="keywordtype">size_t</span> i=0, iend=pairs.size(); i<iend; ++i) { <a name="l00094"></a>00094 keys[i] = pairs[i].first; <a name="l00095"></a>00095 vals[i] = pairs[i].second; <a name="l00096"></a>00096 } <a name="l00097"></a>00097 } <a name="l00098"></a>00098 <span class="comment"></span> <a name="l00099"></a>00099 <span class="comment">/*! @brief A class which sets a boolean value to true when created,</span> <a name="l00100"></a>00100 <span class="comment"> * and resets to false when deleted.</span> <a name="l00101"></a>00101 <span class="comment"> *</span> <a name="l00102"></a>00102 <span class="comment"> * Useful for tracking when the control is within a certain method or</span> <a name="l00103"></a>00103 <span class="comment"> * not. For example, TheoryCore::addFact() uses d_inAddFact to check</span> <a name="l00104"></a>00104 <span class="comment"> * that certain other methods are only called from within addFact().</span> <a name="l00105"></a>00105 <span class="comment"> * However, when an exception is thrown, this variable is not reset.</span> <a name="l00106"></a>00106 <span class="comment"> * The watcher class will reset the variable even in those cases.</span> <a name="l00107"></a>00107 <span class="comment"> */</span> <a name="l00108"></a><a class="code" href="classCVC3_1_1ScopeWatcher.html">00108</a> <span class="keyword">class </span><a class="code" href="classCVC3_1_1ScopeWatcher.html" title="A class which sets a boolean value to true when created, and resets to false when deleted...">ScopeWatcher</a> { <a name="l00109"></a>00109 <span class="keyword">private</span>: <a name="l00110"></a><a class="code" href="classCVC3_1_1ScopeWatcher.html#a248003277034de7387a59039119224d8">00110</a> <span class="keywordtype">bool</span> *<a class="code" href="classCVC3_1_1ScopeWatcher.html#a248003277034de7387a59039119224d8">d_flag</a>; <a name="l00111"></a>00111 <span class="keyword">public</span>: <a name="l00112"></a><a class="code" href="classCVC3_1_1ScopeWatcher.html#aea403b8b5f957e895acdbcc1f7b31b8d">00112</a> <a class="code" href="classCVC3_1_1ScopeWatcher.html#aea403b8b5f957e895acdbcc1f7b31b8d">ScopeWatcher</a>(<span class="keywordtype">bool</span> *flag): <a class="code" href="classCVC3_1_1ScopeWatcher.html#a248003277034de7387a59039119224d8">d_flag</a>(flag) { *<a class="code" href="classCVC3_1_1ScopeWatcher.html#a248003277034de7387a59039119224d8">d_flag</a> = <span class="keyword">true</span>; } <a name="l00113"></a><a class="code" href="classCVC3_1_1ScopeWatcher.html#a16c42e2a3e9ab587d2a51fa07218eac4">00113</a> <a class="code" href="classCVC3_1_1ScopeWatcher.html#a16c42e2a3e9ab587d2a51fa07218eac4">~ScopeWatcher</a>() { *<a class="code" href="classCVC3_1_1ScopeWatcher.html#a248003277034de7387a59039119224d8">d_flag</a> = <span class="keyword">false</span>; } <a name="l00114"></a>00114 }; <a name="l00115"></a>00115 <a name="l00116"></a>00116 <a name="l00117"></a>00117 <span class="comment">// For memory calculations</span> <a name="l00118"></a><a class="code" href="classCVC3_1_1MemoryTracker.html">00118</a> <span class="keyword">class </span><a class="code" href="classCVC3_1_1MemoryTracker.html">MemoryTracker</a> { <a name="l00119"></a>00119 <span class="keyword">public</span>: <a name="l00120"></a><a class="code" href="classCVC3_1_1MemoryTracker.html#a689b66f3be59b607f35a67238817b9d0">00120</a> <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classCVC3_1_1MemoryTracker.html#a689b66f3be59b607f35a67238817b9d0">print</a>(std::string name, <span class="keywordtype">int</span> verbosity, <a name="l00121"></a>00121 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> memSelf, <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> mem) <a name="l00122"></a>00122 { <a name="l00123"></a>00123 <span class="keywordflow">if</span> (verbosity > 0) { <a name="l00124"></a>00124 std::cout << name << <span class="stringliteral">": "</span> << memSelf << <a class="code" href="group__ExprStream__Manip.html#ga05b0ea7353ec24fa8e7e272d7a7875d8" title="Print the end-of-line.">std::endl</a>; <a name="l00125"></a>00125 std::cout << <span class="stringliteral">" Children: "</span> << mem << <a class="code" href="group__ExprStream__Manip.html#ga05b0ea7353ec24fa8e7e272d7a7875d8" title="Print the end-of-line.">std::endl</a>; <a name="l00126"></a>00126 std::cout << <span class="stringliteral">" Total: "</span> << mem+memSelf << <a class="code" href="group__ExprStream__Manip.html#ga05b0ea7353ec24fa8e7e272d7a7875d8" title="Print the end-of-line.">std::endl</a>; <a name="l00127"></a>00127 } <a name="l00128"></a>00128 } <a name="l00129"></a>00129 <a name="l00130"></a>00130 <span class="keyword">template</span> <<span class="keyword">typename</span> T> <a name="l00131"></a><a class="code" href="classCVC3_1_1MemoryTracker.html#a4f1cc78055cb2899adc927c2c26da9bc">00131</a> <span class="keyword">static</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <a class="code" href="classCVC3_1_1MemoryTracker.html#a4f1cc78055cb2899adc927c2c26da9bc">getVec</a>(<span class="keywordtype">int</span> verbosity, <span class="keyword">const</span> std::vector<T>& v) <a name="l00132"></a>00132 { <a name="l00133"></a>00133 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> memSelf = <span class="keyword">sizeof</span>(std::vector<T>); <a name="l00134"></a>00134 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> mem = 0; <a name="l00135"></a>00135 <a class="code" href="classCVC3_1_1MemoryTracker.html#a689b66f3be59b607f35a67238817b9d0">print</a>(<span class="stringliteral">"vector"</span>, verbosity, memSelf, mem); <a name="l00136"></a>00136 <span class="keywordflow">return</span> memSelf + mem; <a name="l00137"></a>00137 } <a name="l00138"></a>00138 <a name="l00139"></a>00139 <span class="keyword">template</span> <<span class="keyword">typename</span> T> <a name="l00140"></a><a class="code" href="classCVC3_1_1MemoryTracker.html#a2af433be2efae02a4d2127beff41725e">00140</a> <span class="keyword">static</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <a class="code" href="classCVC3_1_1MemoryTracker.html#a2af433be2efae02a4d2127beff41725e">getVecAndData</a>(<span class="keywordtype">int</span> verbosity, <span class="keyword">const</span> std::vector<T>& v) <a name="l00141"></a>00141 { <a name="l00142"></a>00142 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> memSelf = <span class="keyword">sizeof</span>(std::vector<T>); <a name="l00143"></a>00143 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> mem = 0; <a name="l00144"></a>00144 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < v.size(); ++i) { <a name="l00145"></a>00145 mem += v[i].getMemory(verbosity - 1); <a name="l00146"></a>00146 } <a name="l00147"></a>00147 <a class="code" href="classCVC3_1_1MemoryTracker.html#a689b66f3be59b607f35a67238817b9d0">print</a>(<span class="stringliteral">"vector+data"</span>, verbosity, memSelf, mem); <a name="l00148"></a>00148 <span class="keywordflow">return</span> memSelf + mem; <a name="l00149"></a>00149 } <a name="l00150"></a>00150 <a name="l00151"></a>00151 <span class="keyword">template</span> <<span class="keyword">typename</span> T> <a name="l00152"></a><a class="code" href="classCVC3_1_1MemoryTracker.html#a64b4a49e5d957a73f3a8f05921c65471">00152</a> <span class="keyword">static</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <a class="code" href="classCVC3_1_1MemoryTracker.html#a64b4a49e5d957a73f3a8f05921c65471">getVecAndDataP</a>(<span class="keywordtype">int</span> verbosity, <span class="keyword">const</span> std::vector<T>& v) <a name="l00153"></a>00153 { <a name="l00154"></a>00154 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> memSelf = <span class="keyword">sizeof</span>(std::vector<T>); <a name="l00155"></a>00155 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> mem = 0; <a name="l00156"></a>00156 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < v.size(); ++i) { <a name="l00157"></a>00157 mem += v[i]->getMemory(verbosity - 1); <a name="l00158"></a>00158 } <a name="l00159"></a>00159 <a class="code" href="classCVC3_1_1MemoryTracker.html#a689b66f3be59b607f35a67238817b9d0">print</a>(<span class="stringliteral">"vector+data(p)"</span>, verbosity, memSelf, mem); <a name="l00160"></a>00160 <span class="keywordflow">return</span> memSelf + mem; <a name="l00161"></a>00161 } <a name="l00162"></a>00162 <a name="l00163"></a><a class="code" href="classCVC3_1_1MemoryTracker.html#add7e68c278aae046a5f5a4df50402114">00163</a> <span class="keyword">static</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <a class="code" href="classCVC3_1_1MemoryTracker.html#add7e68c278aae046a5f5a4df50402114">getString</a>(<span class="keywordtype">int</span> verbosity, <span class="keyword">const</span> std::string& s) <a name="l00164"></a>00164 { <a name="l00165"></a>00165 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> memSelf = <span class="keyword">sizeof</span>(std::string); <a name="l00166"></a>00166 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> mem = s.capacity() * <span class="keyword">sizeof</span>(char); <a name="l00167"></a>00167 <a class="code" href="classCVC3_1_1MemoryTracker.html#a689b66f3be59b607f35a67238817b9d0">print</a>(<span class="stringliteral">"string"</span>, verbosity, memSelf, mem); <a name="l00168"></a>00168 <span class="keywordflow">return</span> memSelf + mem; <a name="l00169"></a>00169 } <a name="l00170"></a>00170 <a name="l00171"></a>00171 <span class="comment">// template <class _Key, class _Value,</span> <a name="l00172"></a>00172 <span class="comment">// class _HashFcn, class _EqualKey, class _ExtractKey></span> <a name="l00173"></a>00173 <span class="comment">// unsigned long get(int verbosity, const hash_table<_Key, _Value, _HashFcn, </span> <a name="l00174"></a>00174 <span class="comment">// unsigned long memSelf = sizeof(BucketNode);</span> <a name="l00175"></a>00175 <span class="comment">// unsigned long mem = 0;</span> <a name="l00176"></a>00176 <span class="comment">// BucketNode* node = this;</span> <a name="l00177"></a>00177 <span class="comment">// do {</span> <a name="l00178"></a>00178 <span class="comment">// if (getMemoryData) {</span> <a name="l00179"></a>00179 <span class="comment">// mem += d_value.getMemory(verbosity</span> <a name="l00180"></a>00180 <span class="comment">// node = node->d_next;</span> <a name="l00181"></a>00181 <span class="comment">// } while (node != NULL) </span> <a name="l00182"></a>00182 <span class="comment">// unsigned long mem = 0;</span> <a name="l00183"></a>00183 <a name="l00184"></a>00184 <span class="comment">// mem += getMemoryVec(verbosity - 1, d_data, false, true);</span> <a name="l00185"></a>00185 <span class="comment">// printMemory("hash_table", verbosity, memSelf, mem);</span> <a name="l00186"></a>00186 <span class="comment">// return mem+memSelf;</span> <a name="l00187"></a>00187 <span class="comment">// }</span> <a name="l00188"></a>00188 <a name="l00189"></a>00189 <span class="comment">// unsigned long getMemory(int verbosity, hash_table) {</span> <a name="l00190"></a>00190 <span class="comment">// unsigned long memSelf = sizeof(hash_table);</span> <a name="l00191"></a>00191 <span class="comment">// unsigned long mem = 0;</span> <a name="l00192"></a>00192 <span class="comment">// mem += d_hash.getmemory(verbosity - 1) - sizeof(hasher);</span> <a name="l00193"></a>00193 <span class="comment">// mem += d_equal.getmemory(verbosity - 1) - sizeof(key_equal);</span> <a name="l00194"></a>00194 <span class="comment">// mem += d_extractKey.getmemory(verbosity - 1) - sizeof(_ExtractKey);</span> <a name="l00195"></a>00195 <a name="l00196"></a>00196 <span class="comment">// // handle data</span> <a name="l00197"></a>00197 <span class="comment">// mem += sizeof(Data);</span> <a name="l00198"></a>00198 <span class="comment">// mem += sizeof(Bucket*)*d_data.capacity();</span> <a name="l00199"></a>00199 <span class="comment">// for (unsigned i = 0; i < d_data.size(); ++i) {</span> <a name="l00200"></a>00200 <span class="comment">// mem += d_data[i]->getMemory(verbosity - 1, getMemoryData, getMemoryDataP);</span> <a name="l00201"></a>00201 <span class="comment">// }</span> <a name="l00202"></a>00202 <a name="l00203"></a>00203 <span class="comment">// printMemory("hash_table", verbosity, memSelf, mem);</span> <a name="l00204"></a>00204 <span class="comment">// return mem+memSelf;</span> <a name="l00205"></a>00205 <span class="comment">// }</span> <a name="l00206"></a>00206 <a name="l00207"></a>00207 <span class="comment">// unsigned long getMemory(int verbosity, hash_map) const {</span> <a name="l00208"></a>00208 <span class="comment">// unsigned long memSelf = sizeof(hash_map);</span> <a name="l00209"></a>00209 <span class="comment">// unsigned long mem = 0;</span> <a name="l00210"></a>00210 <span class="comment">// mem += d_table.getMemory(verbosity - 1) - sizeof(_hash_table);</span> <a name="l00211"></a>00211 <span class="comment">// MemoryTracker::print("hash_map", verbosity, memSelf, mem);</span> <a name="l00212"></a>00212 <span class="comment">// return mem+memSelf;</span> <a name="l00213"></a>00213 <span class="comment">// }</span> <a name="l00214"></a>00214 <a name="l00215"></a>00215 <a name="l00216"></a>00216 }; <span class="comment">// End of MemoryTracker</span> <a name="l00217"></a>00217 <a name="l00218"></a>00218 } <a name="l00219"></a>00219 <a name="l00220"></a>00220 <span class="preprocessor">#endif</span> </pre></div></div> </div> <hr class="footer"/><address class="footer"><small>Generated on Wed Sep 7 2011 for CVC3 by  <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.4 </small></address> </body> </html>