2 list.tcc -- implement List<T>
4 source file of the Flower Library
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
12 // instantiate a template: explicit instantiation.
13 #define L_INSTANTIATE(a) class List<a>; template class Cursor<a>; \
14 template class Link<a>
19 List<T>::List (List const&src)
22 // probably el stupido
23 for (Cursor<T> c (src); c.ok(); c++)
72 \item if #after_me# is #ok()#, add after #after_me#, else
73 \item if list !empty simply add to bottom, else
74 \item list is empty: create first \Ref{Link} and initialize
80 List<T>::add (T const & thing, Cursor<T> &after_me)
82 if (!size_) { // not much choice if list is empty
83 bottom_ = top_ = new Link<T>( thing);
87 else { // add at aprioprate place
90 Link<T> *p =after_me.pointer();
92 if (p == bottom_) // adjust bottom_ if necessary.
101 List<T>::insert (T const & thing, Cursor<T> &before_me)
105 bottom_ = top_ = new Link<T>( thing);
115 Link<T> *p = before_me.pointer() ;
119 top_ = p->previous();
128 List<T>::concatenate (List<T> const&s)
130 Cursor<T> b (bottom());
131 for (Cursor<T> c (s); c.ok(); c++)