| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
| <html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> |
| <title>FTGL: FTList.h Source File</title> |
| <link href="doxygen.css" rel="stylesheet" type="text/css"> |
| </head><body> |
| <!-- Generated by Doxygen 1.3.6 --> |
| <div class="qindex"><a class="qindex" href="index.html">Main Page</a> | <a class="qindex" href="hierarchy.html">Class Hierarchy</a> | <a class="qindex" href="annotated.html">Data Structures</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="functions.html">Data Fields</a> | <a class="qindex" href="globals.html">Globals</a></div> |
| <h1>FTList.h</h1><a href="FTList_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="preprocessor">#ifndef __FTList__</span> |
| 00002 <span class="preprocessor"></span><span class="preprocessor">#define __FTList__</span> |
| 00003 <span class="preprocessor"></span> |
| 00004 <span class="preprocessor">#include "<a class="code" href="FTGL_8h.html">FTGL.h</a>"</span> |
| 00005 |
| 00009 <span class="keyword">template</span> <<span class="keyword">typename</span> FT_LIST_ITEM_TYPE> |
| <a name="l00010"></a><a class="code" href="classFTList.html">00010</a> <span class="keyword">class </span><a class="code" href="FTGL_8h.html#a3">FTGL_EXPORT</a> FTList |
| 00011 { |
| 00012 <span class="keyword">public</span>: |
| <a name="l00013"></a><a class="code" href="classFTList.html#w0">00013</a> <span class="keyword">typedef</span> FT_LIST_ITEM_TYPE value_type; |
| <a name="l00014"></a><a class="code" href="classFTList.html#w1">00014</a> <span class="keyword">typedef</span> value_type& reference; |
| <a name="l00015"></a><a class="code" href="classFTList.html#w2">00015</a> <span class="keyword">typedef</span> <span class="keyword">const</span> value_type& const_reference; |
| <a name="l00016"></a><a class="code" href="classFTList.html#w3">00016</a> <span class="keyword">typedef</span> size_t size_type; |
| 00017 |
| <a name="l00021"></a><a class="code" href="classFTList.html#a0">00021</a> FTList() |
| 00022 : listSize(0), |
| 00023 tail(0) |
| 00024 { |
| 00025 tail = NULL; |
| 00026 head = <span class="keyword">new</span> Node; |
| 00027 } |
| 00028 |
| <a name="l00032"></a><a class="code" href="classFTList.html#a1">00032</a> ~FTList() |
| 00033 { |
| 00034 Node* next; |
| 00035 |
| 00036 <span class="keywordflow">for</span>( Node *walk = head; walk; walk = next) |
| 00037 { |
| 00038 next = walk->next; |
| 00039 <span class="keyword">delete</span> walk; |
| 00040 } |
| 00041 } |
| 00042 |
| <a name="l00046"></a><a class="code" href="classFTList.html#a2">00046</a> size_type size()<span class="keyword"> const</span> |
| 00047 <span class="keyword"> </span>{ |
| 00048 <span class="keywordflow">return</span> listSize; |
| 00049 } |
| 00050 |
| <a name="l00054"></a><a class="code" href="classFTList.html#a3">00054</a> <span class="keywordtype">void</span> push_back( <span class="keyword">const</span> value_type& item) |
| 00055 { |
| 00056 Node* node = <span class="keyword">new</span> Node( item); |
| 00057 |
| 00058 <span class="keywordflow">if</span>( head->next == NULL) |
| 00059 { |
| 00060 head->next = node; |
| 00061 } |
| 00062 |
| 00063 <span class="keywordflow">if</span>( tail) |
| 00064 { |
| 00065 tail->next = node; |
| 00066 } |
| 00067 tail = node; |
| 00068 ++listSize; |
| 00069 } |
| 00070 |
| <a name="l00074"></a><a class="code" href="classFTList.html#a4">00074</a> reference front()<span class="keyword"> const</span> |
| 00075 <span class="keyword"> </span>{ |
| 00076 <span class="keywordflow">return</span> head->next->payload; |
| 00077 } |
| 00078 |
| <a name="l00082"></a><a class="code" href="classFTList.html#a5">00082</a> reference back()<span class="keyword"> const</span> |
| 00083 <span class="keyword"> </span>{ |
| 00084 <span class="keywordflow">return</span> tail->payload; |
| 00085 } |
| 00086 |
| 00087 <span class="keyword">private</span>: |
| 00088 <span class="keyword">struct </span>Node |
| 00089 { |
| 00090 Node() |
| 00091 : next(NULL) |
| 00092 {} |
| 00093 |
| 00094 Node( <span class="keyword">const</span> value_type& item) |
| 00095 : next(NULL) |
| 00096 { |
| 00097 payload = item; |
| 00098 } |
| 00099 |
| 00100 Node* next; |
| 00101 |
| 00102 value_type payload; |
| 00103 }; |
| 00104 |
| 00105 size_type listSize; |
| 00106 |
| 00107 Node* head; |
| 00108 Node* tail; |
| 00109 }; |
| 00110 |
| 00111 <span class="preprocessor">#endif // __FTList__</span> |
| 00112 <span class="preprocessor"></span> |
| </pre></div><hr size="1"><address style="align: right;"><small>Generated on Sun Dec 5 22:24:06 2004 for FTGL by |
| <a href="http://www.doxygen.org/index.html"> |
| <img src="doxygen.png" alt="doxygen" align="middle" border=0 > |
| </a>1.3.6 </small></address> |
| </body> |
| </html> |