Oh GACK! src-clean doesn't quite work that easily since cleandist rebuilds the
[unix-history] / gnu / lib / libg++ / g++-include / gen / SLList.hP
CommitLineData
e87b4ac1
PR
1// This may look like C code, but it is really -*- C++ -*-
2// WARNING: This file is obsolete. Use ../SLList.h, if you can.
3/*
4Copyright (C) 1988 Free Software Foundation
5 written by Doug Lea (dl@rocky.oswego.edu)
6
7This file is part of the GNU C++ Library. This library is free
8software; you can redistribute it and/or modify it under the terms of
9the GNU Library General Public License as published by the Free
10Software Foundation; either version 2 of the License, or (at your
11option) any later version. This library is distributed in the hope
12that it will be useful, but WITHOUT ANY WARRANTY; without even the
13implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14PURPOSE. See the GNU Library General Public License for more details.
15You should have received a copy of the GNU Library General Public
16License along with this library; if not, write to the Free Software
17Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
18*/
19
20
21#ifndef _<T>SLList_h
22#ifdef __GNUG__
23#pragma interface
24#endif
25#define _<T>SLList_h 1
26
27#include <Pix.h>
28#include "<T>.defs.h"
29
30#ifndef _<T>SLListNode_h
31#define _<T>SLListNode_h 1
32
33struct <T>SLListNode
34{
35 <T>SLListNode* tl;
36 <T> hd;
37 <T>SLListNode() { }
38 <T>SLListNode(const <T&> h, <T>SLListNode* t = 0);
39 ~<T>SLListNode() { }
40};
41
42
43inline <T>SLListNode::<T>SLListNode(const <T&> h, <T>SLListNode* t)
44:hd(h), tl(t) {}
45
46typedef <T>SLListNode* <T>SLListNodePtr;
47
48#endif
49
50
51class <T>SLList
52{
53protected:
54 <T>SLListNode* last;
55
56public:
57 <T>SLList();
58 <T>SLList(const <T>SLList& a);
59 ~<T>SLList();
60
61 <T>SLList& operator = (const <T>SLList& a);
62
63 int empty();
64 int length();
65
66 void clear();
67
68 Pix prepend(<T&> item);
69 Pix append(<T&> item);
70
71 void join(<T>SLList&);
72
73 Pix prepend(<T>SLListNode*);
74 Pix append(<T>SLListNode*);
75
76 <T>& operator () (Pix p);
77 Pix first();
78 void next(Pix& p);
79 int owns(Pix p);
80 Pix ins_after(Pix p, <T&> item);
81 void del_after(Pix p);
82
83 <T>& front();
84 <T>& rear();
85 <T> remove_front();
86 int remove_front(<T>& x);
87 void del_front();
88
89 void error(const char* msg);
90 int OK();
91};
92
93inline <T>SLList::~<T>SLList()
94{
95 clear();
96}
97
98inline <T>SLList::<T>SLList()
99{
100 last = 0;
101}
102
103inline int <T>SLList::empty()
104{
105 return last == 0;
106}
107
108
109inline Pix <T>SLList::first()
110{
111 return (last == 0)? 0 : Pix(last->tl);
112}
113
114inline void <T>SLList::next(Pix& p)
115{
116 p = (p == 0 || p == last)? 0 : Pix(((<T>SLListNode*)(p))->tl);
117}
118
119inline <T>& <T>SLList::operator () (Pix p)
120{
121 if (p == 0) error("null Pix");
122 return ((<T>SLListNode*)(p))->hd;
123}
124
125inline <T>& <T>SLList::front()
126{
127 if (last == 0) error("front: empty list");
128 return last->tl->hd;
129}
130
131inline <T>& <T>SLList::rear()
132{
133 if (last == 0) error("rear: empty list");
134 return last->hd;
135}
136
137#endif