本文整理汇总了PHP中Set::union方法的典型用法代码示例。如果您正苦于以下问题:PHP Set::union方法的具体用法?PHP Set::union怎么用?PHP Set::union使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Set
的用法示例。
在下文中一共展示了Set::union方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testUnion
public function testUnion()
{
$set1 = new Set(array(1, 2, 3));
$set2 = new Set(array(2, 3, 4));
$set3 = $set1->union($set2);
$arr = array(1, 2, 3, 4);
foreach ($arr as $n) {
self::assertTrue($set3->member($n));
}
}
示例2: symmetricDifference
/**
* Set symmetric difference operator.
*
* Returns a Set which is the symmetric difference of this Set with the
* passed Set.
*
* @param Value $set
*
* @return Set
*/
public function symmetricDifference(Value $set)
{
$returnValue = new Set(array());
return $returnValue->union($this->complement($set), $set->getSet()->complement($this));
}
示例3: testAUnsionBCrossCEqualsUnsionOfACRossCAndBCrossC
/**
* Axiom: (A ∪ B) × C = (A × C) ∪ (B × C)
* A union B cross C is the union of A cross C and B cross C
* @dataProvider dataProviderForThreeSets
*/
public function testAUnsionBCrossCEqualsUnsionOfACRossCAndBCrossC(Set $A, Set $B, Set $C)
{
$⟮A∪B⟯×C = $A->union($B)->cartesianProduct($C);
$⟮A×C⟯∪⟮B×C⟯ = $A->cartesianProduct($C)->union($B->cartesianProduct($C));
$this->assertEquals($⟮A∪B⟯×C, $⟮A×C⟯∪⟮B×C⟯);
$this->assertEquals($⟮A∪B⟯×C->asArray(), $⟮A×C⟯∪⟮B×C⟯->asArray());
}
示例4: successor
public static function successor($x)
{
return Set::union($x, Set::singleton($x));
}