AWS IoT Device SDK C: Linear Containers
Linked lists and Queues
Return to main page ↑
iot_linear_containers.h
Go to the documentation of this file.
1 /*
2  * IoT Common V1.1.0
3  * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a copy of
6  * this software and associated documentation files (the "Software"), to deal in
7  * the Software without restriction, including without limitation the rights to
8  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9  * the Software, and to permit persons to whom the Software is furnished to do so,
10  * subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be included in all
13  * copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17  * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21  */
22 
28 #ifndef IOT_LINEAR_CONTAINERS_H_
29 #define IOT_LINEAR_CONTAINERS_H_
30 
31 /* The config header is always included first. */
32 #include "iot_config.h"
33 
34 /* Standard includes. */
35 #include <stdbool.h>
36 #include <stddef.h>
37 #include <stdint.h>
38 
52 typedef struct IotLink
53 {
54  struct IotLink * pPrevious;
55  struct IotLink * pNext;
56 } IotLink_t;
57 
63 
69 
86 /* @[define_linear_containers_initializers] */
87 #define IOT_LINK_INITIALIZER { 0 }
88 #define IOT_LIST_DOUBLE_INITIALIZER IOT_LINK_INITIALIZER
89 #define IOT_DEQUEUE_INITIALIZER IOT_LINK_INITIALIZER
90 /* @[define_linear_containers_initializers] */
91 
101 #if IOT_CONTAINERS_ENABLE_ASSERTS == 1
102  #ifndef IotContainers_Assert
103  #ifdef Iot_DefaultAssert
104  #define IotContainers_Assert( expression ) Iot_DefaultAssert( expression )
105  #else
106  #error "Asserts are enabled for containers, but IotContainers_Assert is not defined"
107  #endif
108  #endif
109 #else /* if IOT_CONTAINERS_ENABLE_ASSERTS == 1 */
110  #define IotContainers_Assert( expression )
111 #endif /* if IOT_CONTAINERS_ENABLE_ASSERTS == 1 */
112 
120 #define IotLink_Container( type, pLink, linkName ) \
121  ( ( type * ) ( void * ) ( ( ( uint8_t * ) ( pLink ) ) - offsetof( type, linkName ) ) )
122 
131 #define IotContainers_ForEach( pStart, pLink ) \
132  for( ( pLink ) = ( pStart )->pNext; \
133  ( pLink ) != ( pStart ); \
134  ( pLink ) = ( pLink )->pNext )
210 /* @[declare_linear_containers_link_islinked] */
211 static inline bool IotLink_IsLinked( const IotLink_t * const pLink )
212 /* @[declare_linear_containers_link_islinked] */
213 {
214  bool isLinked = false;
215 
216  if( pLink != NULL )
217  {
218  isLinked = ( pLink->pNext != NULL ) && ( pLink->pPrevious != NULL );
219  }
220 
221  return isLinked;
222 }
223 
237 /* @[declare_linear_containers_list_double_create] */
238 static inline void IotListDouble_Create( IotListDouble_t * const pList )
239 /* @[declare_linear_containers_list_double_create] */
240 {
241  /* This function must not be called with a NULL parameter. */
242  IotContainers_Assert( pList != NULL );
243 
244  /* An empty list is a link pointing to itself. */
245  pList->pPrevious = pList;
246  pList->pNext = pList;
247 }
248 
256 /* @[declare_linear_containers_list_double_count] */
257 static inline size_t IotListDouble_Count( const IotListDouble_t * const pList )
258 /* @[declare_linear_containers_list_double_count] */
259 {
260  size_t count = 0;
261 
262  if( pList != NULL )
263  {
264  /* Get the list head. */
265  const IotLink_t * pCurrent = pList->pNext;
266 
267  /* Iterate through the list to count the elements. */
268  while( pCurrent != pList )
269  {
270  count++;
271  pCurrent = pCurrent->pNext;
272  }
273  }
274 
275  return count;
276 }
277 
285 /* @[declare_linear_containers_list_double_isempty] */
286 static inline bool IotListDouble_IsEmpty( const IotListDouble_t * const pList )
287 /* @[declare_linear_containers_list_double_isempty] */
288 {
289  /* An empty list is NULL link, or a link pointing to itself. */
290  return( ( pList == NULL ) || ( pList->pNext == pList ) );
291 }
292 
303 /* @[declare_linear_containers_list_double_peekhead] */
304 static inline IotLink_t * IotListDouble_PeekHead( const IotListDouble_t * const pList )
305 /* @[declare_linear_containers_list_double_peekhead] */
306 {
307  IotLink_t * pHead = NULL;
308 
309  if( pList != NULL )
310  {
311  if( IotListDouble_IsEmpty( pList ) == false )
312  {
313  pHead = pList->pNext;
314  }
315  }
316 
317  return pHead;
318 }
319 
330 /* @[declare_linear_containers_list_double_peektail] */
331 static inline IotLink_t * IotListDouble_PeekTail( const IotListDouble_t * const pList )
332 /* @[declare_linear_containers_list_double_peektail] */
333 {
334  IotLink_t * pTail = NULL;
335 
336  if( pList != NULL )
337  {
338  if( IotListDouble_IsEmpty( pList ) == false )
339  {
340  pTail = pList->pPrevious;
341  }
342  }
343 
344  return pTail;
345 }
346 
353 /* @[declare_linear_containers_list_double_inserthead] */
354 static inline void IotListDouble_InsertHead( IotListDouble_t * const pList,
355  IotLink_t * const pLink )
356 /* @[declare_linear_containers_list_double_inserthead] */
357 {
358  /* This function must not be called with NULL parameters. */
359  IotContainers_Assert( pList != NULL );
360  IotContainers_Assert( pLink != NULL );
361 
362  /* Save current list head. */
363  IotLink_t * pHead = pList->pNext;
364 
365  /* Place new element before list head. */
366  pLink->pNext = pHead;
367  pLink->pPrevious = pList;
369  /* Assign new list head. */
370  pHead->pPrevious = pLink;
371  pList->pNext = pLink;
372 }
373 
380 /* @[declare_linear_containers_list_double_inserttail] */
381 static inline void IotListDouble_InsertTail( IotListDouble_t * const pList,
382  IotLink_t * const pLink )
383 /* @[declare_linear_containers_list_double_inserttail] */
384 {
385  /* This function must not be called with NULL parameters. */
386  IotContainers_Assert( pList != NULL );
387  IotContainers_Assert( pLink != NULL );
388 
389  /* Save current list tail. */
390  IotLink_t * pTail = pList->pPrevious;
391 
392  pLink->pNext = pList;
393  pLink->pPrevious = pTail;
394 
395  pList->pPrevious = pLink;
396  pTail->pNext = pLink;
397 }
398 
405 /* @[declare_linear_containers_list_double_insertbefore] */
406 static inline void IotListDouble_InsertBefore( IotLink_t * const pElement,
407  IotLink_t * const pLink )
408 /* @[declare_linear_containers_list_double_insertbefore] */
409 {
410  IotListDouble_InsertTail( pElement, pLink );
411 }
412 
419 /* @[declare_linear_containers_list_double_insertafter] */
420 static inline void IotListDouble_InsertAfter( IotLink_t * const pElement,
421  IotLink_t * const pLink )
422 /* @[declare_linear_containers_list_double_insertafter] */
423 {
424  IotListDouble_InsertHead( pElement, pLink );
425 }
426 
442 /* @[declare_linear_containers_list_double_insertsorted] */
443 static inline void IotListDouble_InsertSorted( IotListDouble_t * const pList,
444  IotLink_t * const pLink,
445  int32_t ( *compare )( const IotLink_t * const pParam1, const IotLink_t * const pParam2 ) )
446 /* @[declare_linear_containers_list_double_insertsorted] */
447 {
448  /* This function must not be called with NULL parameters. */
449  IotContainers_Assert( pList != NULL );
450  IotContainers_Assert( pLink != NULL );
451  IotContainers_Assert( compare != NULL );
452 
453  /* Insert at head for empty list. */
454  if( IotListDouble_IsEmpty( pList ) == true )
455  {
456  IotListDouble_InsertHead( pList, pLink );
457  }
458  else
459  {
460  bool inserted = false;
461  IotLink_t * pCurrent = pList->pNext;
462 
463  /* Iterate through the list to find the correct position. */
464  while( pCurrent != pList )
465  {
466  /* Comparing for '<' preserves the order of insertion. */
467  if( compare( pLink, pCurrent ) < 0 )
468  {
469  IotListDouble_InsertBefore( pCurrent, pLink );
470  inserted = true;
471 
472  break;
473  }
474 
475  pCurrent = pCurrent->pNext;
476  }
477 
478  /* New element is greater than all elements in list. Insert at tail. */
479  if( inserted == false )
480  {
481  IotListDouble_InsertTail( pList, pLink );
482  }
483  }
484 }
485 
491 /* @[declare_linear_containers_list_double_remove] */
492 static inline void IotListDouble_Remove( IotLink_t * const pLink )
493 /* @[declare_linear_containers_list_double_remove] */
494 {
495  /* This function must not be called with a NULL parameter. */
496  IotContainers_Assert( pLink != NULL );
497 
498  /* This function must be called on a linked element. */
499  IotContainers_Assert( IotLink_IsLinked( pLink ) == true );
500 
501  pLink->pPrevious->pNext = pLink->pNext;
502  pLink->pNext->pPrevious = pLink->pPrevious;
503  pLink->pPrevious = NULL;
504  pLink->pNext = NULL;
505 }
506 
516 /* @[declare_linear_containers_list_double_removehead] */
517 static inline IotLink_t * IotListDouble_RemoveHead( const IotListDouble_t * const pList )
518 /* @[declare_linear_containers_list_double_removehead] */
519 {
520  IotLink_t * pHead = NULL;
521 
522  if( IotListDouble_IsEmpty( pList ) == false )
523  {
524  pHead = pList->pNext;
525  IotListDouble_Remove( pHead );
526  }
527 
528  return pHead;
529 }
530 
540 /* @[declare_linear_containers_list_double_removetail] */
541 static inline IotLink_t * IotListDouble_RemoveTail( const IotListDouble_t * const pList )
542 /* @[declare_linear_containers_list_double_removetail] */
543 {
544  IotLink_t * pTail = NULL;
545 
546  if( IotListDouble_IsEmpty( pList ) == false )
547  {
548  pTail = pList->pPrevious;
549  IotListDouble_Remove( pTail );
550  }
551 
552  return pTail;
553 }
554 
566 /* @[declare_linear_containers_list_double_removeall] */
567 static inline void IotListDouble_RemoveAll( const IotListDouble_t * const pList,
568  void ( *freeElement )( void * pData ),
569  size_t linkOffset )
570 /* @[declare_linear_containers_list_double_removeall] */
571 {
572  /* This function must not be called with a NULL pList parameter. */
573  IotContainers_Assert( pList != NULL );
574 
575  /* Get the list head. */
576  IotLink_t * pCurrent = pList->pNext;
578  /* Iterate through the list and remove all elements. */
579  while( pCurrent != pList )
580  {
581  /* Save a pointer to the next list element. */
582  IotLink_t * pNext = pCurrent->pNext;
583 
584  /* Remove and free the current list element. */
585  IotListDouble_Remove( pCurrent );
586 
587  if( freeElement != NULL )
588  {
589  freeElement( ( ( uint8_t * ) pCurrent ) - linkOffset );
590  }
591 
592  /* Move the iterating pointer to the next list element. */
593  pCurrent = pNext;
594  }
595 }
596 
617 /* @[declare_linear_containers_list_double_findfirstmatch] */
618 static inline IotLink_t * IotListDouble_FindFirstMatch( const IotListDouble_t * const pList,
619  const IotLink_t * const pStartPoint,
620  bool ( *isMatch )( const IotLink_t * const pOperationLink, void * pCompare ),
621  void * pMatch )
622 /* @[declare_linear_containers_list_double_findfirstmatch] */
623 {
624  /* The const must be cast away to match this function's return value. Nevertheless,
625  * this function will respect the const-ness of pStartPoint. */
626  /* coverity[misra_c_2012_rule_11_8_violation] */
627  IotLink_t * pCurrent = ( IotLink_t * ) pStartPoint, * pMatchedLink = NULL;
628  bool matchFound = false;
629 
630  /* This function must not be called with a NULL pList parameter. */
631  IotContainers_Assert( pList != NULL );
632 
633  /* Search starting from list head if no start point is given. */
634  if( pStartPoint == NULL )
635  {
636  pCurrent = pList->pNext;
637  }
638 
639  /* Iterate through the list to search for matches. */
640  while( pCurrent != pList )
641  {
642  /* Call isMatch if provided. Otherwise, compare pointers. */
643  if( isMatch != NULL )
644  {
645  matchFound = isMatch( pCurrent, pMatch );
646  }
647  else
648  {
649  matchFound = ( pCurrent == pMatch );
650  }
651 
652  if( matchFound == true )
653  {
654  pMatchedLink = pCurrent;
655  break;
656  }
657 
658  pCurrent = pCurrent->pNext;
659  }
660 
661  /* Return match if found, else NULL. */
662  return pMatchedLink;
663 }
664 
685 /* @[declare_linear_containers_list_double_removefirstmatch] */
686 static inline IotLink_t * IotListDouble_RemoveFirstMatch( const IotListDouble_t * const pList,
687  const IotLink_t * const pStartPoint,
688  bool ( *isMatch )( const IotLink_t * const pOperationLink, void * pCompare ),
689  void * pMatch )
690 /* @[declare_linear_containers_list_double_removefirstmatch] */
691 {
692  IotLink_t * pMatchedElement = IotListDouble_FindFirstMatch( pList,
693  pStartPoint,
694  isMatch,
695  pMatch );
696 
697  if( pMatchedElement != NULL )
698  {
699  IotListDouble_Remove( pMatchedElement );
700  }
701 
702  return pMatchedElement;
703 }
704 
721 /* @[declare_linear_containers_list_double_removeallmatches] */
722 static inline void IotListDouble_RemoveAllMatches( const IotListDouble_t * const pList,
723  bool ( *isMatch )( const IotLink_t * const pOperationLink, void * pCompare ),
724  void * pMatch,
725  void ( *freeElement )( void * pData ),
726  size_t linkOffset )
727 /* @[declare_linear_containers_list_double_removeallmatches] */
728 {
729  IotLink_t * pMatchedElement = NULL, * pNextElement = NULL;
730 
731  /* Search the list for all matching elements. */
732  do
733  {
734  pMatchedElement = IotListDouble_FindFirstMatch( pList,
735  pMatchedElement,
736  isMatch,
737  pMatch );
738 
739  if( pMatchedElement != NULL )
740  {
741  /* Save pointer to next element. */
742  pNextElement = pMatchedElement->pNext;
743 
744  /* Match found; remove and free. */
745  IotListDouble_Remove( pMatchedElement );
746 
747  if( freeElement != NULL )
748  {
749  freeElement( ( ( uint8_t * ) pMatchedElement ) - linkOffset );
750  }
751 
752  /* Continue search from next element. */
753  pMatchedElement = pNextElement;
754  }
755  } while( pMatchedElement != NULL );
756 }
757 
769 /* @[declare_linear_containers_queue_create] */
770 static inline void IotDeQueue_Create( IotDeQueue_t * const pQueue )
771 /* @[declare_linear_containers_queue_create] */
772 {
773  IotListDouble_Create( pQueue );
774 }
783 /* @[declare_linear_containers_queue_count] */
784 static inline size_t IotDeQueue_Count( const IotDeQueue_t * const pQueue )
785 /* @[declare_linear_containers_queue_count] */
786 {
787  return IotListDouble_Count( pQueue );
788 }
789 
798 /* @[declare_linear_containers_queue_isempty] */
799 static inline bool IotDeQueue_IsEmpty( const IotDeQueue_t * const pQueue )
800 /* @[declare_linear_containers_queue_isempty] */
801 {
802  return IotListDouble_IsEmpty( pQueue );
803 }
804 
815 /* @[declare_linear_containers_queue_peekhead] */
816 static inline IotLink_t * IotDeQueue_PeekHead( const IotDeQueue_t * const pQueue )
817 /* @[declare_linear_containers_queue_peekhead] */
818 {
819  return IotListDouble_PeekHead( pQueue );
820 }
821 
832 /* @[declare_linear_containers_queue_peektail] */
833 static inline IotLink_t * IotDeQueue_PeekTail( const IotDeQueue_t * const pQueue )
834 /* @[declare_linear_containers_queue_peektail] */
835 {
836  return IotListDouble_PeekTail( pQueue );
837 }
838 
845 /* @[declare_linear_containers_queue_enqueuehead] */
846 static inline void IotDeQueue_EnqueueHead( IotDeQueue_t * const pQueue,
847  IotLink_t * const pLink )
848 /* @[declare_linear_containers_queue_enqueuehead] */
849 {
850  IotListDouble_InsertHead( pQueue, pLink );
851 }
852 
862 /* @[declare_linear_containers_queue_dequeuehead] */
863 static inline IotLink_t * IotDeQueue_DequeueHead( const IotDeQueue_t * const pQueue )
864 /* @[declare_linear_containers_queue_dequeuehead] */
865 {
866  return IotListDouble_RemoveHead( pQueue );
867 }
868 
875 /* @[declare_linear_containers_queue_enqueuetail] */
876 static inline void IotDeQueue_EnqueueTail( IotDeQueue_t * const pQueue,
877  IotLink_t * const pLink )
878 /* @[declare_linear_containers_queue_enqueuetail] */
879 {
880  IotListDouble_InsertTail( pQueue, pLink );
881 }
882 
892 /* @[declare_linear_containers_queue_dequeuetail] */
893 static inline IotLink_t * IotDeQueue_DequeueTail( const IotDeQueue_t * const pQueue )
894 /* @[declare_linear_containers_queue_dequeuetail] */
895 {
896  return IotListDouble_RemoveTail( pQueue );
897 }
898 
904 /* @[declare_linear_containers_queue_remove] */
905 static inline void IotDeQueue_Remove( IotLink_t * const pLink )
906 /* @[declare_linear_containers_queue_remove] */
907 {
908  IotListDouble_Remove( pLink );
909 }
910 
922 /* @[declare_linear_containers_queue_removeall] */
923 static inline void IotDeQueue_RemoveAll( const IotDeQueue_t * const pQueue,
924  void ( * freeElement )( void * pData ),
925  size_t linkOffset )
926 /* @[declare_linear_containers_queue_removeall] */
927 {
928  IotListDouble_RemoveAll( pQueue, freeElement, linkOffset );
929 }
930 
947 /* @[declare_linear_containers_queue_removeallmatches] */
948 static inline void IotDeQueue_RemoveAllMatches( const IotDeQueue_t * const pQueue,
949  bool ( * isMatch )( const IotLink_t * const pOperationLink, void * pCompare ),
950  void * pMatch,
951  void ( * freeElement )( void * pData ),
952  size_t linkOffset )
953 /* @[declare_linear_containers_queue_removeallmatches] */
954 {
955  IotListDouble_RemoveAllMatches( pQueue, isMatch, pMatch, freeElement, linkOffset );
956 }
957 
958 #endif /* IOT_LINEAR_CONTAINERS_H_ */
static void IotDeQueue_Remove(IotLink_t *const pLink)
Remove a single element from a queue.
Definition: iot_linear_containers.h:1062
static IotLink_t * IotDeQueue_PeekHead(const IotDeQueue_t *const pQueue)
Return an IotLink_t representing the element at the front of the queue without removing it...
Definition: iot_linear_containers.h:973
static IotLink_t * IotListDouble_RemoveFirstMatch(const IotListDouble_t *const pList, const IotLink_t *const pStartPoint, bool(*isMatch)(const IotLink_t *const pOperationLink, void *pCompare), void *pMatch)
Search a doubly-linked list for the first matching element and remove it.
Definition: iot_linear_containers.h:843
static bool IotListDouble_IsEmpty(const IotListDouble_t *const pList)
Check if a doubly-linked list is empty.
Definition: iot_linear_containers.h:443
static IotLink_t * IotListDouble_FindFirstMatch(const IotListDouble_t *const pList, const IotLink_t *const pStartPoint, bool(*isMatch)(const IotLink_t *const pOperationLink, void *pCompare), void *pMatch)
Search a doubly-linked list for the first matching element.
Definition: iot_linear_containers.h:775
static void IotListDouble_InsertBefore(IotLink_t *const pElement, IotLink_t *const pLink)
Insert an element before another element in a doubly-linked list.
Definition: iot_linear_containers.h:563
static void IotDeQueue_EnqueueTail(IotDeQueue_t *const pQueue, IotLink_t *const pLink)
Add an element at the tail of the queue.
Definition: iot_linear_containers.h:1033
static IotLink_t * IotListDouble_PeekHead(const IotListDouble_t *const pList)
Return an IotLink_t representing the first element in a doubly-linked list without removing it...
Definition: iot_linear_containers.h:461
static void IotListDouble_RemoveAll(const IotListDouble_t *const pList, void(*freeElement)(void *pData), size_t linkOffset)
Remove all elements in a doubly-linked list.
Definition: iot_linear_containers.h:724
IotLink_t IotDeQueue_t
Represents a queue.
Definition: iot_linear_containers.h:68
static IotLink_t * IotListDouble_RemoveTail(const IotListDouble_t *const pList)
Remove the element at the tail of a doubly-linked list.
Definition: iot_linear_containers.h:698
static size_t IotListDouble_Count(const IotListDouble_t *const pList)
Return the number of elements contained in an IotListDouble_t.
Definition: iot_linear_containers.h:414
static void IotListDouble_InsertAfter(IotLink_t *const pElement, IotLink_t *const pLink)
Insert an element after another element in a doubly-linked list.
Definition: iot_linear_containers.h:577
static size_t IotDeQueue_Count(const IotDeQueue_t *const pQueue)
Return the number of elements contained in an IotDeQueue_t.
Definition: iot_linear_containers.h:941
static void IotDeQueue_EnqueueHead(IotDeQueue_t *const pQueue, IotLink_t *const pLink)
Add an element at the head of the queue.
Definition: iot_linear_containers.h:1003
static void IotListDouble_RemoveAllMatches(const IotListDouble_t *const pList, bool(*isMatch)(const IotLink_t *const pOperationLink, void *pCompare), void *pMatch, void(*freeElement)(void *pData), size_t linkOffset)
Remove all matching elements from a doubly-linked list.
Definition: iot_linear_containers.h:879
#define IotContainers_Assert(expression)
Assertion macro for the linear containers library.
Definition: iot_linear_containers.h:114
static IotLink_t * IotDeQueue_DequeueHead(const IotDeQueue_t *const pQueue)
Remove an element at the head of the queue.
Definition: iot_linear_containers.h:1020
static IotLink_t * IotListDouble_RemoveHead(const IotListDouble_t *const pList)
Remove the element at the head of a doubly-linked list.
Definition: iot_linear_containers.h:674
static IotLink_t * IotListDouble_PeekTail(const IotListDouble_t *const pList)
Return an IotLink_t representing the last element in a doubly-linked list without removing it...
Definition: iot_linear_containers.h:488
static void IotDeQueue_Create(IotDeQueue_t *const pQueue)
Create a new queue.
Definition: iot_linear_containers.h:927
static void IotListDouble_InsertHead(IotListDouble_t *const pList, IotLink_t *const pLink)
Insert an element at the head of a doubly-linked list.
Definition: iot_linear_containers.h:511
static IotLink_t * IotDeQueue_PeekTail(const IotDeQueue_t *const pQueue)
Return an IotLink_t representing the element at the back of the queue without removing it...
Definition: iot_linear_containers.h:990
static void IotListDouble_Create(IotListDouble_t *const pList)
Create a new doubly-linked list.
Definition: iot_linear_containers.h:395
static IotLink_t * IotDeQueue_DequeueTail(const IotDeQueue_t *const pQueue)
Remove an element at the tail of the queue.
Definition: iot_linear_containers.h:1050
static bool IotLink_IsLinked(const IotLink_t *const pLink)
Check if an IotLink_t is linked in a list or queue.
Definition: iot_linear_containers.h:368
static void IotListDouble_InsertTail(IotListDouble_t *const pList, IotLink_t *const pLink)
Insert an element at the tail of a doubly-linked list.
Definition: iot_linear_containers.h:538
IotLink_t IotListDouble_t
Represents a doubly-linked list.
Definition: iot_linear_containers.h:62
static void IotDeQueue_RemoveAllMatches(const IotDeQueue_t *const pQueue, bool(*isMatch)(const IotLink_t *const pOperationLink, void *pCompare), void *pMatch, void(*freeElement)(void *pData), size_t linkOffset)
Remove all matching elements from a queue.
Definition: iot_linear_containers.h:1105
static void IotListDouble_Remove(IotLink_t *const pLink)
Remove a single element from a doubly-linked list.
Definition: iot_linear_containers.h:649
static void IotListDouble_InsertSorted(IotListDouble_t *const pList, IotLink_t *const pLink, int32_t(*compare)(const IotLink_t *const pParam1, const IotLink_t *const pParam2))
Insert an element in a sorted doubly-linked list.
Definition: iot_linear_containers.h:600
static void IotDeQueue_RemoveAll(const IotDeQueue_t *const pQueue, void(*freeElement)(void *pData), size_t linkOffset)
Remove all elements in a queue.
Definition: iot_linear_containers.h:1080
static bool IotDeQueue_IsEmpty(const IotDeQueue_t *const pQueue)
Check if a queue is empty.
Definition: iot_linear_containers.h:956