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)
69 Cons<T> *last_cons (Cons<T> *head)
71 while (head && head->next_)
80 (*tail_) is either the head_ pointer, or a next_ pointer from the list.
90 Cons<T> ** nil_pointer_address_;
98 nil_pointer_address_ = &head_;
102 append (new Cons<T> (c, 0));
104 void append (Cons<T> *c)
107 *nil_pointer_address_ = c;
108 while (*nil_pointer_address_)
109 nil_pointer_address_ = &(*nil_pointer_address_)->next_;
112 PRE: *pp should either be the head_ pointer, or the next_ pointer
115 Cons<T> *remove_cons (Cons<T> **pp)
117 if (& (*pp)->next_ == nil_pointer_address_)
118 nil_pointer_address_ = pp;
120 return ::remove_cons (pp);
123 /// junk everything after the first I elements.
124 void truncate (int i)
126 Cons<T> **p = &head_;
127 for (; *p && i; p = &((*p)->next_))
135 nil_pointer_address_ = p;
149 return cons_list_size (head_);
154 void copy_killing_cons_list (Cons_list<T> &, Cons<T> *src);
157 clone_killing_cons_list (Cons_list<T> &, Cons<T> *src);