A função Ds \ Deque :: slice () pode retornar o sub-deque de um determinado intervalo.
Sintaxe
public Ds\Deque Ds\Deque::slice( int $index [, int $length ] )
A função Ds \ Deque :: slice () pode criar o sub-deque de um determinado intervalo.
Exemplo 1
<?php
$deque = new \Ds\Deque([1, 2, 3, 4, 5]);
echo("The elements in deque: \n");
print_r($deque);
$deque_new = $deque->slice(2, 4);
echo("\n The deque after slice(): \n");
print_r($deque_new);
?>
Exemplo 2
<?php
$deque = new \Ds\Deque([1, 2, 3, 4, 5]);
echo("The elements in deque: \n");
print_r($deque);
$deque_new = $deque->slice(3, -1);
echo("\n The deque after slice(): \n");
print_r($deque_new);
?>