3 ms·
Just curious, this wouldn't work for a circularly linked list in the case where there is only one element, right?
by codezero 15y ago
Just curious, this wouldn't work for a circularly linked list in the case where there is only one element, right?
- tresta 15y agoWhy wouldn't it? A xor A = 0. A xor 0 = A. That should work like a regular circularly linked list or am I missing something? edit Doh, now I understand. If this was allowed it wouldn't be possible to have a one-node non-circular list.
- pmjordan 15y agoGenerally, it doesn't allow you to walk the list given the pointer to an entry. You always need to know the addresses of two adjacent list entries. And yes, this limits its usefulness in practice. I tend to only need doubly linked lists where I want to be able to remove or insert an arbitrary element without walking the list, and you can't do that with an xor list.