本文整理匯總了PHP中Set::addAll方法的典型用法代碼示例。如果您正苦於以下問題:PHP Set::addAll方法的具體用法?PHP Set::addAll怎麽用?PHP Set::addAll使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Set
的用法示例。
在下文中一共展示了Set::addAll方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: union
/**
* @param Set $other
* A set of items to union with this set
*
* @return Set
* A new set which contains only items in this
* Set and the given Set.
*
* @suppress PhanUnreferencedMethod
*/
public function union(Set $other) : Set
{
$set = new Set();
$set->addAll($this);
$set->addAll($other);
return $set;
}
示例2: testAddAll
public function testAddAll()
{
$set1 = new Set(['lol']);
$set2 = new Set(['foo']);
$set1->addAll($set2);
$set2->addAll($set1);
$this->assertTrue($set1->equals($set2));
}
示例3: testAddAllNoDuplicates
public function testAddAllNoDuplicates()
{
$this->setExpectedException('\\InvalidArgumentException');
$this->object->add($this->items['alpha']);
$set = new TreeSet();
$set->add($this->items['alpha']);
$set->add($this->items['bravo']);
$set->add($this->items['charlie']);
$this->object->addAll($set);
}