aboutsummaryrefslogtreecommitdiff
path: root/src/container
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2018-11-12 12:42:47 -0500
committerRuss Cox <rsc@golang.org>2018-11-13 13:42:59 +0000
commit9d025bdafe8390011428b27fe944ee6acc8fa011 (patch)
tree1ec110f94d5bb2825e1865a98d7e63d42e7fc8f5 /src/container
parenta48a666bc89d355205550d43a9fdf1a9c507a123 (diff)
downloadgo-9d025bdafe8390011428b27fe944ee6acc8fa011.tar.gz
go-9d025bdafe8390011428b27fe944ee6acc8fa011.zip
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 <rsc@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'src/container')
-rw-r--r--src/container/heap/heap.go21
1 files changed, 9 insertions, 12 deletions
diff --git a/src/container/heap/heap.go b/src/container/heap/heap.go
index 1ed0da8e6a..2e09da8613 100644
--- a/src/container/heap/heap.go
+++ b/src/container/heap/heap.go
@@ -38,7 +38,7 @@ type Interface interface {
// Init establishes the heap invariants required by the other routines in this package.
// Init is idempotent with respect to the heap invariants
// and may be called whenever the heap invariants may have been invalidated.
-// Its complexity is O(n) where n = h.Len().
+// The complexity is O(n) where n = h.Len().
func Init(h Interface) {
// heapify
n := h.Len()
@@ -47,18 +47,16 @@ func Init(h Interface) {
}
}
-// Push pushes the element x onto the heap. The complexity is
-// O(log(n)) where n = h.Len().
-//
+// Push pushes the element x onto the heap.
+// The complexity is O(log n) where n = h.Len().
func Push(h Interface, x interface{}) {
h.Push(x)
up(h, h.Len()-1)
}
-// Pop removes the minimum element (according to Less) from the heap
-// and returns it. The complexity is O(log(n)) where n = h.Len().
-// It is equivalent to Remove(h, 0).
-//
+// Pop removes and returns the minimum element (according to Less) from the heap.
+// The complexity is O(log n) where n = h.Len().
+// Pop is equivalent to Remove(h, 0).
func Pop(h Interface) interface{} {
n := h.Len() - 1
h.Swap(0, n)
@@ -66,9 +64,8 @@ func Pop(h Interface) interface{} {
return h.Pop()
}
-// Remove removes the element at index i from the heap and returns
-// the element. The complexity is O(log(n)) where n = h.Len().
-//
+// Remove removes and returns the element at index i from the heap.
+// The complexity is O(log n) where n = h.Len().
func Remove(h Interface, i int) interface{} {
n := h.Len() - 1
if n != i {
@@ -83,7 +80,7 @@ func Remove(h Interface, i int) interface{} {
// Fix re-establishes the heap ordering after the element at index i has changed its value.
// Changing the value of the element at index i and then calling Fix is equivalent to,
// but less expensive than, calling Remove(h, i) followed by a Push of the new value.
-// The complexity is O(log(n)) where n = h.Len().
+// The complexity is O(log n) where n = h.Len().
func Fix(h Interface, i int) {
if !down(h, i, h.Len()) {
up(h, i)