Note that there are some explanatory texts on larger screens.

plurals
  1. PORemoving element from own linkedlist
    primarykey
    data
    text
    <p>I'm building my own doubly linkedlist, and im having problem to remove a specified element, my current code:</p> <pre><code>public void BorrarOrdenado(int index) { Nodo&lt;T&gt; nodo = primero; while (index &gt;= 0 &amp;&amp; index &lt; numElementos) { nodo = nodo.sgte; } if (nodo != null) { if (nodo == primero &amp;&amp; nodo == ultimo) { primero = ultimo = null; } if (nodo == primero) { primero = primero.sgte; return; } if (nodo == ultimo) { ultimo = ultimo.sgte; return; } Nodo&lt;T&gt; anterior = nodo.ant; Nodo&lt;T&gt; siguiente = nodo.sgte; anterior.sgte = siguiente; siguiente.ant = anterior; } } </code></pre> <p>The problem is when I want to add new element once I just delete before another one, that the code test:</p> <pre><code>ListaGenerica&lt;int&gt; instanciaLista1 = new ListaGenerica&lt;int&gt;(); instanciaLista1.AñadirOrdenado((int)3); instanciaLista1.AñadirOrdenado((int)2); instanciaLista1.AñadirOrdenado((int)7); instanciaLista1.AñadirOrdenado((int)5); Console.WriteLine(instanciaLista1.ToString()); // ORDENADO : 2 =&gt; 3 =&gt; 5 =&gt; 7 bool esta = instanciaLista1.Buscar((int)5); Console.WriteLine(esta); // TRUE instanciaLista1.setElemento(2, (int)6); // SI EXISTE Console.WriteLine(instanciaLista1.ToString()); instanciaLista1.Borrar(1); Console.WriteLine(instanciaLista1.ToString()); // 2 =&gt; 6 =&gt; 7 instanciaLista1.AñadirOrdenado((int)8); Console.WriteLine(instanciaLista1.ToString()); // 2 =&gt; 5 =&gt; 7 =&gt; 8 . THE PROBLEM IS HERE!!! </code></pre> <p>Any suggestion to solve that??</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload