本文整理汇总了PHP中Iterator::getArrayCopy方法的典型用法代码示例。如果您正苦于以下问题:PHP Iterator::getArrayCopy方法的具体用法?PHP Iterator::getArrayCopy怎么用?PHP Iterator::getArrayCopy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Iterator
的用法示例。
在下文中一共展示了Iterator::getArrayCopy方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: multiSort
/**
* @return void
*/
private function multiSort()
{
if (!$this->sortPended || empty($this->sortingCommands)) {
return;
}
// set pended to false before toArray is performed to avoid infinite loop.
$this->sortPended = false;
$itArray = $this->it instanceof \ArrayIterator ? $this->it->getArrayCopy() : $this->toArray();
if (count($this->sortingCommands) === 1) {
$command = $this->sortingCommands[0];
if (!is_null($command->getComparator())) {
usort($itArray, function ($first, $second) use($command) {
return -$command->getSortOrder() * $command->getComparator()->compare($first, $second);
});
} else {
if ($command->getSortOrder() === SortOrder::ASC) {
sort($itArray);
} else {
rsort($itArray);
}
}
} else {
$itArray = $this->quickSort($itArray, $this->sortingCommands);
}
$this->it = new \ArrayIterator($itArray);
}
示例2: getTraversable
/**
* Get the item that's being traversed.
*
* @return \Traversable|array
*/
public function getTraversable()
{
if ($this->traversable instanceof ArrayIterator) {
$array = $this->traversable->getArrayCopy();
for ($i = 0; $i < $this->i; $i++) {
next($array);
}
return $array;
}
return $this->traversable;
}
示例3: getRaw
/**
* Returns original data.
*
* @return array|\Traversable
*
* @throws DataException
*/
public function getRaw()
{
switch ($this->type) {
case self::TYPE_ARRAY:
return $this->data->getArrayCopy();
case self::TYPE_ITERATOR:
return $this->data;
case self::TYPE_AGGREGATE:
return $this->data->getInnerIterator();
}
throw DataException::invalidCollectionData($this->data);
}