From 53a2a44e806871645328533a6f44a003eb4599d2 Mon Sep 17 00:00:00 2001 From: fred Date: Sat, 16 Nov 1996 00:21:19 +0000 Subject: [PATCH] flower-1.0.7 --- flower/plist.hh | 34 ++++++++++++++++++++-------------- flower/plist.inl | 29 ++++------------------------- 2 files changed, 24 insertions(+), 39 deletions(-) diff --git a/flower/plist.hh b/flower/plist.hh index 8fa126b527..1bfc2d4ab4 100644 --- a/flower/plist.hh +++ b/flower/plist.hh @@ -11,21 +11,25 @@ /// Use for list of pointers, e.g. PointerList. template -class PointerList : public List +class PointerList : public List { public: - PointerList(PointerList&) { set_empty(); } - PointerList( const T& thing ) : List( thing ) { } + PCursor top() { return PCursor (List::top()); } + PCursor bottom() { return PCursor (List::bottom()); } + + PointerList( const T& thing ) : List( thing ) { } PointerList() {} - /// - virtual ~PointerList(); - /** - This function deletes deletes the allocated pointers of all links. - #\Ref{~List}# is used to delete the links themselves. - */ - - protected: - virtual void remove( Cursor me ); +}; + + +/// intrusive pl. deletes pointers given to it. +template +struct IPointerList : public PointerList { + IPointerList(IPointerList&) { set_empty(); } + IPointerList() { } +protected: + virtual void remove( Cursor me ) { remove (PCursor(me)); } + virtual void remove( PCursor me ); }; /** NOTE: @@ -37,16 +41,18 @@ class PointerList : public List You have to copy this yourself, or use the macro PointerList__copy */ -#define PointerList__copy(T, to, from, op) \ +#define IPointerList__copy(T, to, from, op) \ for (PCursor _pc_(from); _pc_.ok(); _pc_++)\ to.bottom().add(_pc_->op)\ \ template -void PL_copy(PointerList &dst,PointerList const&src); +void PL_copy(IPointerList &dst,IPointerList const&src); + #define PL_instantiate(a) L_instantiate(a *); template class PointerList +#define IPL_instantiate(a) PL_instantiate(a); template class IPointerList #include "plist.inl" diff --git a/flower/plist.inl b/flower/plist.inl index b8cd8d6020..82be364334 100644 --- a/flower/plist.inl +++ b/flower/plist.inl @@ -7,36 +7,15 @@ #ifndef PLIST_INL #define PLIST_INL - - -template -inline -PointerList::~PointerList() -{ - Cursor next(*this); - for ( Cursor c( *this ); c.ok(); c = next ) { - next = c; - next++; - remove( c ); // PointerList::remove deletes the real data - } -} - -template -inline void -PointerList_print( PointerList const & l ) -{ - for (PCursor c(l ); c.ok(); c++ ) - c->print(); -} - template -inline void -PL_copy(PointerList &to,PointerList const&src) +void +PL_copy(IPointerList &to, IPointerList const&src) { for (PCursor pc(src); pc.ok(); pc++) { T *q = pc; - T *p=new T(*q) ; // argh, how do i do this in ANSI-C++ + T *p=new T(*q) ; to.bottom().add(p); } } + #endif -- 2.39.5