github.com/MerlinKodo/quic-go@v0.39.2/internal/utils/streamframe_interval.go (about) 1 package utils 2 3 import ( 4 "fmt" 5 6 "github.com/MerlinKodo/quic-go/internal/protocol" 7 ) 8 9 // ByteInterval is an interval from one ByteCount to the other 10 type ByteInterval struct { 11 Start protocol.ByteCount 12 End protocol.ByteCount 13 } 14 15 func (i ByteInterval) Comp(v ByteInterval) int8 { 16 if i.Start < v.Start { 17 return -1 18 } 19 if i.Start > v.Start { 20 return 1 21 } 22 if i.End < v.End { 23 return -1 24 } 25 if i.End > v.End { 26 return 1 27 } 28 return 0 29 } 30 31 func (i ByteInterval) Match(n ByteInterval) int8 { 32 // check if there is an overlap 33 if i.Start <= n.End && i.End >= n.Start { 34 return 0 35 } 36 if i.Start > n.End { 37 return 1 38 } else { 39 return -1 40 } 41 } 42 43 func (i ByteInterval) String() string { 44 return fmt.Sprintf("[%d, %d]", i.Start, i.End) 45 }