Пример #1
0
 /**
  * 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());
     }
 }
Пример #2
0
 /**
  * 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()]);
         }
     }
 }
Пример #3
0
 /**
  * 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;
 }