Ds\Vector::rotate
Ds\Vector::rotate
(PECL ds >= 1.0.0)
Ds \ Vector :: rotate - 将向量旋转给定数量的旋转。
描述
public void Ds\Vector::rotate ( int $rotations )
向量旋转给定数量的旋转,相当于如果旋转次数为正值,或者$ vector-> unshift($ vector-> pop),如果为负数则相当于连续调用$ vector-> push($ vector-> shift()) ())。
参数
rotations
矢量旋转的次数。
返回值
没有返回值。当前实例的向量将被旋转。
例子
示例#1 Ds \ Vector :: rotate()示例
<?php
$vector = new \Ds\Vector(["a", "b", "c", "d"]
$vector->rotate(1 // "a" is shifted, then pushed.
print_r($vector
$vector->rotate(2 // "b" and "c" are both shifted, the pushed.
print_r($vector
?>
上面的例子会输出类似于:
(
[0] => b
[1] => c
[2] => d
[3] => a
)
Ds\Vector Object
(
[0] => d
[1] => a
[2] => b
[3] => c
)
← Ds\Vector::reversed
Ds\Vector::set →