public function testUnionInPlace() { $set1 = new Set(array(1, 2, 3)); $set2 = new Set(array(2, 3, 4)); $set1->unionInPlace($set2); $arr = array(1, 2, 3, 4); foreach ($arr as $n) { self::assertTrue($set1->member($n)); } }
protected function combineFollows($exact) { $top = $this->state->_fsp; $followSet = new Set(array()); for ($i = $top; $i >= 0; $i--) { $localFollowSet = $this->state->following[$i]; /* System.out.println("local follow depth "+i+"="+ localFollowSet.toString(getTokenNames())+")"); */ $followSet->unionInPlace($localFollowSet); if ($exact) { // can we see end of rule? if ($localFollowSet->member(TokenConst::$EOR_TOKEN_TYPE)) { // Only leave EOR in set if at top (start rule); this lets // us know if have to include follow(start rule); i.e., EOF if ($i > 0) { $followSet->remove(TokenConst::$EOR_TOKEN_TYPE); } } else { // can't see end of rule, quit break; } } } return $followSet; }