14 link(const T& t): item(t), prev(0), next(0)
16 link(const T& t, link<T> *p, link<T> *n): item(t), prev(p), next(n)
24 List_DL(const List_DL&);
27 void append(const T& item);
28 void prepend(const T& item);
29 void insert(const T& item, Pix x, bool before);
32 { T tmp; remove(x, tmp); }
33 void remove(Pix& x, T& item);
37 unsigned length() const
51 void next(Pix& x) const
52 { if (0 != x) x = ((link<T> *) x)->next; }
53 void prev(Pix& x) const
54 { if (0 != x) x = ((link<T> *) x)->prev; }
55 T& operator()(Pix x) const
56 { return ((link<T> *) x)->item; }
60 List_DL<T>::List_DL():
66 List_DL<T>::List_DL(const List_DL& other):
70 for (Pix x=other.first(); 0 != x; other.next(x))
75 List_DL<T>::~List_DL()
82 List_DL<T>::append(const T& item)
86 head = new link<T>(item);
89 tail->next = new link<T>(item, tail, 0);
96 List_DL<T>::prepend(const T& item)
100 head = new link<T>(item);
103 head = new link<T>(item, 0, head);
111 List_DL<T>::insert(const T& item, Pix x, bool before = TRUE)
113 link<T> *l = (link<T> *) x;
116 if (0 == l || l == head) {
119 link<T> *n = new link<T>(item, l->prev, l);
124 if (0 == l || l == tail) {
127 link<T> *n = new link<T>(item, l, l->next);
136 List_DL<T>::remove(Pix& x, T& item)
138 link<T> *l = (link<T> *) x;
149 // more than one item in the list
155 } else if (l == tail) {
161 l->next->prev = l->prev;
162 l->prev->next = l->next;
173 for (l=head; 0 != l; l=succ) {
182 class List_DLS: public List_DL<T> {
184 List_DLS(): List_DL<T>()
186 List_DLS(const List_DLS& other): List_DL<T>(other)
189 bool contains(const T& item) const
190 { return search(item) != 0 ? TRUE: FALSE; }
191 Pix search(const T&) const;
196 List_DLS<T>::search(const T& item) const
198 for (Pix x=this->first(); 0 != x; this->next(x)) {
199 if (item == this->operator()(x)) // { dg-error "match" } const subversion
200 // { dg-message "candidate" "candidate note" { target *-*-* } 199 }
207 class List_DLSp: public List_DL<T> {
209 List_DLSp(): List_DL<T>()
211 List_DLSp(const List_DLSp& other): List_DL<T>(other)
214 bool contains(const T& item) const
215 #ifndef INTERNAL_ERROR
218 { return search(item) != 0 ? TRUE: FALSE; }
220 Pix search(const T&) const;
225 List_DLSp<T>::contains(const T& item) const
227 for (Pix x=this->first(); 0 != x; this->next(x)) {
228 if (*item == *(this->operator()(x)))
238 Set(const Set& other);
240 virtual void add(const T& item);
242 void remove(const T& item)
243 { Pix x = search(item); remove(x); }
245 { T tmp; remove(x, tmp); }
246 virtual void remove(Pix& x, T& item);
248 virtual void clear();
250 virtual bool contains(const T&) const;
251 virtual Pix search(const T&) const;
253 virtual unsigned length() const;
255 virtual Pix first() const;
256 virtual void next(Pix& x) const;
257 virtual T& operator()(Pix x) const;
265 Set<T>::Set(const Set& other)
270 class Set_DL: public List_DLS<T> {
273 Set_DL(const Set_DL& other);
275 void add(const T& item)
276 { list.append(item); }
277 void remove(Pix& x, T& item)
278 { list.remove(x, item); }
283 bool contains(const T& item) const
284 { return list.contains(item); }
285 Pix search(const T& item) const
286 { return list.search(item); }
288 unsigned length() const
289 { return list.length(); }
292 { return list.first(); }
293 void next(Pix& x) const
295 T& operator()(Pix x) const
302 class Set_DLp: public List_DLSp<T> {
305 Set_DLp(const Set_DLp& other);
307 void add(const T& item)
308 { list.append(item); }
309 void remove(Pix& x, T& item)
310 { list.remove(x, item); }
315 bool contains(const T& item) const
316 { return list.contains(item); }
317 Pix search(const T& item) const
318 { return list.search(item); }
320 unsigned length() const
321 { return list.length(); }
324 { return list.first(); }
325 void next(Pix& x) const
327 T& operator()(Pix x) const
336 List_DL<vertex<T> *> fanout;
338 vertex(): item(), fanout() // { dg-bogus "" }
340 vertex(const T& i): item(), fanout() // { dg-bogus "" }
351 void add(const T& from, const T& to);
352 bool contains(const T& from, const T& to) const;
355 { vertices.clear(); }
357 unsigned lengthV() const
358 { return vertices.length(); }
361 { return vertices.first(); }
362 void nextV(Pix& x) const
363 { vertices.next(x); }
365 { return vertices(x).item; }
367 Pix firstV1(Pix vx) const;
368 void nextV1(Pix vx, Pix& x) const;
369 T& V1(Pix vx, Pix x) const;
371 vertex<T> *lookup(const T& from) const;
372 vertex<T> *lookup_new(const T& from);
374 List_DLS<vertex<T> > vertices;
383 Graph<T>::Graph(const Graph& other):
386 for (Pix vx=firstV(); 0 != vx; nextV(vx)) {
387 for (Pix vx1=firstV1(vx); 0 != vx1; nextV1(vx, vx1)) {
388 add(V(vx), V1(vx, vx1));
401 Graph<T>::add(const T& from, const T& to)
403 vertex<T> *fromv = lookup_new(from);
406 vertex<T> *tov = lookup_new(to);
407 fromv->fanout.append(tov);
412 Graph<T>::contains(const T& from, const T& to) const
414 vertex<T> *fromv = lookup(from);
418 for (Pix x=fromv->fanout.first(); 0 != x; fromv->fanout.next(x)) {
419 if (fromv->fanout(x)->item == to)
428 Graph<T>::lookup(const T& from) const
430 for (Pix x=vertices.first(); 0 != x; vertices.next(x)) {
431 if (vertices(x).item == from)
439 Graph<T>::lookup_new(const T& from)
441 vertex<T> *v = lookup(from);
443 vertices.append(from);
444 return &vertices(vertices.last());
451 Graph<T>::firstV1(Pix vx) const
453 vertex<T> *v = (vertex<T> *) vx;
454 return v->fanout.first();
459 Graph<T>::nextV1(Pix vx, Pix& x) const
461 vertex<T> *v = (vertex<T> *) vx;
462 return v->fanout.next(x);
467 Graph<T>::V1(Pix vx, Pix x) const
469 vertex<T> *v = (vertex<T> *) vx;
474 class STRLIdentifier;
476 extern int x(List_DL<STRLIdentifier *>);
477 extern int x(List_DLS<STRLIdentifier *>);
479 extern int x(Set<STRLIdentifier *>);
480 extern int x(Set_DL<STRLIdentifier *>);
481 extern int x(Set_DLp<STRLIdentifier *>);
483 extern int x(Graph<STRLIdentifier *>);
485 class STRLIdentifier {
489 extern int operator==(vertex<STRLIdentifier*>&, vertex<STRLIdentifier*>&); // { dg-message "note" } const subversion
490 extern int operator==(STRLIdentifier&, STRLIdentifier&); // { dg-message "note" } fn ref in err msg
492 extern int x(List_DLSp<STRLIdentifier *>);
494 template class Graph<STRLIdentifier *>;
495 template class List_DLS<vertex<STRLIdentifier *> >;