public T get(int i) { if (raiz == null) throw new IndexOutOfBoundsException(); if (i == 0) return raiz.getContenido(); int resultado = 0; Nodo<T> actual = raiz; while (actual != null && resultado < i) { actual = actual.getSiguiente(); resultado++; } if (resultado == i) return actual.getContenido(); logger.error("Se busco la posicion " + i + " pero antes la cadena es nula"); throw new IndexOutOfBoundsException(); }
@Override public M next() { M respuesta = actual.getContenido(); actual = actual.getSiguiente(); return respuesta; }