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