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++)
70 \item if #after_me# is #ok()#, add after #after_me#, else
71 \item if list !empty simply add to bottom, else
72 \item list is empty: create first \Ref{Link} and initialize
78 List<T>::add (T const & thing, Cursor<T> &after_me)
80 if (!size_) { // not much choice if list is empty
81 bottom_ = top_ = new Link<T>( thing);
84 } else { // add at aprioprate place
87 Link<T> *p =after_me.pointer();
89 if (p == bottom_) // adjust bottom_ if necessary.
98 List<T>::insert (T const & thing, Cursor<T> &before_me)
101 bottom_ = top_ = new Link<T>( thing);
109 Link<T> *p = before_me.pointer() ;
113 top_ = p->previous();
122 List<T>::concatenate (List<T> const&s)
124 Cursor<T> b (bottom());
125 for (Cursor<T> c (s); c.ok(); c++) {