4 ms·
This technique is talked about in this Stack Overflow answer: http://stackoverflow.com/questions/12914917/using-pointers-to-remove-item-from-singly-linked-list
by unwind 13y ago
This technique is talked about in this Stack Overflow answer: http://stackoverflow.com/questions/12914917/using-pointers-to-remove-item-from-singly-linked-list http://stackoverflow.com/questions/12914917/using-pointers-t..., which also references this Slashdot interview (http://meta.slashdot.org/story/12/10/11/0030249/linus-torvalds-answers-your-questions http://meta.slashdot.org/story/12/10/11/0030249/linus-torval...) with Linus Torvalds where he gives this as his "favorite hack".
- munificent 13y agoYup, I got the idea for this from Linus. Before then, I've always done the uglier "if this is the first node then ..." special case branch instead.