Phpml\Math\Set::intersection PHP Method

intersection() public static method

Creates the intersection of A and B.
public static intersection ( Set $a, Set $b ) : Set
$a Set
$b Set
return Set
    public static function intersection(Set $a, Set $b) : Set
    {
        return new self(array_intersect($a->toArray(), $b->toArray()));
    }

Usage Example

Example #1
0
 public function testIntersection()
 {
     $intersection = Set::intersection(new Set(['C', 'A']), new Set(['B', 'C']));
     $this->assertInstanceOf('\\Phpml\\Math\\Set', $intersection);
     $this->assertEquals(new Set(['C']), $intersection);
     $this->assertEquals(1, $intersection->cardinality());
 }