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

builtin: make array.delete() reallocate, provide .delete_many() (#10889)

This commit is contained in:
Uwe Krüger
2021-07-21 19:55:32 +02:00
committed by GitHub
parent be7c3965a9
commit 41982053f1
3 changed files with 50 additions and 4 deletions

View File

@ -862,6 +862,9 @@ There are further built in methods for arrays:
* `a.prepend(arr)` insert elements of array `arr` at beginning
* `a.trim(new_len)` truncate the length (if `new_length < a.len`, otherwise do nothing)
* `a.clear()` empty the array (without changing `cap`, equivalent to `a.trim(0)`)
* `a.delete_many(start, size)` removes `size` consecutive elements beginning with index `start`
&ndash; triggers reallocation
* `a.delete(index)` equivalent to `a.delete_many(index, 1)`
* `v := a.first()` equivalent to `v := a[0]`
* `v := a.last()` equivalent to `v := a[a.len - 1]`
* `v := a.pop()` get last element and remove it from array