Debian Codegraph @

list_at.go

raw symbols SCIP
1 package buffer
2
3 import "math"
4
5 // ListAt is a slice of BufferAt's, it's the backing for NewPartitionAt
6 type ListAt []BufferAt
7
8 // Len is the sum of the Len()'s of the BufferAt's in the list.
9 func (l *ListAt) 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 BufferAt's in the list.
20 func (l *ListAt) 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 BufferAt's in the list.
31 func (l *ListAt) Reset() {
32 for _, buffer := range *l {
33 buffer.Reset()
34 }
35 }
36
37 // Push adds a BufferAt to the end of the list
38 func (l *ListAt) Push(b BufferAt) {
39 *l = append(*l, b)
40 }
41
42 // Pop removes and returns a BufferAt from the front of the list
43 func (l *ListAt) Pop() (b BufferAt) {
44 b = (*l)[0]
45 *l = (*l)[1:]
46 return b
47 }