HH\Lib\Vec\slice
Requires the Hack Standard Library to be installed.
Facebook Engineer?
This function is available as Vec\slice()
in Facebook's www repository.
Returns a new vec containing the subsequence of the given Traversable determined by the offset and length
namespace HH\Lib\Vec;
function slice<Tv>(
Container<Tv> $container,
int $offset,
?int $length = NULL,
): vec<Tv>;
If no length is given or it exceeds the upper bound of the Traversable, the vec will contain every element after the offset.
- To take only the first
$n
elements, seeVec\take()
. - To drop the first
$n
elements, seeVec\drop()
.
Time complexity: O(n), where n is the size of the slice Space complexity: O(n), where n is the size of the slice
Parameters
Container<Tv> $container
int $offset
?int $length = NULL
Returns
vec<Tv>