commit eed5d4711b0373f742dc1fab4596c74398e021a0 parent 9319ddab89bba301ed4e379d5eb8f879d975a9d3 Author: CamiAni <129856337+CamiAni@users.noreply.github.com> Date: Sun, 23 Jun 2024 19:46:08 -0300 Merge pull request #20 from CamiAni/main Update list.h Diffstat:
| M | list.h | | | 47 | ----------------------------------------------- |
1 file changed, 0 insertions(+), 47 deletions(-) diff --git a/list.h b/list.h @@ -61,16 +61,6 @@ public: * pos: devuelve el dato del nodo en el cual se encuentra el cursor */ Type getCursorData(); - - void validarPosicion(unsigned int posicion); - - Node<Type> *obtenerNodo(unsigned int posicion); - - /* - *pre : posición pertenece al intervalo: [1, contarElementos()] - *pre * post: remueve de la Lista el elemento en la posición indicada. - */ - void remove(unsigned int posicion); }; template <typename Type> @@ -129,41 +119,4 @@ template<class Type> Type List<Type>::getCursorData() { return this->cursor->getData(); } - - -template <typename Type> void List<Type>::validarPosicion(unsigned int posicion) { - if ((posicion < 1) || - (posicion > this->size + 1)) { - throw "La posicion debe estar entre 1 y tamaño + 1"; - } -} - -template <typename Type> -Node<Type> *List<Type>::obtenerNodo(unsigned int posicion) { - //validarPosicion(posicion); - Node<Type> * actual = this->first; - for(unsigned int i = 1; i < posicion; i++) { - actual = actual->getNext(); - } - return actual; -} - -template <typename Type> -void List<Type>::remove(unsigned int posicion) { - validarPosicion(posicion); - Node<Type> *removido; - - if (posicion == 1) { - removido = this->first; - this->first = removido->getNext(); - } else { - Node<Type> *anterior = this->obtenerNodo(posicion - 1); - removido = anterior->getNext(); - anterior->setNext( removido->getNext()); - } - - delete removido; - this->size--; -} - #endif /* LIST_H_ */
