modules/up/src/gnug++/NormalTermPtr.DLList.h
/* [<][>][^][v][top][bottom][index][help] */
FUNCTIONS
This source file includes following functions.
- NormalTermPtrDLListNode
- NormalTermPtrDLListNode
- NormalTermPtrDLListNode
- NormalTermPtrDLList
- NormalTermPtrDLListTrav
- NormalTermPtrDLList
- empty
- next
- prev
- first
- last
- front
- rear
1 // This may look like C code, but it is really -*- C++ -*-
2 // WARNING: This file is obsolete. Use ../DLList.h, if you can.
3 /*
4 Copyright (C) 1988 Free Software Foundation
5 written by Doug Lea (dl@rocky.oswego.edu)
6
7 This file is part of the GNU C++ Library. This library is free
8 software; you can redistribute it and/or modify it under the terms of
9 the GNU Library General Public License as published by the Free
10 Software Foundation; either version 2 of the License, or (at your
11 option) any later version. This library is distributed in the hope
12 that it will be useful, but WITHOUT ANY WARRANTY; without even the
13 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 PURPOSE. See the GNU Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19
20
21 #ifndef _NormalTermPtrDLList_h
22 #ifdef __GNUG__
23 #pragma interface
24 #endif
25 #define _NormalTermPtrDLList_h 1
26
27 #include "config.h"
28 #include "Pix.h"
29 #include "NormalTermPtr.defs.h"
30
31 #ifndef _NormalTermPtrDLListNode_h
32 #define _NormalTermPtrDLListNode_h 1
33
34 struct NormalTermPtrDLListNode
35 {
36 NormalTermPtrDLListNode* bk;
37 NormalTermPtrDLListNode* fd;
38 NormalTermPtr hd;
39 NormalTermPtrDLListNode();
40 NormalTermPtrDLListNode(const NormalTermPtr h,
41 NormalTermPtrDLListNode* p = 0,
42 NormalTermPtrDLListNode* n = 0);
43 ~NormalTermPtrDLListNode();
44 };
45
46 inline NormalTermPtrDLListNode::NormalTermPtrDLListNode() {}
/* [<][>][^][v][top][bottom][index][help] */
47
48 inline NormalTermPtrDLListNode::NormalTermPtrDLListNode(const NormalTermPtr h, NormalTermPtrDLListNode* p,
/* [<][>][^][v][top][bottom][index][help] */
49 NormalTermPtrDLListNode* n)
50 :bk(p), fd(n), hd(h) {}
51
52 inline NormalTermPtrDLListNode::~NormalTermPtrDLListNode() {}
/* [<][>][^][v][top][bottom][index][help] */
53
54 typedef NormalTermPtrDLListNode* NormalTermPtrDLListNodePtr;
55
56 #endif
57
58 class NormalTermPtrDLList
/* [<][>][^][v][top][bottom][index][help] */
59 {
60 friend class NormalTermPtrDLListTrav;
/* [<][>][^][v][top][bottom][index][help] */
61
62 NormalTermPtrDLListNode* h;
63
64 public:
65 NormalTermPtrDLList();
66 NormalTermPtrDLList(const NormalTermPtrDLList& a);
67 ~NormalTermPtrDLList();
68
69 NormalTermPtrDLList& operator = (const NormalTermPtrDLList& a);
70
71 int empty();
72 int length();
73
74 void clear();
75
76 Pix prepend(NormalTermPtr item);
77 Pix append(NormalTermPtr item);
78 void join(NormalTermPtrDLList&);
79
80 NormalTermPtr& front();
81 NormalTermPtr remove_front();
82 void del_front();
83
84 NormalTermPtr& rear();
85 NormalTermPtr remove_rear();
86 void del_rear();
87
88 NormalTermPtr& operator () (Pix p);
89 Pix first();
90 Pix last();
91 void next(Pix& p);
92 void prev(Pix& p);
93 int owns(Pix p);
94 Pix ins_after(Pix p, NormalTermPtr item);
95 Pix ins_before(Pix p, NormalTermPtr item);
96 void del(Pix& p, int dir = 1);
97 void del_after(Pix& p);
98
99 void error(const char* msg);
100 int OK();
101 };
102
103
104 inline NormalTermPtrDLList::~NormalTermPtrDLList()
105 {
106 clear();
107 }
108
109 inline NormalTermPtrDLList::NormalTermPtrDLList()
/* [<][>][^][v][top][bottom][index][help] */
110 {
111 h = 0;
112 }
113
114 inline int NormalTermPtrDLList::empty()
/* [<][>][^][v][top][bottom][index][help] */
115 {
116 return h == 0;
117 }
118
119
120 inline void NormalTermPtrDLList::next(Pix& p)
/* [<][>][^][v][top][bottom][index][help] */
121 {
122 p = (p == 0 || p == h->bk)? 0 : Pix(((NormalTermPtrDLListNode*)p)->fd);
123 }
124
125 inline void NormalTermPtrDLList::prev(Pix& p)
/* [<][>][^][v][top][bottom][index][help] */
126 {
127 p = (p == 0 || p == h)? 0 : Pix(((NormalTermPtrDLListNode*)p)->bk);
128 }
129
130 inline Pix NormalTermPtrDLList::first()
/* [<][>][^][v][top][bottom][index][help] */
131 {
132 return Pix(h);
133 }
134
135 inline Pix NormalTermPtrDLList::last()
/* [<][>][^][v][top][bottom][index][help] */
136 {
137 return (h == 0)? 0 : Pix(h->bk);
138 }
139
140 inline NormalTermPtr& NormalTermPtrDLList::operator () (Pix p)
141 {
142 if (p == 0) error("null Pix");
143 return ((NormalTermPtrDLListNode*)p)->hd;
144 }
145
146 inline NormalTermPtr& NormalTermPtrDLList::front()
/* [<][>][^][v][top][bottom][index][help] */
147 {
148 if (h == 0) error("front: empty list");
149 return h->hd;
150 }
151
152 inline NormalTermPtr& NormalTermPtrDLList::rear()
/* [<][>][^][v][top][bottom][index][help] */
153 {
154 if (h == 0) error("rear: empty list");
155 return h->bk->hd;
156 }
157
158 #endif