/** * Constructs a new set containing the elements in the specified collection. */ public function HashSet1(Collection $c) { $this->__construct(); for ($i = $c->iterator(); $i->hasNext(); $i->next()) { $this->add($i->current()); } }
/** * Removes from this set all of its elements that are contained in the specified collection (optional operation). */ public function removeAll(Collection $c) { for ($i = $c->iterator(); $i->hasNext(); $i->next()) { if (in_array($i->current(), $this->set)) { unset($this->set[$i->current()]); } } }
public function addAll1($index, Collection $c) { $a = $c->toArray(); $numNew = count($a); if ($numNew == 0) { return false; } $this->modCount++; $successor = $index == $this->size ? $this->header : $this->entry($index); $predecessor = $successor->previous; for ($i = 0; $i < $numNew; $i++) { $e = new Entry($a[$i], $successor, $predecessor); $predecessor->next = $e; $predecessor = $e; } $successor->previous = $predecessor; $this->size += $numNew; return true; }
/** * Returns true if this Vector contains all of the elements in the specified Collection. * * @specified containsAll in interface List * @overrides containsAll in class AbstractCollection * @parm c a collection whose elements will be tested for containment in this Vector * @returns true if this Vector contains all of the elements in the specified collection. * @throws NullPointerException if the specified collection is null. */ public function containsAll(Collection $collection) { $ct = $collection->iterator(); while ($ct->hasNext()) { if (!$this->contains($ct->current())) { return false; } $ct->next(); } return true; }