CDI SDK
SDK for transporting chunks of data reliably and with low latency using a polled mode network driver.
|
This file defines all the methods required for a singly linked list. A tail pointer is provided in order to enable use as a FIFO. The implementation is not thread safe. Its simplicity keeps it efficient for O(1) complexity. More...
#include <assert.h>
#include <stdbool.h>
#include <stddef.h>
Go to the source code of this file.
Data Structures | |
struct | CdiSinglyLinkedListEntry |
This structure represents a single list entry. More... | |
struct | CdiSinglyLinkedList |
This structure represents a list. More... | |
Typedefs | |
typedef struct CdiSinglyLinkedListEntry | CdiSinglyLinkedListEntry |
Forward declaration to create pointer to singly linked list entry when used. | |
Functions | |
static void | CdiSinglyLinkedListInit (CdiSinglyLinkedList *list_ptr) |
static void | CdiSinglyLinkedListPushHead (CdiSinglyLinkedList *list_ptr, CdiSinglyLinkedListEntry *new_entry_ptr) |
static void | CdiSinglyLinkedListPushTail (CdiSinglyLinkedList *list_ptr, CdiSinglyLinkedListEntry *new_entry_ptr) |
static CdiSinglyLinkedListEntry * | CdiSinglyLinkedListPopHead (CdiSinglyLinkedList *list_ptr) |
static bool | CdiSinglyLinkedListIsEmpty (const CdiSinglyLinkedList *list_ptr) |
static int | CdiSinglyLinkedListSize (const CdiSinglyLinkedList *list_ptr) |
static CdiSinglyLinkedListEntry * | CdiSinglyLinkedListGetHead (const CdiSinglyLinkedList *list_ptr) |
static CdiSinglyLinkedListEntry * | CdiSinglyLinkedListNextEntry (const CdiSinglyLinkedListEntry *entry_ptr) |
This file defines all the methods required for a singly linked list. A tail pointer is provided in order to enable use as a FIFO. The implementation is not thread safe. Its simplicity keeps it efficient for O(1) complexity.
empty list: head_ptr -> NULL tail_ptr -> NULL
single item in list: +-------—+ head_ptr -> | next_ptr | -> NULL +-------—+ ^ tail_ptr ------—+
larger list: +-------—+ +-------—+ +-------—+ head_ptr -> | next_ptr | -> | next_ptr | -> ... -> | next_ptr | -> NULL +-------—+ +-------—+ +-------—+ ^ tail_ptr ---------------------------------------------—+
|
inlinestatic |
Provides a pointer to the head entry of a given list.
list_ptr | Pointer to the list to get the head entry ptr. |
|
inlinestatic |
Initialize a list. Doesn't need to be inline, since it is only used once for each instance of the list.
list_ptr | Pointer to instance of the list. |
|
inlinestatic |
Check if the list is empty.
list_ptr | Pointer to instance of the list. |
|
inlinestatic |
Provides a pointer to the next entry of a list entry.
entry_ptr | Pointer to an entry on a list. |
|
inlinestatic |
Pop an item off the head of the list, removing it from the list.
list_ptr | Pointer to instance of the list. |
|
inlinestatic |
Add a new entry to the head of the list.
list_ptr | Pointer to instance of the list. |
new_entry_ptr | Pointer to new entry to add to the list. |
|
inlinestatic |
Add a new entry to the tail of the list.
list_ptr | Pointer to instance of the list. |
new_entry_ptr | Pointer to new entry to add to the list. |
|
inlinestatic |
Report the number of entries currently in the list.
list_ptr | Address of the list whose size is of interest. |