FAQ
Reviewers: r,

Message:
Hello r@golang.org (cc: 0xjnml@gmail.com, golang-dev@googlegroups.com),

I'd like you to review this change to
https://code.google.com/p/go/


Description:
sort: fix comment for various Search routines
Fixes issue 4205 (again).

Please review this at http://codereview.appspot.com/6819082/

Affected files:
M src/pkg/sort/search.go


Index: src/pkg/sort/search.go
===================================================================
--- a/src/pkg/sort/search.go
+++ b/src/pkg/sort/search.go
@@ -12,8 +12,8 @@
// f is false for some (possibly empty) prefix of the input range [0, n)
// and then true for the (possibly empty) remainder; Search returns
// the first true index. If there is no such index, Search returns n.
-// (Note that the "not found" return value is n, the length of the input,
-// not -1 as in, for instance, strings.Index).
+// (Note that the "not found" return value is not -1 as in, for instance,
+// strings.Index).
// Search calls f(i) only for i in the range [0, n).
//
// A common use of Search is to find the index i for a value x in
@@ -76,7 +76,8 @@
// Convenience wrappers for common cases.

// SearchInts searches for x in a sorted slice of ints and returns the
index
-// as specified by Search. The return value is len(a) if x is not present.
+// as specified by Search. The return value is the index to insert x if x
is
+// not present (it could be len(a)).
// The slice must be sorted in ascending order.
//
func SearchInts(a []int, x int) int {
@@ -84,7 +85,8 @@
}

// SearchFloat64s searches for x in a sorted slice of float64s and returns
the index
-// as specified by Search. The return value is len(a) if x is not present.
+// as specified by Search. The return value is the index to insert x if x
is not
+// present (it could be len(a)).
// The slice must be sorted in ascending order.
//
func SearchFloat64s(a []float64, x float64) int {
@@ -92,7 +94,8 @@
}

// SearchStrings searches for x in a sorted slice of strings and returns
the index
-// as specified by Search. The return value is len(a) if x is not present.
+// as specified by Search. The return value is the index to len(a) if x
is not
+// present (it could be len(a)).
// The slice must be sorted in ascending order.
//
func SearchStrings(a []string, x string) int {

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-dev @
categoriesgo
postedNov 3, '12 at 11:42a
activeNov 6, '12 at 9:07p
posts4
users3
websitegolang.org

3 users in discussion

Minux Ma: 2 posts R: 1 post 0xjnml: 1 post

People

Translate

site design / logo © 2022 Grokbase