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\
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 );
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 );
*/
-/// 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 //
--- /dev/null
+/*
+ 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