]> Cypherpunks repositories - gostls13.git/commitdiff
bytes: add Contains function
authorAndrew Gerrand <adg@golang.org>
Fri, 4 Nov 2011 06:46:52 +0000 (17:46 +1100)
committerAndrew Gerrand <adg@golang.org>
Fri, 4 Nov 2011 06:46:52 +0000 (17:46 +1100)
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5349041

src/pkg/bytes/bytes.go

index ac8320fe6b4f5514a5922e8c2c18fa8feccc3693..f7f2f03cd7bb348acca9d099c13113ab86731d54 100644 (file)
@@ -88,6 +88,11 @@ func Count(s, sep []byte) int {
        return n
 }
 
+// Contains returns whether subslice is within b.
+func Contains(b, subslice []string) bool {
+       return Index(b, subslice) != -1
+}
+
 // Index returns the index of the first instance of sep in s, or -1 if sep is not present in s.
 func Index(s, sep []byte) int {
        n := len(sep)