在双向链表(L)头部插入新结点new

/*
 * ==============================================================
 * File name:        doubly_circular_insert_head.c
 * Author:           3360652783@qq.com
 * Date created:     2026-07-24
 * Description:      Insert a new node at the head of a doubly circular linked list (with head node).
 * Copyright notice: All right Reserved
 * ==============================================================
 */

//构造在双向链表头部插入新结点的函数
bool DouLListFirNode_Insert(*L,*new){
    if( L->next == NULL ){                 //如果链表为空则直接插入
        L->next = new;
        return true;
    }
    new->next = L->next;           //链表不为空则插入成为首结点
    L->next->prev = new;
    L->next = new;
    return true;
}
posted @ 2026-07-24 13:33    阅读(2)  评论(0)    收藏  举报