初始化链表

双向循环队列,头尾相连

LIST_ENTRY *
EFIAPI
InitializeListHead (
  IN OUT  LIST_ENTRY                *ListHead
  )

{
  ASSERT (ListHead != NULL);

  ListHead->ForwardLink = ListHead;
  ListHead->BackLink = ListHead;
  return ListHead;
}

插入数据元素

从头部插入数据元素

LIST_ENTRY *
EFIAPI
InsertHeadList (
  IN OUT  LIST_ENTRY                *ListHead,
  IN OUT  LIST_ENTRY                *Entry
  )
{
  //
  // ASSERT List not too long and Entry is not one of the nodes of List
  //
  ASSERT_VERIFY_NODE_IN_VALID_LIST (ListHead, Entry, FALSE);
  
 1 Entry->ForwardLink = ListHead->ForwardLink;
 2 Entry->BackLink = ListHead;
 3 Entry->ForwardLink->BackLink = Entry;
 4 ListHead->ForwardLink = Entry;
  return ListHead;
}

在这里插入图片描述

![在这里插入图片描述](https://img-blog.csdnimg.cn/e5cb16172ffc44bc923759df471dcfe1.png?x-oss-process=image/watermark,type_ZHJvaWRzYW5zZmFsbGJhY2s,shadow_50,text_Q1NETiBAQWxpeF9zeg==,size_20,color_FFFFFF,t_70,g_se,x_16

从尾部插入数据元素

LIST_ENTRY *
EFIAPI
InsertTailList (
  IN OUT  LIST_ENTRY                *ListHead,
  IN OUT  LIST_ENTRY                *Entry
  )
{
  //
  // ASSERT List not too long and Entry is not one of the nodes of List
  //
  ASSERT_VERIFY_NODE_IN_VALID_LIST (ListHead, Entry, FALSE);
  
 1 Entry->ForwardLink = ListHead;
 2 Entry->BackLink = ListHead->BackLink;
 3 Entry->BackLink->ForwardLink = Entry;
 4 ListHead->BackLink = Entry;
  return ListHead;
}

在这里插入图片描述

Logo

CSDN联合极客时间,共同打造面向开发者的精品内容学习社区,助力成长!

更多推荐