diff options
| author | Alan Donovan <adonovan@google.com> | 2015-01-14 18:09:36 -0500 |
|---|---|---|
| committer | Alan Donovan <adonovan@google.com> | 2015-01-15 17:17:05 +0000 |
| commit | 90ce1936e32f46de4c64752dfc54df75ec5758f0 (patch) | |
| tree | 56b9706e454514bff63dfff802f68b6b6694de3e /src/strings/strings_decl.go | |
| parent | ee3a1ff6fd11cd8fab3d3f416c85816af7bef4d1 (diff) | |
| download | go-90ce1936e32f46de4c64752dfc54df75ec5758f0.tar.xz | |
strings: add Compare(x, y string) int, for symmetry with bytes.Compare
The implementation is the same assembly (or Go) routine.
Change-Id: Ib937c461c24ad2d5be9b692b4eed40d9eb031412
Reviewed-on: https://go-review.googlesource.com/2828
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'src/strings/strings_decl.go')
| -rw-r--r-- | src/strings/strings_decl.go | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/strings/strings_decl.go b/src/strings/strings_decl.go index 810a696af2..9dc2a9a6c6 100644 --- a/src/strings/strings_decl.go +++ b/src/strings/strings_decl.go @@ -6,3 +6,10 @@ package strings // IndexByte returns the index of the first instance of c in s, or -1 if c is not present in s. func IndexByte(s string, c byte) int // ../runtime/asm_$GOARCH.s + +// Compare returns an integer comparing two strings lexicographically. +// The result will be 0 if a==b, -1 if a < b, and +1 if a > b. +// +// In most cases it is simpler to use the built-in comparison operators +// ==, <, >, and so on. +func Compare(a, b string) int // ../runtime/noasm.go or ../runtime/asm_*.s |
