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

builtin: add documentation for builtin array functions (#11023)

This commit is contained in:
Enzo 2021-08-03 05:25:33 +02:00 committed by GitHub
parent a55ba08fad
commit fc193bebf2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -488,6 +488,43 @@ pub fn (a &array) free() {
unsafe { free(&byte(a.data) - a.offset) }
}
// filter creates a new array with all elements that pass the test implemented by the provided function
pub fn (a array) filter(predicate fn (voidptr) bool) array
struct ZZZTmp1 {}
// any tests whether at least one element in the array passes the test implemented by the
// provided function. It returns true if, in the array, it finds an element for which the provided
// function returns true; otherwise it returns false. It doesn't modify the array
pub fn (a array) any(predicate fn (voidptr) bool) bool
struct ZZZTmp2 {}
// all tests whether all elements in the array pass the test implemented by the provided function
pub fn (a array) all(predicate fn (voidptr) bool) bool
struct ZZZTmp3 {}
// map creates a new array populated with the results of calling a provided function
// on every element in the calling array
pub fn (a array) map(callback fn (voidptr) voidptr) array
struct ZZZTmp4 {}
// sort sorts an array in place in ascending order.
pub fn (mut a array) sort(callback fn (voidptr, voidptr) int)
struct ZZZTmp5 {}
// contains determines whether an array includes a certain value among its entries
pub fn (a array) contains(val voidptr) bool
struct ZZZTmp6 {}
// 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 array) index(value voidptr) int
[unsafe]
pub fn (mut a []string) free() {
$if prealloc {