private function getValueAt($index, $throwEx)
{
$i = 0;
foreach ($this->iterator as $value) {
if ($i == $index) {
return $value;
}
$i++;
}
if ($throwEx) {
throw new OutOfRangeException("Index is less than 0 or greater than or equal to the number of elements in the sequence.");
}
return null;
}