Skip to content

ListNode

Description

Doubly-linked list node

Fields

Name Description
next Reference to next node. NULL if no next node exists (tail).
prev Reference to previous node. NULL if no previous node exists (head).
data Type specific pointer to data.

Usage example (Cross-references)

Usage examples (Cross-references)
        GenericListNode *rel_f2  = ListNodeRelative(ListNodeBegin(&list), 2);
        GenericListNode *rel_b2  = ListNodeRelative(ListNodeEnd(&list), -2);
        ListNode(int) *null_node = NULL;
    
        bool result = node1 && ListNodeData(node1) && (*(int *)ListNodeData(node1) == 20);
    
    static bool test_list_node_type_layout(void) {
        WriteFmt("Testing ListNode type layout\n");
    
        int value          = 42;
    
        int value          = 42;
        ListNode(int) node = {0};
        // intentional bypass: building a node literal on the stack and reading its
        // fields directly to verify the ListNode(T) layout. The list-managed
    /// TAGS: List, Type, TypeOf
    ///
    #define LIST_NODE_TYPE(list) ListNode(LIST_DATA_TYPE(list))
    
    ///
    #define List(T)                                                                                                        \
        struct {                                                                                                           \
            ListNode(T) * head;                                                                                            \
            ListNode(T) * tail;                                                                                            \
            GenericCopyInit   copy_init;                                                                                   \
        struct {                                                                                                           \
            ListNode(T) * head;                                                                                            \
            ListNode(T) * tail;                                                                                            \
            GenericCopyInit   copy_init;                                                                                   \
            GenericCopyDeinit copy_deinit;                                                                                 \
Last updated on