]> Cypherpunks repositories - gostls13.git/commitdiff
sort.Search: slightly more precise wording in comment
authorRobert Griesemer <gri@golang.org>
Sat, 13 Nov 2010 00:08:56 +0000 (16:08 -0800)
committerRobert Griesemer <gri@golang.org>
Sat, 13 Nov 2010 00:08:56 +0000 (16:08 -0800)
(+ some cosmetic changes)

R=iant, iant2
CC=golang-dev
https://golang.org/cl/3076041

src/pkg/sort/search.go

index 6b053c2b1d5e26815c8329fdc35a7dd1ef598c31..aaaa0c84a1251efb34d73f71ad769fe950b2c7e6 100644 (file)
@@ -27,7 +27,7 @@ package sort
 //     data[i-1] < x && x <= data[i]
 //
 // where data[-1] is assumed to be smaller than any x and data[n] is
-// assumed to be larger than any x.  Thus 0 <= i <= n and i is the first
+// assumed to be larger than any x.  Thus 0 <= i <= n and i is the smallest
 // index of x if x is present in the data.  It is the responsibility of
 // the caller to verify the actual presence by testing if i < n and
 // data[i] == x.
@@ -42,6 +42,7 @@ package sort
 //     } else {
 //             // elem is not present in data
 //     }
+//
 func Search(n int, f func(int) bool) int {
        i, j := 0, n
        for i+1 < j {
@@ -55,11 +56,11 @@ func Search(n int, f func(int) bool) int {
                        j = h
                }
        }
-       // test the final element that the loop did not.
+       // test the final element that the loop did not
        if i < j && f(i) {
+               // data[i] < x
                i++
        }
-
        return i
 }