PHP Ds Deque merge() 函数
Ds\Deque::merge() 函数可以将所有给定的值添加到 deque,并返回结果。
语法
public Ds\Deque Ds\Deque::merge( mixed $values )
Ds\Deque::merge()函数可以返回将所有给定值添加到deque中的结果,实际上相当于将值添加到副本中,然后返回该副本。
示例1
<?php
deque1 = new \Ds\Deque([10, 20, 30, 40, 50]); echo("The elements in first deque: \n"); print_r(deque1);
deque2 = new \Ds\Deque([60, 70, 80, 90]); echo("\n The elements of second deque: \n"); print_r(deque2);
echo("\n The merged deque elements: \n");
print_r(deque1->merge(deque2));
?>
示例2
<?php
deque1 = new \Ds\Deque(["Tutorials", "Point", "India"]); echo("The elements in first deque: \n"); print_r(deque1);
deque2 = new \Ds\Deque(["Tutorix", "India"]);
echo("\n The elements of second deque: \n"); print_r(deque2);
echo("\n The merged deque elements: \n");
print_r(deque1->merge(deque2));
?>