Skip to content

Commit cc348a6

Browse files
georgehaofjl
andauthored
common/prque: fix godoc comments (#29460)
Co-authored-by: Felix Lange <[email protected]>
1 parent 4458905 commit cc348a6

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

common/prque/prque.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222
"container/heap"
2323
)
2424

25-
// Priority queue data structure.
25+
// Prque is a priority queue data structure.
2626
type Prque[P cmp.Ordered, V any] struct {
2727
cont *sstack[P, V]
2828
}
@@ -32,7 +32,7 @@ func New[P cmp.Ordered, V any](setIndex SetIndexCallback[V]) *Prque[P, V] {
3232
return &Prque[P, V]{newSstack[P, V](setIndex)}
3333
}
3434

35-
// Pushes a value with a given priority into the queue, expanding if necessary.
35+
// Push a value with a given priority into the queue, expanding if necessary.
3636
func (p *Prque[P, V]) Push(data V, priority P) {
3737
heap.Push(p.cont, &item[P, V]{data, priority})
3838
}
@@ -43,14 +43,14 @@ func (p *Prque[P, V]) Peek() (V, P) {
4343
return item.value, item.priority
4444
}
4545

46-
// Pops the value with the greatest priority off the stack and returns it.
46+
// Pop the value with the greatest priority off the stack and returns it.
4747
// Currently no shrinking is done.
4848
func (p *Prque[P, V]) Pop() (V, P) {
4949
item := heap.Pop(p.cont).(*item[P, V])
5050
return item.value, item.priority
5151
}
5252

53-
// Pops only the item from the queue, dropping the associated priority value.
53+
// PopItem pops only the item from the queue, dropping the associated priority value.
5454
func (p *Prque[P, V]) PopItem() V {
5555
return heap.Pop(p.cont).(*item[P, V]).value
5656
}
@@ -60,17 +60,17 @@ func (p *Prque[P, V]) Remove(i int) V {
6060
return heap.Remove(p.cont, i).(*item[P, V]).value
6161
}
6262

63-
// Checks whether the priority queue is empty.
63+
// Empty checks whether the priority queue is empty.
6464
func (p *Prque[P, V]) Empty() bool {
6565
return p.cont.Len() == 0
6666
}
6767

68-
// Returns the number of element in the priority queue.
68+
// Size returns the number of element in the priority queue.
6969
func (p *Prque[P, V]) Size() int {
7070
return p.cont.Len()
7171
}
7272

73-
// Clears the contents of the priority queue.
73+
// Reset clears the contents of the priority queue.
7474
func (p *Prque[P, V]) Reset() {
7575
*p = *New[P, V](p.cont.setIndex)
7676
}

common/prque/sstack.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func newSstack[P cmp.Ordered, V any](setIndex SetIndexCallback[V]) *sstack[P, V]
4949
return result
5050
}
5151

52-
// Pushes a value onto the stack, expanding it if necessary. Required by
52+
// Push a value onto the stack, expanding it if necessary. Required by
5353
// heap.Interface.
5454
func (s *sstack[P, V]) Push(data any) {
5555
if s.size == s.capacity {
@@ -69,7 +69,7 @@ func (s *sstack[P, V]) Push(data any) {
6969
s.size++
7070
}
7171

72-
// Pops a value off the stack and returns it. Currently no shrinking is done.
72+
// Pop a value off the stack and returns it. Currently no shrinking is done.
7373
// Required by heap.Interface.
7474
func (s *sstack[P, V]) Pop() (res any) {
7575
s.size--
@@ -85,18 +85,18 @@ func (s *sstack[P, V]) Pop() (res any) {
8585
return
8686
}
8787

88-
// Returns the length of the stack. Required by sort.Interface.
88+
// Len returns the length of the stack. Required by sort.Interface.
8989
func (s *sstack[P, V]) Len() int {
9090
return s.size
9191
}
9292

93-
// Compares the priority of two elements of the stack (higher is first).
93+
// Less compares the priority of two elements of the stack (higher is first).
9494
// Required by sort.Interface.
9595
func (s *sstack[P, V]) Less(i, j int) bool {
9696
return s.blocks[i/blockSize][i%blockSize].priority > s.blocks[j/blockSize][j%blockSize].priority
9797
}
9898

99-
// Swaps two elements in the stack. Required by sort.Interface.
99+
// Swap two elements in the stack. Required by sort.Interface.
100100
func (s *sstack[P, V]) Swap(i, j int) {
101101
ib, io, jb, jo := i/blockSize, i%blockSize, j/blockSize, j%blockSize
102102
a, b := s.blocks[jb][jo], s.blocks[ib][io]
@@ -107,7 +107,7 @@ func (s *sstack[P, V]) Swap(i, j int) {
107107
s.blocks[ib][io], s.blocks[jb][jo] = a, b
108108
}
109109

110-
// Resets the stack, effectively clearing its contents.
110+
// Reset the stack, effectively clearing its contents.
111111
func (s *sstack[P, V]) Reset() {
112112
*s = *newSstack[P, V](s.setIndex)
113113
}

0 commit comments

Comments
 (0)