Skip to content

Commit 1f6e0b7

Browse files
authoredMar 21, 2025··
Merge pull request #321 from xigang/ring_growing
Add Len and Capacity methods for ring buffer
2 parents 24370be + 336e707 commit 1f6e0b7

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed
 

‎buffer/ring_growing.go

+10
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,13 @@ func (r *RingGrowing) WriteOne(data interface{}) {
7070
r.data[(r.readable+r.beg)%r.n] = data
7171
r.readable++
7272
}
73+
74+
// Len returns the number of items in the buffer.
75+
func (r *RingGrowing) Len() int {
76+
return r.readable
77+
}
78+
79+
// Cap returns the capacity of the buffer.
80+
func (r *RingGrowing) Cap() int {
81+
return r.n
82+
}

0 commit comments

Comments
 (0)
Please sign in to comment.