2 list.hh -- part of flowerlib
4 (c) 1996 Han-Wen Nienhuys & Jan Nieuwenhuizen
12 /// Use for list of pointers, e.g. PointerList<AbstractType*>.
14 class PointerList : public List<void *>
17 PCursor<T> top() { return PCursor<T> (List<void*>::top()); }
18 PCursor<T> bottom() { return PCursor<T> (List<void*>::bottom()); }
20 PointerList( const T& thing ) : List<void*>( thing ) { }
25 /// intrusive pl. deletes pointers given to it.
27 struct IPointerList : public PointerList<T> {
28 IPointerList(IPointerList&) { set_empty(); }
31 virtual void remove( Cursor<void*> me ) { remove (PCursor<T>(me)); }
32 virtual void remove( PCursor<T> me );
36 The copy constructor doesn't do what you'd want:
37 Since T might have a virtual ctor, we don't try to do a
41 You have to copy this yourself, or use the macro PointerList__copy
44 #define IPointerList__copy(T, to, from, op) \
45 for (PCursor<T> _pc_(from); _pc_.ok(); _pc_++)\
46 to.bottom().add(_pc_->op)\
51 void PL_copy(IPointerList<T*> &dst,IPointerList<T*> const&src);
54 #define PL_instantiate(a) L_instantiate(a *); template class PointerList<a*>
55 #define IPL_instantiate(a) PL_instantiate(a); template class IPointerList<a*>