/** * @param mixed $x * @return bool */ public function remove($x) { $hash = $this->eqComparer->hash($x); if (array_key_exists($hash, $this->elements)) { unset($this->elements[$hash]); return true; } else { return false; } }
/** * @param array|\Iterator|\IteratorAggregate $rhs * @return bool */ public function sequenceEquals($rhs) { $eqComparer = EqualityComparerResolver::resolve(null, EqualityComparer::getDefault()); $lhs = $this->getIterator(); $rhs = IteratorUtil::iterator($rhs); if ($lhs instanceof \Countable && $rhs instanceof \Countable) { if ($lhs->count() !== $rhs->count()) { return false; } } $lhs->rewind(); $rhs->rewind(); while ($lhs->valid()) { $v0 = $lhs->current(); if ($rhs->valid()) { $v1 = $rhs->current(); if (!$eqComparer->equals($v0, $v1)) { return false; } $rhs->next(); } else { return false; } $lhs->next(); } return true; }