From: Brian H. <bh...@sp...> - 2003-04-25 22:30:31
|
I'm playing (while waiting for compiles) at writting a circular, mutable, doubly linked list data structure. The advantage of this is that inserts anywhere into the list are O(1), if you have a pointer into the list. Enum is almost a perfect vehicle for this- internal to the enum I'm keeping a reference to the current element. If I could just 'reach into' the enum and snag this reference, all would be good with the world. But I can't figure out how to do that (this may be because it's friday afternoon of a long, stressfull week and my brain is mush). So this leaves me with three options, that I wanted to throw out to the listmind at large for input: 1) I can extend Enum to do what I want/need. Nicolas is probably against this. And here I think I actually agree with him- we don't want to extend Enum in ways that make it hard/inefficient/impossible to apply to native linked lists. 2) I can implement a whole new interface, call it Pointer for lack of a better name, and implement *that*. One member of this interface being Pointer.enum_of, an O(1) creation of an enumeration given a pointer. 3) I can just add the pointer library, without any generalization (but still with the enum_of function), to the Dllist library. Thoughts? Brian |