LEFT | RIGHT |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 // Package strings implements simple functions to manipulate strings. | 5 // Package strings implements simple functions to manipulate strings. |
6 package strings | 6 package strings |
7 | 7 |
8 import ( | 8 import ( |
9 "unicode" | 9 "unicode" |
10 "unicode/utf8" | 10 "unicode/utf8" |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 i++ | 155 i++ |
156 if h == hashsep && s[i-n:i] == sep { | 156 if h == hashsep && s[i-n:i] == sep { |
157 return i - n | 157 return i - n |
158 } | 158 } |
159 } | 159 } |
160 return -1 | 160 return -1 |
161 } | 161 } |
162 | 162 |
163 // IndexByte returns the index of the first instance of c in s, or -1 if c is no
t present in s. | 163 // IndexByte returns the index of the first instance of c in s, or -1 if c is no
t present in s. |
164 func IndexByte(s string, c byte) int { | 164 func IndexByte(s string, c byte) int { |
165 // special case worth making fast | |
166 for i := 0; i < len(s); i++ { | 165 for i := 0; i < len(s); i++ { |
167 if s[i] == c { | 166 if s[i] == c { |
168 return i | 167 return i |
169 } | 168 } |
170 } | 169 } |
171 return -1 | 170 return -1 |
172 } | 171 } |
173 | 172 |
174 // LastIndex returns the index of the last instance of sep in s, or -1 if sep is
not present in s. | 173 // LastIndex returns the index of the last instance of sep in s, or -1 if sep is
not present in s. |
175 func LastIndex(s, sep string) int { | 174 func LastIndex(s, sep string) int { |
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
730 } | 729 } |
731 if r == tr { | 730 if r == tr { |
732 continue | 731 continue |
733 } | 732 } |
734 return false | 733 return false |
735 } | 734 } |
736 | 735 |
737 // One string is empty. Are both? | 736 // One string is empty. Are both? |
738 return s == t | 737 return s == t |
739 } | 738 } |
LEFT | RIGHT |