Sophie

Sophie

distrib > Fedora > 15 > i386 > by-pkgid > 583ffa4ba069126c3ba0bc565dc0485a > files > 92

cvc3-doc-2.4.1-1.fc15.noarch.rpm

<!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: cdlist.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&#160;<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&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;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&#160;List</span></a></li>
      <li><a href="globals.html"><span>File&#160;Members</span></a></li>
    </ul>
  </div>
<div class="header">
  <div class="headertitle">
<div class="title">cdlist.h</div>  </div>
</div>
<div class="contents">
<a href="cdlist_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 cdlist.h</span>
<a name="l00004"></a>00004 <span class="comment"> * </span>
<a name="l00005"></a>00005 <span class="comment"> * Author: Clark Barrett</span>
<a name="l00006"></a>00006 <span class="comment"> * </span>
<a name="l00007"></a>00007 <span class="comment"> * Created: Wed Feb 12 18:45:26 2003</span>
<a name="l00008"></a>00008 <span class="comment"> *</span>
<a name="l00009"></a>00009 <span class="comment"> * &lt;hr&gt;</span>
<a name="l00010"></a>00010 <span class="comment"> *</span>
<a name="l00011"></a>00011 <span class="comment"> * License to use, copy, modify, sell and/or distribute this software</span>
<a name="l00012"></a>00012 <span class="comment"> * and its documentation for any purpose is hereby granted without</span>
<a name="l00013"></a>00013 <span class="comment"> * royalty, subject to the terms and conditions defined in the \ref</span>
<a name="l00014"></a>00014 <span class="comment"> * LICENSE file provided with this distribution.</span>
<a name="l00015"></a>00015 <span class="comment"> * </span>
<a name="l00016"></a>00016 <span class="comment"> * &lt;hr&gt;</span>
<a name="l00017"></a>00017 <span class="comment"> * </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__include__cdlist_h_</span>
<a name="l00022"></a>00022 <span class="preprocessor"></span><span class="preprocessor">#define _cvc3__include__cdlist_h_</span>
<a name="l00023"></a>00023 <span class="preprocessor"></span>
<a name="l00024"></a>00024 <span class="preprocessor">#include &quot;<a class="code" href="context_8h.html">context.h</a>&quot;</span>
<a name="l00025"></a>00025 <span class="preprocessor">#include &lt;deque&gt;</span>
<a name="l00026"></a>00026 
<a name="l00027"></a>00027 <span class="keyword">namespace </span>CVC3 {
<a name="l00028"></a>00028 <span class="comment"></span>
<a name="l00029"></a>00029 <span class="comment">///////////////////////////////////////////////////////////////////////////////</span>
<a name="l00030"></a>00030 <span class="comment"></span><span class="comment">//                                                                           //</span>
<a name="l00031"></a>00031 <span class="comment">// Class: CDList (Context Dependent List)            //</span>
<a name="l00032"></a>00032 <span class="comment">// Author: Clark Barrett                                                     //</span>
<a name="l00033"></a>00033 <span class="comment">// Created: Wed Feb 12 17:28:25 2003               //</span>
<a name="l00034"></a>00034 <span class="comment">// Description: Generic templated class for list which grows monotonically   //</span>
<a name="l00035"></a>00035 <span class="comment">//              over time (if the context is not popped) but must also be    //</span>
<a name="l00036"></a>00036 <span class="comment">//              saved and restored as contexts are pushed and popped.        //</span>
<a name="l00037"></a>00037 <span class="comment">//                                                                           //</span><span class="comment"></span>
<a name="l00038"></a>00038 <span class="comment">///////////////////////////////////////////////////////////////////////////////</span>
<a name="l00039"></a>00039 <span class="comment"></span><span class="comment">// TODO: more efficient implementation</span>
<a name="l00040"></a>00040 <span class="keyword">template</span> &lt;<span class="keyword">class</span> T&gt;
<a name="l00041"></a><a class="code" href="classCVC3_1_1CDList.html">00041</a> <span class="keyword">class </span><a class="code" href="classCVC3_1_1CDList.html">CDList</a> :<span class="keyword">public</span> <a class="code" href="classCVC3_1_1ContextObj.html">ContextObj</a> {<span class="comment"></span>
<a name="l00042"></a>00042 <span class="comment">  //! The actual data.  </span>
<a name="l00043"></a>00043 <span class="comment"></span><span class="comment">  /*! Use deque because it doesn&#39;t create/destroy data on resize.</span>
<a name="l00044"></a>00044 <span class="comment">    This pointer is only non-NULL in the master copy. */</span>
<a name="l00045"></a><a class="code" href="classCVC3_1_1CDList.html#a00cc7b0ec422024ceb9d37cab0cf8d13">00045</a>   std::deque&lt;T&gt;* <a class="code" href="classCVC3_1_1CDList.html#a00cc7b0ec422024ceb9d37cab0cf8d13" title="The actual data.">d_list</a>; <span class="comment">// </span>
<a name="l00046"></a><a class="code" href="classCVC3_1_1CDList.html#aeae6c707e040edaddcaf2210e5c982df">00046</a>   <span class="keywordtype">unsigned</span> <a class="code" href="classCVC3_1_1CDList.html#aeae6c707e040edaddcaf2210e5c982df">d_size</a>;
<a name="l00047"></a>00047 
<a name="l00048"></a><a class="code" href="classCVC3_1_1CDList.html#a73cc9e67876b310570f199849c4b4c34">00048</a>   <span class="keyword">virtual</span> <a class="code" href="classCVC3_1_1ContextObj.html">ContextObj</a>* <a class="code" href="classCVC3_1_1CDList.html#a73cc9e67876b310570f199849c4b4c34" title="Make a copy of the current object so it can be restored to its current state.">makeCopy</a>(<a class="code" href="classCVC3_1_1ContextMemoryManager.html" title="ContextMemoryManager.">ContextMemoryManager</a>* cmm) { <span class="keywordflow">return</span> <span class="keyword">new</span>(cmm) <a class="code" href="classCVC3_1_1CDList.html">CDList&lt;T&gt;</a>(*<span class="keyword">this</span>); }
<a name="l00049"></a><a class="code" href="classCVC3_1_1CDList.html#ae8dd8c4621883f2f9e39a9961ae677a4">00049</a>   <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classCVC3_1_1CDList.html#ae8dd8c4621883f2f9e39a9961ae677a4" title="Restore the current object from the given data.">restoreData</a>(<a class="code" href="classCVC3_1_1ContextObj.html">ContextObj</a>* data)
<a name="l00050"></a>00050     { <a class="code" href="classCVC3_1_1CDList.html#aeae6c707e040edaddcaf2210e5c982df">d_size</a> = ((<a class="code" href="classCVC3_1_1CDList.html">CDList&lt;T&gt;</a>*)data)-&gt;d_size;
<a name="l00051"></a>00051       <span class="keywordflow">while</span> (<a class="code" href="classCVC3_1_1CDList.html#a00cc7b0ec422024ceb9d37cab0cf8d13" title="The actual data.">d_list</a>-&gt;size() &gt; <a class="code" href="classCVC3_1_1CDList.html#aeae6c707e040edaddcaf2210e5c982df">d_size</a>) <a class="code" href="classCVC3_1_1CDList.html#a00cc7b0ec422024ceb9d37cab0cf8d13" title="The actual data.">d_list</a>-&gt;pop_back(); }
<a name="l00052"></a><a class="code" href="classCVC3_1_1CDList.html#ae9b6faa25c578c0a3c3fb2feb5e9ddd7">00052</a>   <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classCVC3_1_1CDList.html#ae9b6faa25c578c0a3c3fb2feb5e9ddd7" title="Set the current object to be invalid.">setNull</a>(<span class="keywordtype">void</span>)
<a name="l00053"></a>00053     { <span class="keywordflow">while</span> (<a class="code" href="classCVC3_1_1CDList.html#a00cc7b0ec422024ceb9d37cab0cf8d13" title="The actual data.">d_list</a>-&gt;size()) <a class="code" href="classCVC3_1_1CDList.html#a00cc7b0ec422024ceb9d37cab0cf8d13" title="The actual data.">d_list</a>-&gt;pop_back(); <a class="code" href="classCVC3_1_1CDList.html#aeae6c707e040edaddcaf2210e5c982df">d_size</a> = 0; }
<a name="l00054"></a>00054 
<a name="l00055"></a>00055   <span class="comment">// Copy constructor (private).  Do NOT copy d_list.  It&#39;s not used</span>
<a name="l00056"></a>00056   <span class="comment">// in restore, and it will be deleted in destructor.</span>
<a name="l00057"></a><a class="code" href="classCVC3_1_1CDList.html#abf552d89a744af824ca22a4b713ec8dd">00057</a>   <a class="code" href="classCVC3_1_1CDList.html#abf552d89a744af824ca22a4b713ec8dd">CDList</a>(<span class="keyword">const</span> <a class="code" href="classCVC3_1_1CDList.html">CDList&lt;T&gt;</a>&amp; l): <a class="code" href="classCVC3_1_1ContextObj.html">ContextObj</a>(l), <a class="code" href="classCVC3_1_1CDList.html#a00cc7b0ec422024ceb9d37cab0cf8d13" title="The actual data.">d_list</a>(NULL), <a class="code" href="classCVC3_1_1CDList.html#aeae6c707e040edaddcaf2210e5c982df">d_size</a>(l.<a class="code" href="classCVC3_1_1CDList.html#aeae6c707e040edaddcaf2210e5c982df">d_size</a>) { }
<a name="l00058"></a>00058 <span class="keyword">public</span>:
<a name="l00059"></a><a class="code" href="classCVC3_1_1CDList.html#a77d6bb320aecfd466025cbfb4fdb579b">00059</a>   <a class="code" href="classCVC3_1_1CDList.html#a77d6bb320aecfd466025cbfb4fdb579b">CDList</a>(<a class="code" href="classCVC3_1_1Context.html">Context</a>* context) : <a class="code" href="classCVC3_1_1ContextObj.html">ContextObj</a>(context), <a class="code" href="classCVC3_1_1CDList.html#aeae6c707e040edaddcaf2210e5c982df">d_size</a>(0) {
<a name="l00060"></a>00060     <a class="code" href="classCVC3_1_1CDList.html#a00cc7b0ec422024ceb9d37cab0cf8d13" title="The actual data.">d_list</a> = <span class="keyword">new</span> std::deque&lt;T&gt;();
<a name="l00061"></a>00061     <a class="code" href="debug_8h.html#a600cb2d68efe7cc413cccbb5714c7016">IF_DEBUG</a>(setName(<span class="stringliteral">&quot;CDList&quot;</span>);)
<a name="l00062"></a>00062   }
<a name="l00063"></a><a class="code" href="classCVC3_1_1CDList.html#aec2c5706729c396301026766813a632f">00063</a>   <span class="keyword">virtual</span> ~<a class="code" href="classCVC3_1_1CDList.html#abf552d89a744af824ca22a4b713ec8dd">CDList</a>() { <span class="keywordflow">if</span>(<a class="code" href="classCVC3_1_1CDList.html#a00cc7b0ec422024ceb9d37cab0cf8d13" title="The actual data.">d_list</a> != NULL) <span class="keyword">delete</span> <a class="code" href="classCVC3_1_1CDList.html#a00cc7b0ec422024ceb9d37cab0cf8d13" title="The actual data.">d_list</a>; }
<a name="l00064"></a><a class="code" href="classCVC3_1_1CDList.html#adf92d0f391d73e7ac70da57db135af27">00064</a>   <span class="keywordtype">unsigned</span> <a class="code" href="classCVC3_1_1CDList.html#adf92d0f391d73e7ac70da57db135af27">size</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="classCVC3_1_1CDList.html#aeae6c707e040edaddcaf2210e5c982df">d_size</a>; }
<a name="l00065"></a><a class="code" href="classCVC3_1_1CDList.html#afafb842f23a41289eb104404e5eb94bf">00065</a>   <span class="keywordtype">bool</span> <a class="code" href="classCVC3_1_1CDList.html#afafb842f23a41289eb104404e5eb94bf">empty</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="classCVC3_1_1CDList.html#aeae6c707e040edaddcaf2210e5c982df">d_size</a> == 0; }
<a name="l00066"></a><a class="code" href="classCVC3_1_1CDList.html#aa1e8d3591c596d1b9c585dec955b519b">00066</a>   T&amp; <a class="code" href="classCVC3_1_1CDList.html#aa1e8d3591c596d1b9c585dec955b519b">push_back</a>(<span class="keyword">const</span> T&amp; data, <span class="keywordtype">int</span> scope = -1)
<a name="l00067"></a>00067    { <a class="code" href="classCVC3_1_1ContextObj.html#a780166170b1df8eb7a7632eae66c3511">makeCurrent</a>(scope); <a class="code" href="classCVC3_1_1CDList.html#a00cc7b0ec422024ceb9d37cab0cf8d13" title="The actual data.">d_list</a>-&gt;push_back(data); ++<a class="code" href="classCVC3_1_1CDList.html#aeae6c707e040edaddcaf2210e5c982df">d_size</a>; <span class="keywordflow">return</span> <a class="code" href="classCVC3_1_1CDList.html#a00cc7b0ec422024ceb9d37cab0cf8d13" title="The actual data.">d_list</a>-&gt;back(); }
<a name="l00068"></a><a class="code" href="classCVC3_1_1CDList.html#a49d135664e22701bc537fd799f82c740">00068</a>   <span class="keywordtype">void</span> <a class="code" href="classCVC3_1_1CDList.html#a49d135664e22701bc537fd799f82c740">pop_back</a>()
<a name="l00069"></a>00069   { <a class="code" href="debug_8h.html#a40dac3bdb2166ffc852ee8b1489d2b56">DebugAssert</a>(<a class="code" href="classCVC3_1_1ContextObj.html#a136ad204e9ea96ee300de82ea534277e">isCurrent</a>() &amp;&amp; <a class="code" href="classCVC3_1_1ContextObj.html#a6d37a721fd7fc3b4eabdae16cdf133c0">getRestore</a>() &amp;&amp;
<a name="l00070"></a>00070                 <a class="code" href="classCVC3_1_1CDList.html#aeae6c707e040edaddcaf2210e5c982df">d_size</a> &gt; ((<a class="code" href="classCVC3_1_1CDList.html">CDList&lt;T&gt;</a>*)<a class="code" href="classCVC3_1_1ContextObj.html#a6d37a721fd7fc3b4eabdae16cdf133c0">getRestore</a>())-&gt;<a class="code" href="classCVC3_1_1CDList.html#aeae6c707e040edaddcaf2210e5c982df">d_size</a>, <span class="stringliteral">&quot;pop_back precond violated&quot;</span>);
<a name="l00071"></a>00071     <a class="code" href="classCVC3_1_1CDList.html#a00cc7b0ec422024ceb9d37cab0cf8d13" title="The actual data.">d_list</a>-&gt;pop_back(); --<a class="code" href="classCVC3_1_1CDList.html#aeae6c707e040edaddcaf2210e5c982df">d_size</a>; }
<a name="l00072"></a><a class="code" href="classCVC3_1_1CDList.html#a442a4e4c6e5b0842bd94af64f110c947">00072</a>   <span class="keyword">const</span> T&amp; <a class="code" href="classCVC3_1_1CDList.html#a442a4e4c6e5b0842bd94af64f110c947">operator[]</a>(<span class="keywordtype">unsigned</span> i)<span class="keyword"> const </span>{
<a name="l00073"></a>00073     <a class="code" href="debug_8h.html#a40dac3bdb2166ffc852ee8b1489d2b56">DebugAssert</a>(i &lt; <a class="code" href="classCVC3_1_1CDList.html#adf92d0f391d73e7ac70da57db135af27">size</a>(),
<a name="l00074"></a>00074     <span class="stringliteral">&quot;CDList[&quot;</span>+<a class="code" href="namespaceCVC3.html#af69618103f1f0f2eadada0796a2a940c">int2string</a>(i)+<span class="stringliteral">&quot;]: i &lt; size=&quot;</span>+<a class="code" href="namespaceCVC3.html#af69618103f1f0f2eadada0796a2a940c">int2string</a>(<a class="code" href="classCVC3_1_1CDList.html#adf92d0f391d73e7ac70da57db135af27">size</a>()));
<a name="l00075"></a>00075     <span class="keywordflow">return</span> (*<a class="code" href="classCVC3_1_1CDList.html#a00cc7b0ec422024ceb9d37cab0cf8d13" title="The actual data.">d_list</a>)[i];
<a name="l00076"></a>00076   }
<a name="l00077"></a><a class="code" href="classCVC3_1_1CDList.html#ae461043535f7886c46b87e850ca19cdd">00077</a>   <span class="keyword">const</span> T&amp; <a class="code" href="classCVC3_1_1CDList.html#ae461043535f7886c46b87e850ca19cdd">at</a>(<span class="keywordtype">unsigned</span> i)<span class="keyword"> const </span>{
<a name="l00078"></a>00078     <a class="code" href="debug_8h.html#a40dac3bdb2166ffc852ee8b1489d2b56">DebugAssert</a>(i &lt; <a class="code" href="classCVC3_1_1CDList.html#adf92d0f391d73e7ac70da57db135af27">size</a>(),
<a name="l00079"></a>00079     <span class="stringliteral">&quot;CDList[&quot;</span>+<a class="code" href="namespaceCVC3.html#af69618103f1f0f2eadada0796a2a940c">int2string</a>(i)+<span class="stringliteral">&quot;]: i &lt; size=&quot;</span>+<a class="code" href="namespaceCVC3.html#af69618103f1f0f2eadada0796a2a940c">int2string</a>(<a class="code" href="classCVC3_1_1CDList.html#adf92d0f391d73e7ac70da57db135af27">size</a>()));
<a name="l00080"></a>00080     <span class="keywordflow">return</span> (*<a class="code" href="classCVC3_1_1CDList.html#a00cc7b0ec422024ceb9d37cab0cf8d13" title="The actual data.">d_list</a>)[i];
<a name="l00081"></a>00081   }
<a name="l00082"></a><a class="code" href="classCVC3_1_1CDList.html#ad6812838e872789a511317c79981a208">00082</a>   <span class="keyword">const</span> T&amp; <a class="code" href="classCVC3_1_1CDList.html#ad6812838e872789a511317c79981a208">back</a>()<span class="keyword"> const </span>{
<a name="l00083"></a>00083     <a class="code" href="debug_8h.html#a40dac3bdb2166ffc852ee8b1489d2b56">DebugAssert</a>(<a class="code" href="classCVC3_1_1CDList.html#adf92d0f391d73e7ac70da57db135af27">size</a>() &gt; 0,
<a name="l00084"></a>00084     <span class="stringliteral">&quot;CDList::back(): size=&quot;</span>+<a class="code" href="namespaceCVC3.html#af69618103f1f0f2eadada0796a2a940c">int2string</a>(<a class="code" href="classCVC3_1_1CDList.html#adf92d0f391d73e7ac70da57db135af27">size</a>()));
<a name="l00085"></a>00085     <span class="keywordflow">return</span> <a class="code" href="classCVC3_1_1CDList.html#a00cc7b0ec422024ceb9d37cab0cf8d13" title="The actual data.">d_list</a>-&gt;back();
<a name="l00086"></a>00086   }
<a name="l00087"></a><a class="code" href="classCVC3_1_1CDList.html#ae95c5bcd0125298d6d189136705c92b5">00087</a>   <span class="keyword">typedef</span> <span class="keyword">typename</span> std::deque&lt;T&gt;::const_iterator <a class="code" href="classCVC3_1_1CDList.html#ae95c5bcd0125298d6d189136705c92b5">const_iterator</a>;
<a name="l00088"></a><a class="code" href="classCVC3_1_1CDList.html#ae2cf006604b1ab88139332a5e2c08568">00088</a>   const_iterator <a class="code" href="classCVC3_1_1CDList.html#ae2cf006604b1ab88139332a5e2c08568">begin</a>()<span class="keyword"> const </span>{
<a name="l00089"></a>00089     <span class="keywordflow">return</span> <a class="code" href="classCVC3_1_1CDList.html#a00cc7b0ec422024ceb9d37cab0cf8d13" title="The actual data.">d_list</a>-&gt;begin();
<a name="l00090"></a>00090   }
<a name="l00091"></a><a class="code" href="classCVC3_1_1CDList.html#a96313ff2924c89a93d7fe6c618c837af">00091</a>   const_iterator <a class="code" href="classCVC3_1_1CDList.html#a96313ff2924c89a93d7fe6c618c837af">end</a>()<span class="keyword"> const </span>{
<a name="l00092"></a>00092     <span class="keywordflow">return</span> <a class="code" href="classCVC3_1_1CDList.html#ae2cf006604b1ab88139332a5e2c08568">begin</a>() + <a class="code" href="classCVC3_1_1CDList.html#aeae6c707e040edaddcaf2210e5c982df">d_size</a>;
<a name="l00093"></a>00093   }
<a name="l00094"></a>00094 };
<a name="l00095"></a>00095 
<a name="l00096"></a>00096 }
<a name="l00097"></a>00097 
<a name="l00098"></a>00098 <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&#160;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.4 </small></address>
</body>
</html>