]> git.donarmstrong.com Git - lilypond.git/commitdiff
flower-1.0.4
authorfred <fred>
Fri, 1 Nov 1996 13:41:26 +0000 (13:41 +0000)
committerfred <fred>
Fri, 1 Nov 1996 13:41:26 +0000 (13:41 +0000)
flower/Sources.make
flower/list.hh
flower/plist.hh [new file with mode: 0644]

index 6521100b3bb5ba72883175fdeaa7a77bfc716bfd..fd5dcf414610946561df2d31cc895c13fbdbf14e 100644 (file)
@@ -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\
index a45252b8c3fb9d6020e479168cd1c69ed4beecfe..6edf4aebc4c25ba4b72b356e86f43bb19a11af27 100644 (file)
@@ -11,10 +11,12 @@ template<class T> class Link;
 template<class T>
 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<T>;
     friend class Link<T>;
+    /// make *this empty
+    void set_empty();
+    /**
+      WARNING: contents lost, and not deleted.
+      */
     
     /// add after after_me
     void add( const T& thing, Cursor<T> after_me );
@@ -67,32 +74,13 @@ class List
 */
 
 
-/// Use for list of pointers, e.g. PointerList<AbstractType*>.
-template<class T>
-class PointerList : public List<T>
-{
- 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<T> me );
-};
-
 #include "list.inl"
 #include "cursor.hh"
 
 // instantiate a template:  explicit instantiation.
 #define L_instantiate(a)  template class List<a>; template class Cursor<a>; \
   template class Link<a>
-#define PL_instantiate(a) L_instantiate(a *); template class PointerList<a*>
+
 
 #endif // __LIST_HH //
     
diff --git a/flower/plist.hh b/flower/plist.hh
new file mode 100644 (file)
index 0000000..3660968
--- /dev/null
@@ -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<AbstractType*>.
+template<class T>
+class PointerList : public List<T>
+{
+ public:
+    PointerList(PointerList&) { set_empty(); }
+    PointerList( const T& thing ) : List<T>( 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<T> 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<T> _pc_(from); _pc_.ok(); _pc_++)\
+      to.bottom().add(_pc_->op)\
+  \
+
+
+template<class T>
+void PL_copy(PointerList<T> &dst,PointerList<T> const&src);
+
+#define PL_instantiate(a) L_instantiate(a *); template class PointerList<a*>
+
+#include "plist.inl"
+
+#endif