Ds\Vector::rotate
(PECL ds >= 1.0.0)
Ds\Vector::rotate — Rotates the vector by a given number of rotations.
Описание
public void Ds\Vector::rotate
( int
$rotations
)
Rotates the vector by a given number of rotations, which is equivalent
to successively calling $vector->push($vector->shift())
if the number
of rotations is positive, or $vector->unshift($vector->pop())
if negative.
Список параметров
-
rotations
-
The number of times the vector should be rotated.
Возвращаемые значения
Эта функция не возвращает значения после выполнения.. The vector of the current instance will be rotated.
Примеры
Пример #1 Ds\Vector::rotate() example
<?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 )
- PHP Руководство
- Функции по категориям
- Индекс функций
- Справочник функций
- Расширения, относящиеся к переменным и типам
- Data Structures
- Ds\Vector::allocate
- Ds\Vector::apply
- Ds\Vector::capacity
- Ds\Vector::clear
- Ds\Vector::__construct
- Ds\Vector::contains
- Ds\Vector::copy
- Ds\Vector::count
- Ds\Vector::filter
- Ds\Vector::find
- Ds\Vector::first
- Ds\Vector::get
- Ds\Vector::insert
- Ds\Vector::isEmpty
- Ds\Vector::join
- Ds\Vector::jsonSerialize
- Ds\Vector::last
- Ds\Vector::map
- Ds\Vector::merge
- Ds\Vector::pop
- Ds\Vector::push
- Ds\Vector::reduce
- Ds\Vector::remove
- Ds\Vector::reverse
- Ds\Vector::reversed
- Ds\Vector::rotate
- Ds\Vector::set
- Ds\Vector::shift
- Ds\Vector::slice
- Ds\Vector::sort
- Ds\Vector::sorted
- Ds\Vector::sum
- Ds\Vector::toArray
- Ds\Vector::unshift
Коментарии
404 Not Found