Commit 8cf45909 authored by Matthew Dempsky's avatar Matthew Dempsky Committed by Russ Cox

bytes: Change Compare example to be consistent with sort.Search's.

R=rsc, adg
CC=golang-dev
https://golang.org/cl/7057049
parent a88bbbb7
......@@ -59,10 +59,10 @@ func ExampleCompare_search() {
var needle []byte
var haystack [][]byte // Assume sorted
i := sort.Search(len(haystack), func(i int) bool {
// Return needle <= haystack[i].
return bytes.Compare(needle, haystack[i]) <= 0
// Return haystack[i] >= needle.
return bytes.Compare(haystack[i], needle) >= 0
})
if i < len(haystack) && bytes.Equal(needle, haystack[i]) {
if i < len(haystack) && bytes.Equal(haystack[i], needle) {
// Found it!
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment