Created
November 24, 2014 22:56
-
-
Save cubuspl42/cf681f8e8d636a2349c7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Oznaczmy: | |
// X - nowy węzeł | |
// L - węzeł, po którym dodajemy X | |
// N - węzeł obecnie następujący po L | |
// L <-> N | |
x->next = l->next; | |
// L <-> N | |
// X -> N | |
l->next = x; | |
// L <- N | |
// L -> X -> N | |
x->prev = l; | |
// L <- N | |
// L <-> X -> N | |
(l->next)->prev = x->prev; // x->prev = x->prev (= l); (ta linia nic nie robi!) | |
// Podsumowując. Co mamy: | |
// L <- N | |
// L <-> X -> N | |
// Co chcieliśmy mieć: | |
// L <-> X <-> N |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment