1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

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

This commit is contained in:
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

View File

@ -597,51 +597,6 @@ pub fn (a []string) index(v string) int {
return -1 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, // reduce executes a given reducer function on each element of the array,
// resulting in a single output value. // resulting in a single output value.
pub fn (a []int) reduce(iter fn (int, int) int, accum_start int) int { pub fn (a []int) reduce(iter fn (int, int) int, accum_start int) int {