It was thus said that the Great woodelf once stated:
Sean 'Captain Napalm' Conner wrote:
Gee, I think I could do that in one memory
location---cache the value of
the first pointer. Keep following the list, checking each address against
the cached value. If you hit 0, it terminates, otherwise if the address
matches the cached value, you have a loop. The above method is cleverness
(not) for cleverness sake.
That only works if the first pointer is part of the loop.
Either I'm not that smart, or in all my years as a programmer, I've never
come across a linked list where part of it is in a loop, not all of it.
-spc (Perhaps I'm lucky?)