Skip to content

Commit 6c8342e

Browse files
committed
Add Len and Capacity methods for ring buffer
Signed-off-by: xigang <[email protected]>
1 parent 6fe5fd8 commit 6c8342e

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+
// Capacity returns the capacity of the buffer.
80+
func (r *RingGrowing) Capacity() int {
81+
return r.n
82+
}

0 commit comments

Comments
 (0)