public function indexExists($index)
{
if (!is_int($index)) {
throw new InvalidArgumentException("Index must be an integer");
}
if ($index < 0) {
throw new InvalidArgumentException("Index must be a non-negative integer");
}
return $index < $this->count();
}