2 cons.hh -- declare LISP like datatypes
4 source file of the GNU LilyPond music typesetter
6 (c) 1999--2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
26 Cons (T *t, Cons<T> *c)
38 class Killing_cons : public Cons<T>
41 Killing_cons (T *t, Cons<T> *p)
45 virtual ~Killing_cons ();
48 /// remove the link pointed to by *p.
50 Cons<T> *remove_cons (Cons<T> **pp)
58 template<class T> int cons_list_size (Cons<T> *l)
70 Cons<T> *last_cons (Cons<T> *head)
72 while (head && head->next_)
81 (*tail_) is either the head_ pointer, or a next_ pointer from the list.
91 Cons<T> ** nil_pointer_address_;
99 nil_pointer_address_ = &head_;
103 append (new Cons<T> (c, 0));
105 void append (Cons<T> *c)
108 *nil_pointer_address_ = c;
109 while (*nil_pointer_address_)
110 nil_pointer_address_ = &(*nil_pointer_address_)->next_;
113 PRE: *pp should either be the head_ pointer, or the next_ pointer
116 Cons<T> *remove_cons (Cons<T> **pp)
118 if (& (*pp)->next_ == nil_pointer_address_)
119 nil_pointer_address_ = pp;
121 return ::remove_cons (pp);
124 /// junk everything after the first I elements.
125 void truncate (int i)
127 Cons<T> **p = &head_;
128 for (; *p && i; p = &((*p)->next_))
136 nil_pointer_address_ = p;
150 return cons_list_size (head_);
155 void copy_killing_cons_list (Cons_list<T> &, Cons<T> *src);
158 clone_killing_cons_list (Cons_list<T> &, Cons<T> *src);