1
0
mirror of https://github.com/golang/go synced 2024-11-24 00:20:14 -07:00
go/src/bytes
Dmitry Vyukov 0fb5475bdf bytes, strings: add LastIndexByte
Currently the packages have the following index functions:

func Index(s, sep []byte) int
func IndexAny(s []byte, chars string) int
func IndexByte(s []byte, c byte) int
func IndexFunc(s []byte, f func(r rune) bool) int
func IndexRune(s []byte, r rune) int

func LastIndex(s, sep []byte) int
func LastIndexAny(s []byte, chars string) int
func LastIndexFunc(s []byte, f func(r rune) bool) int

Searching for the last occurrence of a byte is quite common
for string parsing algorithms (e.g. find the last paren on a line).
Also addition of LastIndexByte makes the set more orthogonal.

Change-Id: Ida168849acacf8e78dd70c1354bef9eac5effafe
Reviewed-on: https://go-review.googlesource.com/9500
Reviewed-by: Rob Pike <r@golang.org>
2015-04-30 07:13:18 +00:00
..
buffer_test.go bytes: export Cap method for buffer 2015-04-03 23:50:02 +00:00
buffer.go bytes: fix comment 2015-04-04 02:00:51 +00:00
bytes_decl.go
bytes_test.go bytes, strings: add LastIndexByte 2015-04-30 07:13:18 +00:00
bytes.go bytes, strings: add LastIndexByte 2015-04-30 07:13:18 +00:00
compare_test.go runtime: add runtime.cmpstring and bytes.Compare 2015-03-25 22:46:39 +00:00
equal_test.go
example_test.go
export_test.go bytes: export Cap method for buffer 2015-04-03 23:50:02 +00:00
reader_test.go bytes, strings: add Reader.Size methods 2015-04-06 08:53:47 +00:00
reader.go bytes, strings: add Reader.Size methods 2015-04-06 08:53:47 +00:00