Skip to content

Instantly share code, notes, and snippets.

@cubuspl42
Created November 24, 2014 22:56
Show Gist options
  • Save cubuspl42/cf681f8e8d636a2349c7 to your computer and use it in GitHub Desktop.
Save cubuspl42/cf681f8e8d636a2349c7 to your computer and use it in GitHub Desktop.
// 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