// Indexer ??? public int?this[int indice] { get { trabajo = getIndiceNodito(indice); return(trabajo.getDato()); } set { trabajo = getIndiceNodito(indice); if (trabajo != null) { trabajo.setDato(Convert.ToInt32(value)); } } }
//Recorre toda la lista public void Transversa() { //Trabajo al Inicio trabajo = ancla; //Recorremos hasta encontrar el final while (trabajo.getSiguiente() != null) { //Avanzamos trabajo trabajo = trabajo.getSiguiente(); //Obtenemos el dato y lo mostramos int d = trabajo.getDato(); Console.Write("{0} -> ", d); } //Bajamos la linea Console.WriteLine(); }
// Regresa el indice del Nodo public int getIndice(int valor) { int n = -1; trabajo = ancla; while (trabajo.getSiguiente() != null) { trabajo = trabajo.getSiguiente(); n++; if (trabajo.getDato() == valor) { return(n); } } return(-1); }
// Regresa el nodo con la primera ocurrencia del dato public Nodito Buscar(int valor) { if (isEmpty()) { return(null); } trabajo2 = ancla; //Recorremos para ver si lo encontramos while (trabajo2.getSiguiente() != null) { trabajo2 = trabajo2.getSiguiente(); //Al encontrarlo lo regresamos... if (trabajo2.getDato() == valor) { return(trabajo2); } } //No se encontró, regresamos null return(null); }