MathPHP\SetTheory\Set::copy PHP Method

copy() public method

Copy Produces a new set with the same elements as the set.
public copy ( ) : Set
return Set
    public function copy() : Set
    {
        // ImmutableSet extends Set, so return the calling class' type.
        return new static($this->A);
    }

Usage Example

 /**
  * @dataProvider dataProviderForSingleSet
  */
 public function testCopy(array $members)
 {
     $set = new Set($members);
     $copy = $set->copy();
     $set_array = $set->asArray();
     $copy_array = $copy->asArray();
     $this->assertEquals($set, $copy);
     $this->assertEquals($set_array, $copy_array);
     $this->assertEquals(count($set), count($copy));
 }