Linear Containers API Reference
Linked lists and Queues
iot_linear_containers.h
Go to the documentation of this file.
1 /*
2  * IoT Common V1.1.1
3  * Copyright (C) 2020 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  IotLink_t * pCurrent = ( IotLink_t * ) pStartPoint, * pMatchedLink = NULL;
627  bool matchFound = false;
628 
629  /* This function must not be called with a NULL pList parameter. */
630  IotContainers_Assert( pList != NULL );
631 
632  /* Search starting from list head if no start point is given. */
633  if( pStartPoint == NULL )
634  {
635  pCurrent = pList->pNext;
636  }
637 
638  /* Iterate through the list to search for matches. */
639  while( pCurrent != pList )
640  {
641  /* Call isMatch if provided. Otherwise, compare pointers. */
642  if( isMatch != NULL )
643  {
644  matchFound = isMatch( pCurrent, pMatch );
645  }
646  else
647  {
648  matchFound = ( pCurrent == pMatch );
649  }
650 
651  if( matchFound == true )
652  {
653  pMatchedLink = pCurrent;
654  break;
655  }
656 
657  pCurrent = pCurrent->pNext;
658  }
659 
660  /* Return match if found, else NULL. */
661  return pMatchedLink;
662 }
663 
684 /* @[declare_linear_containers_list_double_removefirstmatch] */
685 static inline IotLink_t * IotListDouble_RemoveFirstMatch( const IotListDouble_t * const pList,
686  const IotLink_t * const pStartPoint,
687  bool ( * isMatch )( const IotLink_t * const pOperationLink, void * pCompare ),
688  void * pMatch )
689 /* @[declare_linear_containers_list_double_removefirstmatch] */
690 {
691  IotLink_t * pMatchedElement = IotListDouble_FindFirstMatch( pList,
692  pStartPoint,
693  isMatch,
694  pMatch );
695 
696  if( pMatchedElement != NULL )
697  {
698  IotListDouble_Remove( pMatchedElement );
699  }
700 
701  return pMatchedElement;
702 }
703 
720 /* @[declare_linear_containers_list_double_removeallmatches] */
721 static inline void IotListDouble_RemoveAllMatches( const IotListDouble_t * const pList,
722  bool ( * isMatch )( const IotLink_t * const pOperationLink, void * pCompare ),
723  void * pMatch,
724  void ( * freeElement )( void * pData ),
725  size_t linkOffset )
726 /* @[declare_linear_containers_list_double_removeallmatches] */
727 {
728  IotLink_t * pMatchedElement = NULL, * pNextElement = NULL;
729 
730  /* Search the list for all matching elements. */
731  do
732  {
733  pMatchedElement = IotListDouble_FindFirstMatch( pList,
734  pMatchedElement,
735  isMatch,
736  pMatch );
737 
738  if( pMatchedElement != NULL )
739  {
740  /* Save pointer to next element. */
741  pNextElement = pMatchedElement->pNext;
742 
743  /* Match found; remove and free. */
744  IotListDouble_Remove( pMatchedElement );
745 
746  if( freeElement != NULL )
747  {
748  freeElement( ( ( uint8_t * ) pMatchedElement ) - linkOffset );
749  }
750 
751  /* Continue search from next element. */
752  pMatchedElement = pNextElement;
753  }
754  } while( pMatchedElement != NULL );
755 }
756 
768 /* @[declare_linear_containers_queue_create] */
769 static inline void IotDeQueue_Create( IotDeQueue_t * const pQueue )
770 /* @[declare_linear_containers_queue_create] */
771 {
772  IotListDouble_Create( pQueue );
773 }
774 
782 /* @[declare_linear_containers_queue_count] */
783 static inline size_t IotDeQueue_Count( const IotDeQueue_t * const pQueue )
784 /* @[declare_linear_containers_queue_count] */
785 {
786  return IotListDouble_Count( pQueue );
787 }
788 
797 /* @[declare_linear_containers_queue_isempty] */
798 static inline bool IotDeQueue_IsEmpty( const IotDeQueue_t * const pQueue )
799 /* @[declare_linear_containers_queue_isempty] */
800 {
801  return IotListDouble_IsEmpty( pQueue );
802 }
803 
814 /* @[declare_linear_containers_queue_peekhead] */
815 static inline IotLink_t * IotDeQueue_PeekHead( const IotDeQueue_t * const pQueue )
816 /* @[declare_linear_containers_queue_peekhead] */
817 {
818  return IotListDouble_PeekHead( pQueue );
819 }
820 
831 /* @[declare_linear_containers_queue_peektail] */
832 static inline IotLink_t * IotDeQueue_PeekTail( const IotDeQueue_t * const pQueue )
833 /* @[declare_linear_containers_queue_peektail] */
834 {
835  return IotListDouble_PeekTail( pQueue );
836 }
837 
844 /* @[declare_linear_containers_queue_enqueuehead] */
845 static inline void IotDeQueue_EnqueueHead( IotDeQueue_t * const pQueue,
846  IotLink_t * const pLink )
847 /* @[declare_linear_containers_queue_enqueuehead] */
848 {
849  IotListDouble_InsertHead( pQueue, pLink );
850 }
851 
861 /* @[declare_linear_containers_queue_dequeuehead] */
862 static inline IotLink_t * IotDeQueue_DequeueHead( const IotDeQueue_t * const pQueue )
863 /* @[declare_linear_containers_queue_dequeuehead] */
864 {
865  return IotListDouble_RemoveHead( pQueue );
866 }
867 
874 /* @[declare_linear_containers_queue_enqueuetail] */
875 static inline void IotDeQueue_EnqueueTail( IotDeQueue_t * const pQueue,
876  IotLink_t * const pLink )
877 /* @[declare_linear_containers_queue_enqueuetail] */
878 {
879  IotListDouble_InsertTail( pQueue, pLink );
880 }
881 
891 /* @[declare_linear_containers_queue_dequeuetail] */
892 static inline IotLink_t * IotDeQueue_DequeueTail( const IotDeQueue_t * const pQueue )
893 /* @[declare_linear_containers_queue_dequeuetail] */
894 {
895  return IotListDouble_RemoveTail( pQueue );
896 }
897 
903 /* @[declare_linear_containers_queue_remove] */
904 static inline void IotDeQueue_Remove( IotLink_t * const pLink )
905 /* @[declare_linear_containers_queue_remove] */
906 {
907  IotListDouble_Remove( pLink );
908 }
909 
921 /* @[declare_linear_containers_queue_removeall] */
922 static inline void IotDeQueue_RemoveAll( const IotDeQueue_t * const pQueue,
923  void ( * freeElement )( void * pData ),
924  size_t linkOffset )
925 /* @[declare_linear_containers_queue_removeall] */
926 {
927  IotListDouble_RemoveAll( pQueue, freeElement, linkOffset );
928 }
929 
946 /* @[declare_linear_containers_queue_removeallmatches] */
947 static inline void IotDeQueue_RemoveAllMatches( const IotDeQueue_t * const pQueue,
948  bool ( * isMatch )( const IotLink_t * const pOperationLink, void * pCompare ),
949  void * pMatch,
950  void ( * freeElement )( void * pData ),
951  size_t linkOffset )
952 /* @[declare_linear_containers_queue_removeallmatches] */
953 {
954  IotListDouble_RemoveAllMatches( pQueue, isMatch, pMatch, freeElement, linkOffset );
955 }
956 
957 #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:1061
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:972
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:842
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:1032
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:940
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:1002
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:878
#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:1019
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:926
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:989
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:1049
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:1104
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:1079
static bool IotDeQueue_IsEmpty(const IotDeQueue_t *const pQueue)
Check if a queue is empty.
Definition: iot_linear_containers.h:955