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; }
public function testGet() { $v = new Vector(); $v->add(new String('these')); $v->add(new String('are')); $v->add(new String('the')); $v->add(new String('words')); $v->add(new String('of')); $v->add(new String('a')); $v->add(new String('sentence')); $n = new Vector(); $n->addAll($v); $str = ''; $it = $n->iterator(); while ($it->hasNext()) { $str .= $it->current(); $it->next(); } $this->assertEquals($str, 'thesearethewordsofasentence'); }