le_doublyLinkedList.h
Go to the documentation of this file.
1 
181 #ifndef LEGATO_DOUBLY_LINKED_LIST_INCLUDE_GUARD
182 #define LEGATO_DOUBLY_LINKED_LIST_INCLUDE_GUARD
183 
184 
185 //--------------------------------------------------------------------------------------------------
194 //--------------------------------------------------------------------------------------------------
195 typedef struct le_dls_Link
196 {
197  struct le_dls_Link* nextPtr;
198  struct le_dls_Link* prevPtr;
199 }
201 
202 
203 //--------------------------------------------------------------------------------------------------
210 //--------------------------------------------------------------------------------------------------
211 typedef struct
212 {
214 }
216 
217 
218 //--------------------------------------------------------------------------------------------------
223 //--------------------------------------------------------------------------------------------------
224 #define LE_DLS_LIST_INIT (le_dls_List_t){NULL}
225 
226 
227 //--------------------------------------------------------------------------------------------------
232 //--------------------------------------------------------------------------------------------------
233 #define LE_DLS_LINK_INIT (le_dls_Link_t){NULL, NULL}
234 
235 
236 //--------------------------------------------------------------------------------------------------
240 //--------------------------------------------------------------------------------------------------
241 void le_dls_Stack
242 (
243  le_dls_List_t* listPtr,
244  le_dls_Link_t* newLinkPtr
245 );
246 
247 
248 //--------------------------------------------------------------------------------------------------
252 //--------------------------------------------------------------------------------------------------
253 void le_dls_Queue
254 (
255  le_dls_List_t* listPtr,
256  le_dls_Link_t* newLinkPtr
257 );
258 
259 
260 //--------------------------------------------------------------------------------------------------
265 //--------------------------------------------------------------------------------------------------
266 void le_dls_AddAfter
267 (
268  le_dls_List_t* listPtr,
269  le_dls_Link_t* currentLinkPtr,
270  le_dls_Link_t* newLinkPtr
271 );
272 
273 
274 //--------------------------------------------------------------------------------------------------
279 //--------------------------------------------------------------------------------------------------
280 void le_dls_AddBefore
281 (
282  le_dls_List_t* listPtr,
283  le_dls_Link_t* currentLinkPtr,
284  le_dls_Link_t* newLinkPtr
285 );
286 
287 
288 //--------------------------------------------------------------------------------------------------
296 //--------------------------------------------------------------------------------------------------
298 (
299  le_dls_List_t* listPtr
300 );
301 
302 
303 //--------------------------------------------------------------------------------------------------
311 //--------------------------------------------------------------------------------------------------
313 (
314  le_dls_List_t* listPtr
315 );
316 
317 
318 //--------------------------------------------------------------------------------------------------
323 //--------------------------------------------------------------------------------------------------
324 void le_dls_Remove
325 (
326  le_dls_List_t* listPtr,
327  le_dls_Link_t* linkToRemovePtr
328 );
329 
330 
331 //--------------------------------------------------------------------------------------------------
339 //--------------------------------------------------------------------------------------------------
341 (
342  const le_dls_List_t* listPtr
343 );
344 
345 
346 //--------------------------------------------------------------------------------------------------
354 //--------------------------------------------------------------------------------------------------
356 (
357  const le_dls_List_t* listPtr
358 );
359 
360 
361 //--------------------------------------------------------------------------------------------------
368 //--------------------------------------------------------------------------------------------------
369 static inline bool le_dls_IsEmpty
370 (
371  const le_dls_List_t* listPtr
372 )
373 //--------------------------------------------------------------------------------------------------
374 {
375  return (le_dls_Peek(listPtr) == NULL);
376 }
377 
378 
379 //--------------------------------------------------------------------------------------------------
390 //--------------------------------------------------------------------------------------------------
392 (
393  const le_dls_List_t* listPtr,
394  const le_dls_Link_t* currentLinkPtr
395 );
396 
397 
398 //--------------------------------------------------------------------------------------------------
408 //--------------------------------------------------------------------------------------------------
410 (
411  const le_dls_List_t* listPtr,
412  const le_dls_Link_t* currentLinkPtr
413 );
414 
415 
416 //--------------------------------------------------------------------------------------------------
421 //--------------------------------------------------------------------------------------------------
422 void le_dls_Swap
423 (
424  le_dls_List_t* listPtr,
425  le_dls_Link_t* linkPtr,
426  le_dls_Link_t* otherLinkPtr
427 );
428 
429 
430 //--------------------------------------------------------------------------------------------------
438 //--------------------------------------------------------------------------------------------------
439 bool le_dls_IsInList
440 (
441  const le_dls_List_t* listPtr,
442  const le_dls_Link_t* linkPtr
443 );
444 
445 
446 //--------------------------------------------------------------------------------------------------
454 //--------------------------------------------------------------------------------------------------
455 static inline bool le_dls_IsHead
456 (
457  const le_dls_List_t* listPtr,
458  const le_dls_Link_t* linkPtr
459 )
460 {
461  return (le_dls_Peek(listPtr) == linkPtr);
462 }
463 
464 
465 //--------------------------------------------------------------------------------------------------
473 //--------------------------------------------------------------------------------------------------
474 static inline bool le_dls_IsTail
475 (
476  const le_dls_List_t* listPtr,
477  const le_dls_Link_t* linkPtr
478 )
479 {
480  return (le_dls_PeekTail(listPtr) == linkPtr);
481 }
482 
483 
484 //--------------------------------------------------------------------------------------------------
491 //--------------------------------------------------------------------------------------------------
492 size_t le_dls_NumLinks
493 (
494  const le_dls_List_t* listPtr
495 );
496 
497 
498 //--------------------------------------------------------------------------------------------------
506 //--------------------------------------------------------------------------------------------------
508 (
509  const le_dls_List_t* listPtr
510 );
511 
512 #endif // LEGATO_DOUBLY_LINKED_LIST_INCLUDE_GUARD
513 
void le_dls_AddAfter(le_dls_List_t *listPtr, le_dls_Link_t *currentLinkPtr, le_dls_Link_t *newLinkPtr)
le_dls_Link_t * le_dls_PeekTail(const le_dls_List_t *listPtr)
static bool le_dls_IsHead(const le_dls_List_t *listPtr, const le_dls_Link_t *linkPtr)
Definition: le_doublyLinkedList.h:456
le_dls_Link_t * le_dls_PeekPrev(const le_dls_List_t *listPtr, const le_dls_Link_t *currentLinkPtr)
bool le_dls_IsListCorrupted(const le_dls_List_t *listPtr)
void le_dls_AddBefore(le_dls_List_t *listPtr, le_dls_Link_t *currentLinkPtr, le_dls_Link_t *newLinkPtr)
void le_dls_Queue(le_dls_List_t *listPtr, le_dls_Link_t *newLinkPtr)
le_dls_Link_t * le_dls_PopTail(le_dls_List_t *listPtr)
Definition: le_doublyLinkedList.h:211
le_dls_Link_t * le_dls_Pop(le_dls_List_t *listPtr)
void le_dls_Stack(le_dls_List_t *listPtr, le_dls_Link_t *newLinkPtr)
le_dls_Link_t * headLinkPtr
Link to list head.
Definition: le_doublyLinkedList.h:213
bool le_dls_IsInList(const le_dls_List_t *listPtr, const le_dls_Link_t *linkPtr)
size_t le_dls_NumLinks(const le_dls_List_t *listPtr)
void le_dls_Swap(le_dls_List_t *listPtr, le_dls_Link_t *linkPtr, le_dls_Link_t *otherLinkPtr)
le_dls_Link_t * le_dls_Peek(const le_dls_List_t *listPtr)
static bool le_dls_IsEmpty(const le_dls_List_t *listPtr)
Definition: le_doublyLinkedList.h:370
le_dls_Link_t * le_dls_PeekNext(const le_dls_List_t *listPtr, const le_dls_Link_t *currentLinkPtr)
static bool le_dls_IsTail(const le_dls_List_t *listPtr, const le_dls_Link_t *linkPtr)
Definition: le_doublyLinkedList.h:475
void le_dls_Remove(le_dls_List_t *listPtr, le_dls_Link_t *linkToRemovePtr)