array: remove redundant index method in array.v (#7523)

pull/7561/head^2
yuyi 2020-12-25 23:21:23 +08:00 committed by GitHub
parent fdf6927585
commit 775d16cce3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 0 additions and 45 deletions

View File

@ -597,51 +597,6 @@ pub fn (a []string) index(v string) int {
return -1
}
// index returns the first index at which a given element can be found in the array
// or -1 if the value is not found.
pub fn (a []int) index(v int) int {
for i in 0 .. a.len {
if a[i] == v {
return i
}
}
return -1
}
// index returns the first index at which a given element can be found in the array
// or -1 if the value is not found.
pub fn (a []byte) index(v byte) int {
for i in 0 .. a.len {
if a[i] == v {
return i
}
}
return -1
}
// index returns the first index at which a given element can be found in the array
// or -1 if the value is not found.
pub fn (a []rune) index(v rune) int {
for i in 0 .. a.len {
if a[i] == v {
return i
}
}
return -1
}
// index returns the first index at which a given element can be found in the array
// or -1 if the value is not found.
// TODO is `char` type yet in the language?
pub fn (a []char) index(v char) int {
for i in 0 .. a.len {
if a[i] == v {
return i
}
}
return -1
}
// reduce executes a given reducer function on each element of the array,
// resulting in a single output value.
pub fn (a []int) reduce(iter fn (int, int) int, accum_start int) int {