|
Archives
D Programming
digitalmars.Ddigitalmars.D.bugs digitalmars.D.dtl digitalmars.D.ide digitalmars.D.dwt digitalmars.D.announce digitalmars.D.learn digitalmars.D.debugger D.gnu D C/C++ Programming
c++c++.announce c++.atl c++.beta c++.chat c++.command-line c++.dos c++.dos.16-bits c++.dos.32-bits c++.idde c++.mfc c++.rtl c++.stl c++.stl.hp c++.stl.port c++.stl.sgi c++.stlsoft c++.windows c++.windows.16-bits c++.windows.32-bits c++.wxwindows digitalmars.empire digitalmars.DMDScript electronics |
digitalmars.D.dtl - mixin linked lists?
Does anyone see a need for a mixin for a doubly or singly linked list? I'm
basically thinking of
// mixin for linked list support
template Node(Value) {
Node next, prev;
... various linked-list member functions ...
}
// user data structure that wants to be stored in a list
class MyClass {
mixin Node!(MyClass);
char[] a_string;
int an_int;
... etc etc
}
The advantages are a smaller memory footprint and simplicity when the object
lives in exactly one list. Sometimes you just want the list semantics to be
built into the class or struct instead of having a separate List!(MyClass)
type with its definition of nodes. Also an SNode template for singly-linked
lists would be nice.
I haven't completely decided what should go into the Node template - so far
I just have about 5 functions to link, add, remove and opApply. Does this
seem useful?
-Ben
Nov 11 2004
Nov 11 2004
On Thu, 11 Nov 2004 14:21:18 -0500, Ben Hinkle <bhinkle mathworks.com> wrote: Nov 11 2004
In article <cn0e3e$km4$1 digitaldaemon.com>, Ben Hinkle says...Does anyone see a need for a mixin for a doubly or singly linked list? I'm basically thinking of Nov 12 2004
but it will require an interface, right? I see (and use) mixins paired with interfaces. Nov 12 2004
|