> For the complete documentation index, see [llms.txt](https://wskdsgcf.gitbook.io/mastering-go-zh-cn/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://wskdsgcf.gitbook.io/mastering-go-zh-cn/05.0/05.9.md).

# 05.9 container 包

在这一节中，我会介绍 Go 语言标准库 `container` 的用法。`container` 包支持三种数据结构：`heap`、`list` 和 `ring`。`container/heap`、`container/list` 和 `container/ring` 分别实现了这些数据结构。

有的人可能对环不太熟悉，环就是一个**循环链表**，也就是说环上的最后一个元素中的指针指向环上的第一个元素。从根本上来说，这意味着环上的每个节点都是平等的，并且没有开头和结尾。因此，从环上任一元素开始都能遍历整个环。

后面的三个小节将分别详细介绍 `container` 包中的每一个包。有个合理的建议：你应该先判断 Go 语言标准库 `container` 的功能是否满足你的需求，如果满足再加以使用，否则你应该使用自己实现的数据结构。
