2 cons.hh -- declare LISP like datatypes
4 source file of the GNU LilyPond music typesetter
6 (c) 1999--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
25 Cons (T *t, Cons<T>*c)
37 class Killing_cons : public Cons<T>
40 Killing_cons (T *t, Cons<T> *p)
44 virtual ~Killing_cons ();
47 /// remove the link pointed to by *p.
49 Cons<T> *remove_cons (Cons<T> **pp)
57 template<class T> int cons_list_size (Cons<T> *l)
70 Cons<T> * last_cons (Cons<T> * head)
72 while (head && head->next_)
83 (*tail_) is either the head_ pointer, or a next_ pointer from the list.
93 Cons<T> ** nil_pointer_address_;
101 nil_pointer_address_ = &head_;
105 append (new Cons<T> (c, 0));
107 void append (Cons<T> *c)
110 *nil_pointer_address_ = c;
111 while (*nil_pointer_address_)
112 nil_pointer_address_ = &(*nil_pointer_address_)->next_;
115 PRE: *pp should either be the head_ pointer, or the next_ pointer
118 Cons<T> *remove_cons (Cons<T> **pp)
120 if (& (*pp)->next_ == nil_pointer_address_)
121 nil_pointer_address_ = pp;
123 return ::remove_cons (pp);
126 /// junk everything after the first I elements.
127 void truncate (int i)
129 Cons<T> **p = &head_;
130 for (; *p && i; p = &((*p)->next_))
140 nil_pointer_address_ = p;
154 return cons_list_size (head_);
159 void copy_killing_cons_list (Cons_list<T>&, Cons<T> *src);
162 clone_killing_cons_list (Cons_list<T>&, Cons<T> *src);