Skip to content

Commit 9d025bd

Browse files
committed
container/heap: adjust wording in comments
Followup to CL 129779 but also some other minor tweaks. Change-Id: Id71455d8a14f5e33f82c942c9e892da56c49d17c Reviewed-on: https://go-review.googlesource.com/c/149257 Run-TryBot: Russ Cox <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Brad Fitzpatrick <[email protected]>
1 parent a48a666 commit 9d025bd

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

src/container/heap/heap.go

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ type Interface interface {
3838
// Init establishes the heap invariants required by the other routines in this package.
3939
// Init is idempotent with respect to the heap invariants
4040
// and may be called whenever the heap invariants may have been invalidated.
41-
// Its complexity is O(n) where n = h.Len().
41+
// The complexity is O(n) where n = h.Len().
4242
func Init(h Interface) {
4343
// heapify
4444
n := h.Len()
@@ -47,28 +47,25 @@ func Init(h Interface) {
4747
}
4848
}
4949

50-
// Push pushes the element x onto the heap. The complexity is
51-
// O(log(n)) where n = h.Len().
52-
//
50+
// Push pushes the element x onto the heap.
51+
// The complexity is O(log n) where n = h.Len().
5352
func Push(h Interface, x interface{}) {
5453
h.Push(x)
5554
up(h, h.Len()-1)
5655
}
5756

58-
// Pop removes the minimum element (according to Less) from the heap
59-
// and returns it. The complexity is O(log(n)) where n = h.Len().
60-
// It is equivalent to Remove(h, 0).
61-
//
57+
// Pop removes and returns the minimum element (according to Less) from the heap.
58+
// The complexity is O(log n) where n = h.Len().
59+
// Pop is equivalent to Remove(h, 0).
6260
func Pop(h Interface) interface{} {
6361
n := h.Len() - 1
6462
h.Swap(0, n)
6563
down(h, 0, n)
6664
return h.Pop()
6765
}
6866

69-
// Remove removes the element at index i from the heap and returns
70-
// the element. The complexity is O(log(n)) where n = h.Len().
71-
//
67+
// Remove removes and returns the element at index i from the heap.
68+
// The complexity is O(log n) where n = h.Len().
7269
func Remove(h Interface, i int) interface{} {
7370
n := h.Len() - 1
7471
if n != i {
@@ -83,7 +80,7 @@ func Remove(h Interface, i int) interface{} {
8380
// Fix re-establishes the heap ordering after the element at index i has changed its value.
8481
// Changing the value of the element at index i and then calling Fix is equivalent to,
8582
// but less expensive than, calling Remove(h, i) followed by a Push of the new value.
86-
// The complexity is O(log(n)) where n = h.Len().
83+
// The complexity is O(log n) where n = h.Len().
8784
func Fix(h Interface, i int) {
8885
if !down(h, i, h.Len()) {
8986
up(h, i)

0 commit comments

Comments
 (0)