Esempio n. 1
0
 public function getIterator()
 {
     $set = new Set();
     foreach ($this->iterator as $value) {
         if ($set->add($value)) {
             (yield $value);
         }
     }
 }
Esempio n. 2
0
 public function getIterator()
 {
     $set = new Set();
     foreach ($this->second as $second) {
         $set->add($second);
     }
     foreach ($this->first as $first) {
         if (!$set->contains($first)) {
             (yield $first);
         }
     }
 }
Esempio n. 3
0
 /**
  * @test
  */
 public function add_remove_mixValues_CorrectBehaviour()
 {
     $set = new Set();
     $a = null;
     $b = "string";
     $c = new stdClass();
     $d = ["a", "b", "c"];
     $this->assertTrue($set->add($a));
     $this->assertTrue($set->add($b));
     $this->assertTrue($set->add($c));
     $this->assertTrue($set->add($d));
     $this->assertTrue($set->contains($a));
     $this->assertTrue($set->contains($b));
     $this->assertTrue($set->contains($c));
     $this->assertTrue($set->contains($d));
     $this->assertFalse($set->add($a));
     $this->assertFalse($set->add($b));
     $this->assertFalse($set->add($c));
     $this->assertFalse($set->add($d));
     $this->assertTrue($set->remove($a));
     $this->assertTrue($set->remove($b));
     $this->assertTrue($set->remove($c));
     $this->assertTrue($set->remove($d));
     $this->assertFalse($set->contains($a));
     $this->assertFalse($set->contains($b));
     $this->assertFalse($set->contains($c));
     $this->assertFalse($set->contains($d));
     $this->assertFalse($set->remove($a));
     $this->assertFalse($set->remove($b));
     $this->assertFalse($set->remove($c));
     $this->assertFalse($set->remove($d));
 }