2 list.hh -- part of flowerlib
4 (c) 1996 Han-Wen Nienhuys & Jan Nieuwenhuizen
15 Use for list of pointers, e.g. Link_list<AbstractType*>.
16 This class does no deletion of the pointers, but it knows how to
17 copy itself (shallow copy). We could have derived it from List<T>,
18 but this design saves a lot of code dup; for all Link_lists in the
19 program only one parent List<void*> is instantiated.
22 class Link_list : public List<void *>
25 PCursor<T> top() const{
26 return PCursor<T> (List<void*>::top());
28 PCursor<T> bottom() const {
29 return PCursor<T> (List<void*>::bottom());
31 PCursor<T> find (T) const;
32 void concatenate (Link_list<T> const &s) { List<void*>::concatenate (s); }
39 Link_list which deletes pointers given to it.
43 The copy constructor doesn't do what you'd want:
44 Since T might have a virtual ctor, we don't try to do a
48 You have to copy this yourself, or use the macro Link_list__copy
54 class Pointer_list : public Link_list<T> {
58 Pointer_list (Pointer_list const &) { set_empty(); }
60 ~Pointer_list() { junk (); }
63 #define Pointer_list__copy(T, to, from, op) \
64 for (PCursor<T> _pc_(from); _pc_.ok(); _pc_++)\
65 to.bottom().add (_pc_->op)\
70 void PL_copy (Pointer_list<T*> &dst,Pointer_list<T*> const&src);