# 循环列表

循环链表是指链表的头部和尾部之间存在相互引用，形成了一个循环。

## 单向循环链表

![](/files/-Lxe9moRBwFG-13UHysq)

单向循环链表的实现方法和单向链表几乎一样，但在增加和头部和尾部节点的时候需要注意设置`current.next = this.head`，篇幅所限这里不再累述。

## 双向循环链表

![](/files/-Lxe9u1DwSWIcDuiEswZ)

双向循环链表的实现方法和双向链表也大同小异，这里也不再累述。

链表是 js 中没有原声实现的一种数据结构，相比数组，链表在添加和移除元素的时候效率更高。因此在需要添加和移除大批量元素的时候，最好的选择就是链表。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://mm.ricky.moe/algorithm/algorithm-and-data-structure/shu-ju-jie-gou/lian-biao/xun-huan-lie-biao.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
