getCurrent(); return parent::getIterator()->current(); } #retorna bool si el iterador es valido public function valid(){ return parent::getIterator()->valid(); } #retorna proximo iterador public function next(){ return parent::getIterator()->next(); } #rewind pone el iterator al comienzo public function rewind(){ parent::getIterator()->rewind(); return parent::getIterator(); } # retorna un array donde los ids son obtneidos por $metodGetId y el valor por $metodGetValor public function getAsArray($metodGetId,$metodGetValor){ $return = false; $iterator = $this->getIterator(); $iterator->rewind(); while($iterator->valid()) { $id = $iterator->current()->$metodGetId(); $valor = $iterator->current()->$metodGetValor(); $return[$id]=$valor; $iterator->next(); } return $return; } public function toArray() { return $this->getArrayCopy(); } # retorna el número de elementos en el mapa public function getCount(){ return parent::count(); } # método para obtener y eliminar el primer elemento public function first() { if ($this->count() == 0) { return null; // o lanzar una excepción, según lo que prefieras } // Obtener el primer elemento $iterator = $this->getIterator(); $iterator->rewind(); $firstElement = $iterator->current(); // Eliminar el primer elemento $this->offsetUnset($iterator->key()); // Reindexar el array para mantener los índices consecutivos $this->exchangeArray(array_values($this->getArrayCopy())); return $firstElement; } } ?>

Iniciar Sesión

Al usar este servicio, aceptas nuestra Política de Privacidad

¿Aún no tienes cuenta? Regístrate. ¿Olvidaste tu contraseña?

Registrarse

Al registrarte, aceptas nuestra Política de Privacidad

Recuperar Contraseña

Te enviaremos un enlace para restablecer tu contraseña.