2 parray.hh -- declare Pointer_array
4 source file of the Flower Library
6 (c) 1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
19 should init to 0. Derive from Array<void*>?
22 class Link_array : public Array<T*>
24 static default_compare (T *const& p1, T *const&p2) {
25 /* can't do p1 -p2, since T might be an incomplete type */
33 void substitute (T *old, T*new_l)
36 while ((i = find_i (old)) >=0)
42 void unordered_substitute (T* old, T * new_l)
45 while ((i = find_i (old)) >=0)
54 sort (default_compare);
58 for (int i=0; i < size(); i++)
59 if (!i || elem (i-1) != elem (i))
60 l_arr.push (elem (i));
64 int find_i (T const * t) const {
65 for (int i=0; i < size(); i++)
70 T *find_l (T const *t) const
80 template<class T, class V>
82 typecast_array (Link_array<V> const &a, T * /* dummy */ )
85 for (int i=a.size (); i-- ; )
86 ret.push (dynamic_cast<T*> (a[i])); // ugh?