array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'zh', ), 'this' => array ( 0 => 'ds-queue.copy.php', 1 => 'Ds\\Queue::copy', 2 => 'Returns a shallow copy of the queue', ), 'up' => array ( 0 => 'class.ds-queue.php', 1 => 'Ds\\Queue', ), 'prev' => array ( 0 => 'ds-queue.construct.php', 1 => 'Ds\\Queue::__construct', ), 'next' => array ( 0 => 'ds-queue.count.php', 1 => 'Ds\\Queue::count', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'en', 'path' => 'reference/ds/ds/queue/copy.xml', ), 'history' => array ( ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); contributors($setup); ?>

Ds\Queue::copy

(PECL ds >= 1.0.0)

Ds\Queue::copyReturns a shallow copy of the queue

说明

public Ds\Queue::copy(): Ds\Queue

Returns a shallow copy of the queue.

参数

此函数没有参数。

返回值

Returns a shallow copy of the queue.

示例

示例 #1 Ds\Queue::copy() example

<?php
$a
= new \Ds\Queue([1, 2, 3]);
$b = $a->copy();

// Updating the copy doesn't affect the original
$b->push(4);

print_r($a);
print_r($b);
?>

以上示例的输出类似于:

Ds\Queue Object
(
    [0] => 1
    [1] => 2
    [2] => 3
)
Ds\Queue Object
(
    [0] => 1
    [1] => 2
    [2] => 3
    [3] => 4
)