关于go:go源码阅读-containerring

一、介绍
ring是一个首尾相连的list,源码位于 src/container/ring/ring.go
其中每一个元素的定义如下:

// A Ring is an element of a circular list, or ring.
// Rings do not have a beginning or end; a pointer to any ring element
// serves as reference to the entire ring. Empty rings are represented
// as nil Ring pointers. The zero value for a Ring is a one-element
// ring with a nil Value.
//
type Ring struct {
    next, prev *Ring
    Value      interface{} // for use by client; untouched by this library
}

通过New办法能够创立一个特定大小的ring,例如:

r := ring.New(5)

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理