Exemple #1
0
 public static function nCopies($n, Object $obj)
 {
     // Vector is the closest instantiable child to PList
     $list = new Vector();
     for ($i = 0; $i <= $n; $i++) {
         $list->add($obj);
     }
     return $list;
 }
Exemple #2
0
 public function testRemove()
 {
     $v = new Vector();
     $v->addAll($this->cases);
     $n = new Vector();
     $n->addAll($this->cases);
     $this->assertEquals($v, $n);
     $v->removeElementAt(rand(0, $v->size()));
     $this->assertNotEquals($v, $n);
 }
Exemple #3
0
 /**
  * Returns an enumeration of the components of this vector. The returned Enumeration 
  * object will generate all items in this vector. The first item generated is the item at 
  * index 0, then the item at index 1, and so on. 
  *
  * @returns an enumeration of the components of this vector.
  * @see Enumeration, Iterator
  */
 public function elements()
 {
     $enum = new Vector();
     for ($i = 0; $i < count($this->list); $i++) {
         $enum->addElement($this->list[$i]);
     }
     return $enum;
 }