Implement heap.Interface on pointer receiver
PiperOrigin-RevId: 300467253
This commit is contained in:
parent
538e35f61b
commit
ac05043525
|
@ -14,21 +14,25 @@
|
||||||
|
|
||||||
package tcp
|
package tcp
|
||||||
|
|
||||||
|
import "container/heap"
|
||||||
|
|
||||||
type segmentHeap []*segment
|
type segmentHeap []*segment
|
||||||
|
|
||||||
|
var _ heap.Interface = (*segmentHeap)(nil)
|
||||||
|
|
||||||
// Len returns the length of h.
|
// Len returns the length of h.
|
||||||
func (h segmentHeap) Len() int {
|
func (h *segmentHeap) Len() int {
|
||||||
return len(h)
|
return len(*h)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Less determines whether the i-th element of h is less than the j-th element.
|
// Less determines whether the i-th element of h is less than the j-th element.
|
||||||
func (h segmentHeap) Less(i, j int) bool {
|
func (h *segmentHeap) Less(i, j int) bool {
|
||||||
return h[i].sequenceNumber.LessThan(h[j].sequenceNumber)
|
return (*h)[i].sequenceNumber.LessThan((*h)[j].sequenceNumber)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Swap swaps the i-th and j-th elements of h.
|
// Swap swaps the i-th and j-th elements of h.
|
||||||
func (h segmentHeap) Swap(i, j int) {
|
func (h *segmentHeap) Swap(i, j int) {
|
||||||
h[i], h[j] = h[j], h[i]
|
(*h)[i], (*h)[j] = (*h)[j], (*h)[i]
|
||||||
}
|
}
|
||||||
|
|
||||||
// Push adds x as the last element of h.
|
// Push adds x as the last element of h.
|
||||||
|
|
Loading…
Reference in New Issue