\hypertarget{xblnklst_8h_source}{}\doxysection{xblnklst.\+h}
\label{xblnklst_8h_source}\index{/mnt/1Tdata/xbase/xbase64-\/4.1.4/src/include/xblnklst.h@{/mnt/1Tdata/xbase/xbase64-\/4.1.4/src/include/xblnklst.h}}
\mbox{\hyperlink{xblnklst_8h}{Go to the documentation of this file.}}
\begin{DoxyCode}{0}
\DoxyCodeLine{1 \textcolor{comment}{/*  xblnklst.h}}
\DoxyCodeLine{2 \textcolor{comment}{}}
\DoxyCodeLine{3 \textcolor{comment}{XBase64 Software Library}}
\DoxyCodeLine{4 \textcolor{comment}{}}
\DoxyCodeLine{5 \textcolor{comment}{Copyright (c) 1997,2003,2014,2022 Gary A Kunkel}}
\DoxyCodeLine{6 \textcolor{comment}{}}
\DoxyCodeLine{7 \textcolor{comment}{The xb64 software library is covered under the terms of the GPL Version 3, 2007 license.}}
\DoxyCodeLine{8 \textcolor{comment}{}}
\DoxyCodeLine{9 \textcolor{comment}{Email Contact:}}
\DoxyCodeLine{10 \textcolor{comment}{}}
\DoxyCodeLine{11 \textcolor{comment}{    XDB-\/devel@lists.sourceforge.net}}
\DoxyCodeLine{12 \textcolor{comment}{    XDB-\/users@lists.sourceforge.net}}
\DoxyCodeLine{13 \textcolor{comment}{}}
\DoxyCodeLine{14 \textcolor{comment}{*/}}
\DoxyCodeLine{15 }
\DoxyCodeLine{16 }
\DoxyCodeLine{17 \textcolor{preprocessor}{\#ifndef \_\_XB\_XBLNKLST\_H\_\_}}
\DoxyCodeLine{18 \textcolor{preprocessor}{\#define \_\_XB\_XBLNKLST\_H\_\_}}
\DoxyCodeLine{19 }
\DoxyCodeLine{20 \textcolor{preprocessor}{\#ifdef XB\_LINKLIST\_SUPPORT}}
\DoxyCodeLine{21 }
\DoxyCodeLine{22 \textcolor{keyword}{namespace }\mbox{\hyperlink{namespacexb}{xb}}\{}
\DoxyCodeLine{23 }
\DoxyCodeLine{24 }
\DoxyCodeLine{25 \textcolor{keyword}{template}<\textcolor{keyword}{class} xbNodeType>}
\DoxyCodeLine{26 \textcolor{keyword}{class }XBDLLEXPORT xbLinkList \{}
\DoxyCodeLine{27   \textcolor{keyword}{public}:}
\DoxyCodeLine{28    xbLinkList();}
\DoxyCodeLine{29    \string~xbLinkList();}
\DoxyCodeLine{30 }
\DoxyCodeLine{31    xbLinkListNode<xbNodeType> *GetHeadNode() \textcolor{keyword}{const};}
\DoxyCodeLine{32    xbLinkListNode<xbNodeType> *GetEndNode() \textcolor{keyword}{const};}
\DoxyCodeLine{33    xbLinkListNode<xbNodeType> *GetNodeForNo( xbUInt32 ulNodeNo ) \textcolor{keyword}{const};}
\DoxyCodeLine{34 }
\DoxyCodeLine{35    \textcolor{keywordtype}{void}        Clear();}
\DoxyCodeLine{36    xbUInt32    GetNodeCnt     () \textcolor{keyword}{const};}
\DoxyCodeLine{37    xbInt16     InsertAtEnd    ( \textcolor{keyword}{const} xbNodeType \&xbLLN );}
\DoxyCodeLine{38    xbInt16     InsertAtFront  ( \textcolor{keyword}{const} xbNodeType \&xbLLN );}
\DoxyCodeLine{39    xbInt16     RemoveByVal    ( \textcolor{keyword}{const} xbNodeType \&xbLLN );}
\DoxyCodeLine{40    xbInt16     RemoveFromEnd  ();}
\DoxyCodeLine{41    xbInt16     RemoveFromEnd  ( xbNodeType \&xbLLN );}
\DoxyCodeLine{42    xbInt16     RemoveFromFront( xbNodeType \&xbLLN );}
\DoxyCodeLine{43    xbInt16     SearchFor      ( \textcolor{keyword}{const} xbNodeType \&xbLLN );}
\DoxyCodeLine{44 }
\DoxyCodeLine{45   \textcolor{keyword}{private}:}
\DoxyCodeLine{46    xbUInt32 ulNodeCnt;}
\DoxyCodeLine{47    xbLinkListNode<xbNodeType> *llStartPtr;}
\DoxyCodeLine{48    xbLinkListNode<xbNodeType> *llEndPtr;}
\DoxyCodeLine{49 \};}
\DoxyCodeLine{50 }
\DoxyCodeLine{51 \textcolor{keyword}{template}<\textcolor{keyword}{class} xbNodeType>}
\DoxyCodeLine{52 xbLinkList<xbNodeType>::xbLinkList()\{}
\DoxyCodeLine{53   ulNodeCnt  = 0;}
\DoxyCodeLine{54   llStartPtr = NULL;}
\DoxyCodeLine{55   llEndPtr   = NULL;}
\DoxyCodeLine{56 \}}
\DoxyCodeLine{57 }
\DoxyCodeLine{58 \textcolor{keyword}{template}<\textcolor{keyword}{class} xbNodeType>}
\DoxyCodeLine{59 xbLinkList<xbNodeType>::\string~xbLinkList()\{}
\DoxyCodeLine{60   Clear();}
\DoxyCodeLine{61 \}}
\DoxyCodeLine{62 }
\DoxyCodeLine{63 \textcolor{keyword}{template}<\textcolor{keyword}{class} xbNodeType>}
\DoxyCodeLine{64 \textcolor{keywordtype}{void} xbLinkList<xbNodeType>::Clear()\{}
\DoxyCodeLine{65   xbLinkListNode<xbNodeType> *cPtr = llStartPtr, *tPtr;}
\DoxyCodeLine{66   \textcolor{keywordflow}{for}( xbUInt32 i = 0; i < ulNodeCnt; i++ )\{}
\DoxyCodeLine{67     tPtr = cPtr;}
\DoxyCodeLine{68     cPtr = cPtr-\/>GetNextNode();}
\DoxyCodeLine{69     \textcolor{keyword}{delete} tPtr;}
\DoxyCodeLine{70   \}}
\DoxyCodeLine{71   ulNodeCnt  = 0;}
\DoxyCodeLine{72   llStartPtr = NULL;}
\DoxyCodeLine{73   llEndPtr   = NULL;}
\DoxyCodeLine{74 \}}
\DoxyCodeLine{75 }
\DoxyCodeLine{76 }
\DoxyCodeLine{77 \textcolor{keyword}{template}<\textcolor{keyword}{class} xbNodeType>}
\DoxyCodeLine{78 xbLinkListNode<xbNodeType> *xbLinkList<xbNodeType>::GetHeadNode()\textcolor{keyword}{ const}\{}
\DoxyCodeLine{79   \textcolor{keywordflow}{return} llStartPtr;}
\DoxyCodeLine{80 \}}
\DoxyCodeLine{81 }
\DoxyCodeLine{82 \textcolor{keyword}{template}<\textcolor{keyword}{class} xbNodeType>}
\DoxyCodeLine{83 xbLinkListNode<xbNodeType> *xbLinkList<xbNodeType>::GetEndNode()\textcolor{keyword}{ const}\{}
\DoxyCodeLine{84   \textcolor{keywordflow}{return} llEndPtr;}
\DoxyCodeLine{85 \}}
\DoxyCodeLine{86 }
\DoxyCodeLine{87 }
\DoxyCodeLine{88 \textcolor{keyword}{template}<\textcolor{keyword}{class} xbNodeType>}
\DoxyCodeLine{89 xbLinkListNode<xbNodeType> *xbLinkList<xbNodeType>::GetNodeForNo( xbUInt32 ulNo )\textcolor{keyword}{ const}\{}
\DoxyCodeLine{90 }
\DoxyCodeLine{91   xbLinkListNode<xbNodeType> *cPtr = llStartPtr;}
\DoxyCodeLine{92   xbUInt32 i;}
\DoxyCodeLine{93   \textcolor{keywordflow}{for}( i = 0; i < ulNo \&\& i < ulNodeCnt; i++ )}
\DoxyCodeLine{94     cPtr = cPtr-\/>GetNextNode();}
\DoxyCodeLine{95 }
\DoxyCodeLine{96   \textcolor{keywordflow}{if}( i == ulNo )}
\DoxyCodeLine{97     \textcolor{keywordflow}{return} cPtr;}
\DoxyCodeLine{98   \textcolor{keywordflow}{else} }
\DoxyCodeLine{99     \textcolor{keywordflow}{return} 0;}
\DoxyCodeLine{100 \}}
\DoxyCodeLine{101 }
\DoxyCodeLine{102 }
\DoxyCodeLine{103 }
\DoxyCodeLine{104 \textcolor{keyword}{template}<\textcolor{keyword}{class} xbNodeType>}
\DoxyCodeLine{105 xbUInt32 xbLinkList<xbNodeType>::GetNodeCnt()\textcolor{keyword}{ const}\{}
\DoxyCodeLine{106   \textcolor{keywordflow}{return} ulNodeCnt;}
\DoxyCodeLine{107 \}}
\DoxyCodeLine{108 }
\DoxyCodeLine{109 \textcolor{keyword}{template}<\textcolor{keyword}{class} xbNodeType>}
\DoxyCodeLine{110 xbInt16 xbLinkList<xbNodeType>::InsertAtFront( \textcolor{keyword}{const} xbNodeType \& ntKey )\{}
\DoxyCodeLine{111 }
\DoxyCodeLine{112   xbLinkListNode<xbNodeType> *p = \textcolor{keyword}{new} xbLinkListNode<xbNodeType>( ntKey );}
\DoxyCodeLine{113   \textcolor{keywordflow}{if}( p == 0 )}
\DoxyCodeLine{114     \textcolor{keywordflow}{return} \mbox{\hyperlink{xbretcod_8h_ae687fc7d872ba0475a8477e4447f9b54}{XB\_NO\_MEMORY}};}
\DoxyCodeLine{115 }
\DoxyCodeLine{116   \textcolor{keywordflow}{if}( ulNodeCnt > 0 )\{}
\DoxyCodeLine{117     llStartPtr-\/>SetPrevNode( p );}
\DoxyCodeLine{118     p-\/>SetNextNode( llStartPtr );}
\DoxyCodeLine{119   \} \textcolor{keywordflow}{else} \{}
\DoxyCodeLine{120     llEndPtr = p;}
\DoxyCodeLine{121   \}}
\DoxyCodeLine{122 }
\DoxyCodeLine{123   llStartPtr = p;}
\DoxyCodeLine{124   ulNodeCnt++;}
\DoxyCodeLine{125   \textcolor{keywordflow}{return} \mbox{\hyperlink{xbretcod_8h_ac720d5b4ec45bfd606f5865d40816e23}{XB\_NO\_ERROR}};}
\DoxyCodeLine{126 \}}
\DoxyCodeLine{127 }
\DoxyCodeLine{128 \textcolor{keyword}{template}<\textcolor{keyword}{class} xbNodeType>}
\DoxyCodeLine{129 xbInt16 xbLinkList<xbNodeType>::InsertAtEnd( \textcolor{keyword}{const} xbNodeType \& ntKey )\{}
\DoxyCodeLine{130 }
\DoxyCodeLine{131   xbLinkListNode<xbNodeType> *p = \textcolor{keyword}{new} xbLinkListNode<xbNodeType>( ntKey );}
\DoxyCodeLine{132   \textcolor{keywordflow}{if}( p == 0 )}
\DoxyCodeLine{133     \textcolor{keywordflow}{return} \mbox{\hyperlink{xbretcod_8h_ae687fc7d872ba0475a8477e4447f9b54}{XB\_NO\_MEMORY}};}
\DoxyCodeLine{134 }
\DoxyCodeLine{135   \textcolor{keywordflow}{if}( ulNodeCnt > 0 )\{}
\DoxyCodeLine{136     llEndPtr-\/>SetNextNode( p );}
\DoxyCodeLine{137     p-\/>SetPrevNode( llEndPtr );}
\DoxyCodeLine{138     llEndPtr = p;}
\DoxyCodeLine{139   \} \textcolor{keywordflow}{else} \{}
\DoxyCodeLine{140     llStartPtr = p;}
\DoxyCodeLine{141   \}}
\DoxyCodeLine{142 }
\DoxyCodeLine{143   llEndPtr = p;}
\DoxyCodeLine{144   ulNodeCnt++;}
\DoxyCodeLine{145   \textcolor{keywordflow}{return} \mbox{\hyperlink{xbretcod_8h_ac720d5b4ec45bfd606f5865d40816e23}{XB\_NO\_ERROR}};}
\DoxyCodeLine{146 \}}
\DoxyCodeLine{147 }
\DoxyCodeLine{148 }
\DoxyCodeLine{149 }
\DoxyCodeLine{150 \textcolor{keyword}{template}<\textcolor{keyword}{class} xbNodeType>}
\DoxyCodeLine{151 xbInt16 xbLinkList<xbNodeType>::RemoveByVal( \textcolor{keyword}{const} xbNodeType \& ntKey )\{}
\DoxyCodeLine{152   \textcolor{comment}{// Remove the first instance of ntKey from the node chain}}
\DoxyCodeLine{153   xbLinkListNode<xbNodeType> *currPtr = llStartPtr;}
\DoxyCodeLine{154   xbLinkListNode<xbNodeType> *prevPtr = NULL;}
\DoxyCodeLine{155 }
\DoxyCodeLine{156   \textcolor{keywordflow}{for}( xbUInt32 i = 0; i < ulNodeCnt; i++ )\{}
\DoxyCodeLine{157     \textcolor{keywordflow}{if}( currPtr-\/>GetKey() == ntKey )\{}
\DoxyCodeLine{158       \textcolor{keywordflow}{if}( prevPtr == NULL )\{                   \textcolor{comment}{//then this is the first node}}
\DoxyCodeLine{159         llStartPtr = currPtr-\/>GetNextNode();}
\DoxyCodeLine{160         \textcolor{keywordflow}{if}( llStartPtr )                      \textcolor{comment}{// if more than one link in the linked list}}
\DoxyCodeLine{161           llStartPtr-\/>SetPrevNode( NULL );}
\DoxyCodeLine{162         \textcolor{keyword}{delete} currPtr;}
\DoxyCodeLine{163         ulNodeCnt-\/-\/;}
\DoxyCodeLine{164         \textcolor{keywordflow}{return} i + 1;}
\DoxyCodeLine{165       \}}
\DoxyCodeLine{166       \textcolor{keywordflow}{else} \{}
\DoxyCodeLine{167         prevPtr-\/>SetNextNode( currPtr-\/>GetNextNode());}
\DoxyCodeLine{168         \textcolor{keywordflow}{if}( currPtr-\/>GetNextNode())}
\DoxyCodeLine{169           currPtr-\/>GetNextNode()-\/>SetPrevNode( prevPtr );}
\DoxyCodeLine{170         \textcolor{keyword}{delete} currPtr;}
\DoxyCodeLine{171         ulNodeCnt-\/-\/;}
\DoxyCodeLine{172         \textcolor{keywordflow}{return} i + 1;}
\DoxyCodeLine{173       \}}
\DoxyCodeLine{174     \}}
\DoxyCodeLine{175     prevPtr = currPtr;}
\DoxyCodeLine{176     currPtr = currPtr-\/>GetNextNode();}
\DoxyCodeLine{177   \}}
\DoxyCodeLine{178   \textcolor{keywordflow}{return} \mbox{\hyperlink{xbretcod_8h_ac2606659a54111334f5b02861e533700}{XB\_NOT\_FOUND}};}
\DoxyCodeLine{179 \}}
\DoxyCodeLine{180 }
\DoxyCodeLine{181 }
\DoxyCodeLine{182 \textcolor{keyword}{template}<\textcolor{keyword}{class} xbNodeType>}
\DoxyCodeLine{183 xbInt16 xbLinkList<xbNodeType>::RemoveFromFront( xbNodeType \& ntKey )\{}
\DoxyCodeLine{184 }
\DoxyCodeLine{185   \textcolor{keywordflow}{if}( ulNodeCnt <= 0 )}
\DoxyCodeLine{186     \textcolor{keywordflow}{return} \mbox{\hyperlink{xbretcod_8h_a13e6876470bd34c8c4e5533f115e04eb}{XB\_INVALID\_NODELINK}};}
\DoxyCodeLine{187   xbLinkListNode<xbNodeType> *p = llStartPtr;}
\DoxyCodeLine{188   llStartPtr = p-\/>GetNextNode();}
\DoxyCodeLine{189   \textcolor{keywordflow}{if}( llStartPtr )}
\DoxyCodeLine{190     llStartPtr-\/>SetPrevNode( NULL );}
\DoxyCodeLine{191   ntKey = p-\/>GetKey();}
\DoxyCodeLine{192   \textcolor{keyword}{delete} p;}
\DoxyCodeLine{193   ulNodeCnt-\/-\/;}
\DoxyCodeLine{194   \textcolor{keywordflow}{return} \mbox{\hyperlink{xbretcod_8h_ac720d5b4ec45bfd606f5865d40816e23}{XB\_NO\_ERROR}};}
\DoxyCodeLine{195 \}}
\DoxyCodeLine{196 }
\DoxyCodeLine{197 }
\DoxyCodeLine{198 \textcolor{keyword}{template}<\textcolor{keyword}{class} xbNodeType>}
\DoxyCodeLine{199 xbInt16 xbLinkList<xbNodeType>::RemoveFromEnd( xbNodeType \& ntKey )\{}
\DoxyCodeLine{200 }
\DoxyCodeLine{201   \textcolor{keywordflow}{if}( ulNodeCnt <= 0 )}
\DoxyCodeLine{202     \textcolor{keywordflow}{return} \mbox{\hyperlink{xbretcod_8h_a13e6876470bd34c8c4e5533f115e04eb}{XB\_INVALID\_NODELINK}};}
\DoxyCodeLine{203   xbLinkListNode<xbNodeType> *p = llEndPtr;}
\DoxyCodeLine{204   \textcolor{keywordflow}{if}( p-\/>GetPrevNode())\{}
\DoxyCodeLine{205     llEndPtr = p-\/>GetPrevNode();}
\DoxyCodeLine{206     llEndPtr-\/>SetNextNode( NULL );}
\DoxyCodeLine{207   \} \textcolor{keywordflow}{else} \{}
\DoxyCodeLine{208     \textcolor{comment}{// there are no more nodes}}
\DoxyCodeLine{209     llStartPtr = NULL;}
\DoxyCodeLine{210     llEndPtr   = NULL;}
\DoxyCodeLine{211   \}}
\DoxyCodeLine{212   ntKey = p-\/>GetKey();}
\DoxyCodeLine{213   \textcolor{keyword}{delete} p;}
\DoxyCodeLine{214   ulNodeCnt-\/-\/;}
\DoxyCodeLine{215   \textcolor{keywordflow}{return} \mbox{\hyperlink{xbretcod_8h_ac720d5b4ec45bfd606f5865d40816e23}{XB\_NO\_ERROR}};}
\DoxyCodeLine{216 \}}
\DoxyCodeLine{217 }
\DoxyCodeLine{218 }
\DoxyCodeLine{219 \textcolor{keyword}{template}<\textcolor{keyword}{class} xbNodeType>}
\DoxyCodeLine{220 xbInt16 xbLinkList<xbNodeType>::RemoveFromEnd()\{}
\DoxyCodeLine{221 }
\DoxyCodeLine{222   \textcolor{keywordflow}{if}( ulNodeCnt <= 0 )}
\DoxyCodeLine{223     \textcolor{keywordflow}{return} \mbox{\hyperlink{xbretcod_8h_a13e6876470bd34c8c4e5533f115e04eb}{XB\_INVALID\_NODELINK}};}
\DoxyCodeLine{224   xbLinkListNode<xbNodeType> *p = llEndPtr;}
\DoxyCodeLine{225   \textcolor{keywordflow}{if}( p-\/>GetPrevNode())\{}
\DoxyCodeLine{226     llEndPtr = p-\/>GetPrevNode();}
\DoxyCodeLine{227     llEndPtr-\/>SetNextNode( NULL );}
\DoxyCodeLine{228   \} \textcolor{keywordflow}{else} \{}
\DoxyCodeLine{229     \textcolor{comment}{// there are no more nodes}}
\DoxyCodeLine{230     llStartPtr = NULL;}
\DoxyCodeLine{231     llEndPtr   = NULL;}
\DoxyCodeLine{232   \}}
\DoxyCodeLine{233   \textcolor{keyword}{delete} p-\/>GetKey();}
\DoxyCodeLine{234   \textcolor{keyword}{delete} p;}
\DoxyCodeLine{235   ulNodeCnt-\/-\/;}
\DoxyCodeLine{236   \textcolor{keywordflow}{return} \mbox{\hyperlink{xbretcod_8h_ac720d5b4ec45bfd606f5865d40816e23}{XB\_NO\_ERROR}};}
\DoxyCodeLine{237 \}}
\DoxyCodeLine{238 }
\DoxyCodeLine{239 }
\DoxyCodeLine{240 \textcolor{keyword}{template}<\textcolor{keyword}{class} xbNodeType>}
\DoxyCodeLine{241 xbInt16 xbLinkList<xbNodeType>::SearchFor( \textcolor{keyword}{const} xbNodeType \& ntKey )\{}
\DoxyCodeLine{242 }
\DoxyCodeLine{243   xbLinkListNode<xbNodeType> *cPtr = llStartPtr;}
\DoxyCodeLine{244   \textcolor{keywordflow}{for}( xbUInt32 i = 0; i < ulNodeCnt; i++ )\{}
\DoxyCodeLine{245     \textcolor{keywordflow}{if}( cPtr-\/>GetKey() == ntKey )}
\DoxyCodeLine{246       \textcolor{keywordflow}{return} i+1;}
\DoxyCodeLine{247     cPtr = cPtr-\/>GetNextNode();}
\DoxyCodeLine{248   \}}
\DoxyCodeLine{249   \textcolor{keywordflow}{return} \mbox{\hyperlink{xbretcod_8h_ac720d5b4ec45bfd606f5865d40816e23}{XB\_NO\_ERROR}};}
\DoxyCodeLine{250 }
\DoxyCodeLine{251 \}}
\DoxyCodeLine{252 \}               \textcolor{comment}{// namespace}}
\DoxyCodeLine{253 }
\DoxyCodeLine{254 \textcolor{preprocessor}{\#endif          }\textcolor{comment}{// XB\_LINKLIST\_SUPPORT}}
\DoxyCodeLine{255 \textcolor{preprocessor}{\#endif          }\textcolor{comment}{// XB\_XBLNKLST\_H\_\_}}
\DoxyCodeLine{256 }
\DoxyCodeLine{257 }

\end{DoxyCode}
