|
Archives
D Programming
DD.gnu digitalmars.D digitalmars.D.bugs digitalmars.D.dtl digitalmars.D.dwt digitalmars.D.announce digitalmars.D.learn digitalmars.D.debugger 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 |
digitalmars.D.dtl - tree node mixin template
(ATTN:not tested heavily) If somebody wants to implement tree alike structure then this (on the clip) will help Beside other features it has three opApply "enumerators": Node parent = ...; foreach(Node n; parent.forward) // all children from first to last foreach(Node n; parent.backward) // all children from last to first foreach(Node n; parent.deep) // all descendants - children and their children Hope it will be useful. Andrew Fedoniouk. http://terrainformatica.com Mar 12 2005
In article <d10nld$1e58$1 digitaldaemon.com>, Andrew Fedoniouk says...(ATTN:not tested heavily) If somebody wants to implement tree alike structure then this (on the clip) will help Beside other features it has three opApply "enumerators": Node parent = ...; foreach(Node n; parent.forward) // all children from first to last foreach(Node n; parent.backward) // all children from last to first foreach(Node n; parent.deep) // all descendants - children and their children Hope it will be useful. Mar 13 2005
Yep. That was my initial test drive of mixins. They are useful indeed. Assigning names to the "inclusion points" is extremely nice. "custom foreach" : if I understand Walter idea about structs clearly then they should work as fast as "plain foreach". Having defined "forward foreach" I am implicitly defining visiting order. As far as I can see from D definition there is no order specified in foreach implementations for standard collections. Andrew. "Ben Hinkle" <Ben_member pathlink.com> wrote in message news:d11rlq$2gss$1 digitaldaemon.com...In article <d10nld$1e58$1 digitaldaemon.com>, Andrew Fedoniouk says...(ATTN:not tested heavily) If somebody wants to implement tree alike structure then this (on the clip) will help Beside other features it has three opApply "enumerators": Node parent = ...; foreach(Node n; parent.forward) // all children from first to last foreach(Node n; parent.backward) // all children from last to first foreach(Node n; parent.deep) // all descendants - children and their children Hope it will be useful. Mar 13 2005
|