2 cons.hh -- declare LISP like datatypes
4 source file of the GNU LilyPond music typesetter
6 (c) 1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
39 class Killing_cons
: public Cons
<T
>
42 Killing_cons (T
*t
, Cons
<T
> *p
)
46 virtual ~Killing_cons ();
50 /// remove the link pointed to by *p.
52 Cons
<T
> *remove_cons (Cons
<T
> **pp
)
60 template<class T
> int cons_list_size (Cons
<T
> *l
)
76 Cons
<T
> * last_cons (Cons
<T
> * head
)
78 while (head
&& head
->next_
)
89 (*tail_) is either the head_ pointer, or a next_ pointer from the list.
99 Cons
<T
> ** nil_pointer_address_
;
107 nil_pointer_address_
= &head_
;
111 append (new Cons
<T
> (c
,0));
113 void append (Cons
<T
> *c
)
116 *nil_pointer_address_
= c
;
117 while (*nil_pointer_address_
)
118 nil_pointer_address_
= & (*nil_pointer_address_
)->next_
;
121 PRE: *pp should either be the head_ pointer, or the next_ pointer
124 Cons
<T
> *remove_cons (Cons
<T
> **pp
)
126 if (& (*pp
)->next_
== nil_pointer_address_
)
127 nil_pointer_address_
= pp
;
129 return ::remove_cons (pp
);
132 /// junk everything after the first I elements.
133 void truncate (int i
)
135 Cons
<T
> **p
= &head_
;
136 for (; *p
&& i
; p
= & ((*p
)->next_
))
146 nil_pointer_address_
= p
;
160 return cons_list_size (head_
);
166 void copy_killing_cons_list (Cons_list
<T
>&, Cons
<T
> *src
);
169 clone_killing_cons_list (Cons_list
<T
>&, Cons
<T
> *src
);