00001 /* Orx - Portable Game Engine 00002 * 00003 * Copyright (c) 2008-2011 Orx-Project 00004 * 00005 * This software is provided 'as-is', without any express or implied 00006 * warranty. In no event will the authors be held liable for any damages 00007 * arising from the use of this software. 00008 * 00009 * Permission is granted to anyone to use this software for any purpose, 00010 * including commercial applications, and to alter it and redistribute it 00011 * freely, subject to the following restrictions: 00012 * 00013 * 1. The origin of this software must not be misrepresented; you must not 00014 * claim that you wrote the original software. If you use this software 00015 * in a product, an acknowledgment in the product documentation would be 00016 * appreciated but is not required. 00017 * 00018 * 2. Altered source versions must be plainly marked as such, and must not be 00019 * misrepresented as being the original software. 00020 * 00021 * 3. This notice may not be removed or altered from any source 00022 * distribution. 00023 */ 00024 00083 #ifndef _orxLINKLIST_H_ 00084 #define _orxLINKLIST_H_ 00085 00086 00087 #include "orxInclude.h" 00088 00089 #include "debug/orxDebug.h" 00090 00091 00094 typedef struct __orxLINKLIST_NODE_t 00095 { 00096 struct __orxLINKLIST_NODE_t *pstNext; 00097 struct __orxLINKLIST_NODE_t *pstPrevious; 00098 struct __orxLINKLIST_t *pstList; 00100 } orxLINKLIST_NODE; 00101 00104 typedef struct __orxLINKLIST_t 00105 { 00106 orxLINKLIST_NODE *pstFirst; 00107 orxLINKLIST_NODE *pstLast; 00108 orxU32 u32Counter; 00110 } orxLINKLIST; 00111 00112 00117 extern orxDLLAPI orxSTATUS orxFASTCALL orxLinkList_Clean(orxLINKLIST *_pstList); 00118 00119 00125 extern orxDLLAPI orxSTATUS orxFASTCALL orxLinkList_AddStart(orxLINKLIST *_pstList, orxLINKLIST_NODE *_pstNode); 00126 00132 extern orxDLLAPI orxSTATUS orxFASTCALL orxLinkList_AddEnd(orxLINKLIST *_pstList, orxLINKLIST_NODE *_pstNode); 00133 00139 extern orxDLLAPI orxSTATUS orxFASTCALL orxLinkList_AddBefore(orxLINKLIST_NODE *_pstRefNode, orxLINKLIST_NODE *_pstNode); 00140 00146 extern orxDLLAPI orxSTATUS orxFASTCALL orxLinkList_AddAfter(orxLINKLIST_NODE *_pstRefNode, orxLINKLIST_NODE *_pstNode); 00147 00152 extern orxDLLAPI orxSTATUS orxFASTCALL orxLinkList_Remove(orxLINKLIST_NODE *_pstNode); 00153 00154 00155 /* *** LinkList inlined accessors *** */ 00156 00157 00162 static orxINLINE orxLINKLIST * orxLinkList_GetList(const orxLINKLIST_NODE *_pstNode) 00163 { 00164 /* Checks */ 00165 orxASSERT(_pstNode != orxNULL); 00166 00167 /* Returns it */ 00168 return(_pstNode->pstList); 00169 } 00170 00175 static orxINLINE orxLINKLIST_NODE * orxLinkList_GetPrevious(const orxLINKLIST_NODE *_pstNode) 00176 { 00177 /* Checks */ 00178 orxASSERT(_pstNode != orxNULL); 00179 00180 /* Returns it */ 00181 return((_pstNode->pstList != orxNULL) ? _pstNode->pstPrevious : (orxLINKLIST_NODE *)orxNULL); 00182 } 00183 00188 static orxINLINE orxLINKLIST_NODE * orxLinkList_GetNext(const orxLINKLIST_NODE *_pstNode) 00189 { 00190 /* Checks */ 00191 orxASSERT(_pstNode != orxNULL); 00192 00193 /* Returns it */ 00194 return((_pstNode->pstList != orxNULL) ? _pstNode->pstNext : (orxLINKLIST_NODE *)orxNULL); 00195 } 00196 00197 00202 static orxINLINE orxLINKLIST_NODE * orxLinkList_GetFirst(const orxLINKLIST *_pstList) 00203 { 00204 /* Checks */ 00205 orxASSERT(_pstList != orxNULL); 00206 00207 /* Returns it */ 00208 return(_pstList->pstFirst); 00209 } 00210 00215 static orxINLINE orxLINKLIST_NODE * orxLinkList_GetLast(const orxLINKLIST *_pstList) 00216 { 00217 /* Checks */ 00218 orxASSERT(_pstList != orxNULL); 00219 00220 /* Returns it */ 00221 return(_pstList->pstLast); 00222 } 00223 00228 static orxINLINE orxU32 orxLinkList_GetCounter(const orxLINKLIST *_pstList) 00229 { 00230 /* Checks */ 00231 orxASSERT(_pstList != orxNULL); 00232 00233 /* Returns it */ 00234 return(_pstList->u32Counter); 00235 } 00236 00237 #endif /* _orxLINKLIST_H_ */ 00238
1.5.6