Debian Codegraph @

list.go

raw symbols SCIP
1 package buffer
2
3 import "math"
4
5 // List is a slice of Buffers, it's the backing for NewPartition
6 type List []Buffer
7
8 // Len is the sum of the Len()'s of the Buffers in the List.
9 func (l *List) Len() (n int64) {
10 for _, buffer := range *l {
11 if n > math.MaxInt64-buffer.Len() {
12 return math.MaxInt64
13 }
14 n += buffer.Len()
15 }
16 return n
17 }
18
19 // Cap is the sum of the Cap()'s of the Buffers in the List.
20 func (l *List) Cap() (n int64) {
21 for _, buffer := range *l {
22 if n > math.MaxInt64-buffer.Cap() {
23 return math.MaxInt64
24 }
25 n += buffer.Cap()
26 }
27 return n
28 }
29
30 // Reset calls Reset() on each of the Buffers in the list.
31 func (l *List) Reset() {
32 for _, buffer := range *l {
33 buffer.Reset()
34 }
35 }
36
37 // Push adds a Buffer to the end of the List
38 func (l *List) Push(b Buffer) {
39 *l = append(*l, b)
40 }
41
42 // Pop removes and returns a Buffer from the front of the List
43 func (l *List) Pop() (b Buffer) {
44 b = (*l)[0]
45 *l = (*l)[1:]
46 return b
47 }