From: fred Date: Fri, 1 Nov 1996 13:41:26 +0000 (+0000) Subject: flower-1.0.4 X-Git-Tag: release/1.5.59~6976 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=487611d60bd8c98c1e5b4baa4443b42423d6c1fb;p=lilypond.git flower-1.0.4 --- diff --git a/flower/Sources.make b/flower/Sources.make index 6521100b3b..fd5dcf4146 100644 --- a/flower/Sources.make +++ b/flower/Sources.make @@ -1,12 +1,12 @@ cc=lgetopt.cc string.cc dataf.cc textdb.cc unionfind.cc \ smat.cc matrix.cc choleski.cc vector.cc dstream.cc\ - matdebug.cc + matdebug.cc -templatecc=cursor.cc list.cc tsmat.cc -inl=findcurs.inl link.inl list.inl -hh=cursor.hh pcursor.hh cursor.inl lgetopt.hh link.hh list.hh dstream.hh \ +templatecc=cursor.cc list.cc tsmat.cc plist.cc +inl=findcurs.inl link.inl list.inl plist.inl cursor.inl +hh=cursor.hh pcursor.hh lgetopt.hh link.hh list.hh dstream.hh \ string.hh stringutil.hh vray.hh textdb.hh textstr.hh assoc.hh\ findcurs.hh unionfind.hh compare.hh handle.hh matrix.hh\ smat.hh vsmat.hh vector.hh real.hh choleski.hh\ - tsmat.hh tvsmat.hh + tsmat.hh tvsmat.hh plist.hh\ diff --git a/flower/list.hh b/flower/list.hh index a45252b8c3..6edf4aebc4 100644 --- a/flower/list.hh +++ b/flower/list.hh @@ -11,10 +11,12 @@ template class Link; template class List { - public: - /// construct empty list - List(); + List(List const&src); + public: + /// construct empty list + List(); + /// construct list from first item. List( const T& thing ); @@ -28,6 +30,11 @@ class List protected: friend class Cursor; friend class Link; + /// make *this empty + void set_empty(); + /** + WARNING: contents lost, and not deleted. + */ /// add after after_me void add( const T& thing, Cursor after_me ); @@ -67,32 +74,13 @@ class List */ -/// Use for list of pointers, e.g. PointerList. -template -class PointerList : public List -{ - public: - PointerList(); - PointerList( const T& thing ); - - /// - 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 ); -}; - #include "list.inl" #include "cursor.hh" // instantiate a template: explicit instantiation. #define L_instantiate(a) template class List; template class Cursor; \ template class Link -#define PL_instantiate(a) L_instantiate(a *); template class PointerList + #endif // __LIST_HH // diff --git a/flower/plist.hh b/flower/plist.hh new file mode 100644 index 0000000000..3660968a47 --- /dev/null +++ b/flower/plist.hh @@ -0,0 +1,53 @@ +/* + list.hh -- part of flowerlib + + (c) 1996 Han-Wen Nienhuys & Jan Nieuwenhuizen +*/ + +#ifndef PLIST_HH +#define PLIST_HH + +#include "list.hh" + +/// Use for list of pointers, e.g. PointerList. +template +class PointerList : public List +{ + public: + PointerList(PointerList&) { set_empty(); } + 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 ); +}; +/** + NOTE: + The copy constructor doesn't do what you'd want: + Since T might have a virtual ctor, we don't try to do a + + new T(*cursor) + + You have to copy this yourself, or use the macro PointerList__copy + + */ +#define PointerList__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); + +#define PL_instantiate(a) L_instantiate(a *); template class PointerList + +#include "plist.inl" + +#endif