modules/up/src/gnug++/SymbolConjunctPtr.SplayBag.h
/* [<][>][^][v][top][bottom][index][help] */
FUNCTIONS
This source file includes following functions.
- SymbolConjunctPtrSplayBag
- SymbolConjunctPtrSplayBag
- SymbolConjunctPtrSplayBag
- SymbolConjunctPtrSplayBag
- first
- last
- next
- prev
- clear
- contains
- del
- del_this
1 // This may look like C code, but it is really -*- C++ -*-
2 /*
3 Copyright (C) 1988 Free Software Foundation
4 written by Doug Lea (dl@rocky.oswego.edu)
5
6 This file is part of the GNU C++ Library. This library is free
7 software; you can redistribute it and/or modify it under the terms of
8 the GNU Library General Public License as published by the Free
9 Software Foundation; either version 2 of the License, or (at your
10 option) any later version. This library is distributed in the hope
11 that it will be useful, but WITHOUT ANY WARRANTY; without even the
12 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
13 PURPOSE. See the GNU Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public
15 License along with this library; if not, write to the Free Software
16 Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
17 */
18 // This may look like C code, but it is really -*- C++ -*-
19 /*
20 Copyright (C) 1988, 1982 Free Software Foundation
21 written by Doug Lea (dl@rocky.oswego.edu)
22
23 This file is part of the GNU C++ Library. This library is free
24 software; you can redistribute it and/or modify it under the terms of
25 the GNU Library General Public License as published by the Free
26 Software Foundation; either version 2 of the License, or (at your
27 option) any later version. This library is distributed in the hope
28 that it will be useful, but WITHOUT ANY WARRANTY; without even the
29 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
30 PURPOSE. See the GNU Library General Public License for more details.
31 You should have received a copy of the GNU Library General Public
32 License along with this library; if not, write to the Free Software
33 Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
34 */
35
36
37 #ifndef _SymbolConjunctPtrSplayBag_h
38 #ifdef __GNUG__
39 #pragma interface
40 #endif
41 #define _SymbolConjunctPtrSplayBag_h 1
42
43 #include "config.h"
44 #include "SymbolConjunctPtr.Bag.h"
45 #include "SymbolConjunctPtr.SplayNode.h"
46
47 class SymbolConjunctPtrSplayBag : public SymbolConjunctPtrBag
/* [<][>][^][v][top][bottom][index][help] */
48 {
49 protected:
50 SymbolConjunctPtrSplayNode* root;
51
52 SymbolConjunctPtrSplayNode* leftmost();
53 SymbolConjunctPtrSplayNode* rightmost();
54 SymbolConjunctPtrSplayNode* pred(SymbolConjunctPtrSplayNode* t);
55 SymbolConjunctPtrSplayNode* succ(SymbolConjunctPtrSplayNode* t);
56 void _kill(SymbolConjunctPtrSplayNode* t);
57 SymbolConjunctPtrSplayNode* _copy(SymbolConjunctPtrSplayNode* t);
58 void _del(SymbolConjunctPtrSplayNode* t);
59
60 public:
61 SymbolConjunctPtrSplayBag();
62 SymbolConjunctPtrSplayBag(SymbolConjunctPtrSplayBag& a);
63 ~SymbolConjunctPtrSplayBag();
64
65 Pix add(SymbolConjunctPtr item);
66 void del(SymbolConjunctPtr item);
67 void del_this(Pix i); // added by cengiz alaettinoglu
68 void remove(SymbolConjunctPtr item);
69 int nof(SymbolConjunctPtr item);
70 int contains(SymbolConjunctPtr item);
71
72 void clear();
73
74 Pix first();
75 void next(Pix& i);
76 SymbolConjunctPtr& operator () (Pix i);
77 Pix seek(SymbolConjunctPtr item, Pix from = 0);
78
79 Pix last();
80 void prev(Pix& i);
81
82 int OK();
83 };
84
85
86 inline SymbolConjunctPtrSplayBag::~SymbolConjunctPtrSplayBag()
/* [<][>][^][v][top][bottom][index][help] */
87 {
88 _kill(root);
89 }
90
91 inline SymbolConjunctPtrSplayBag::SymbolConjunctPtrSplayBag()
/* [<][>][^][v][top][bottom][index][help] */
92 {
93 root = 0;
94 count = 0;
95 }
96
97 inline SymbolConjunctPtrSplayBag::SymbolConjunctPtrSplayBag(SymbolConjunctPtrSplayBag& b)
/* [<][>][^][v][top][bottom][index][help] */
98 {
99 count = b.count;
100 root = _copy(b.root);
101 }
102
103 inline Pix SymbolConjunctPtrSplayBag::first()
/* [<][>][^][v][top][bottom][index][help] */
104 {
105 return Pix(leftmost());
106 }
107
108 inline Pix SymbolConjunctPtrSplayBag::last()
/* [<][>][^][v][top][bottom][index][help] */
109 {
110 return Pix(rightmost());
111 }
112
113 inline void SymbolConjunctPtrSplayBag::next(Pix& i)
/* [<][>][^][v][top][bottom][index][help] */
114 {
115 if (i != 0) i = Pix(succ((SymbolConjunctPtrSplayNode*)i));
116 }
117
118 inline void SymbolConjunctPtrSplayBag::prev(Pix& i)
/* [<][>][^][v][top][bottom][index][help] */
119 {
120 if (i != 0) i = Pix(pred((SymbolConjunctPtrSplayNode*)i));
121 }
122
123 inline SymbolConjunctPtr& SymbolConjunctPtrSplayBag::operator () (Pix i)
124 {
125 if (i == 0) error("null Pix");
126 return ((SymbolConjunctPtrSplayNode*)i)->item;
127 }
128
129 inline void SymbolConjunctPtrSplayBag::clear()
/* [<][>][^][v][top][bottom][index][help] */
130 {
131 _kill(root);
132 count = 0;
133 root = 0;
134 }
135
136 inline int SymbolConjunctPtrSplayBag::contains(SymbolConjunctPtr key)
/* [<][>][^][v][top][bottom][index][help] */
137 {
138 return seek(key) != 0;
139 }
140
141 inline void SymbolConjunctPtrSplayBag::del(SymbolConjunctPtr key)
/* [<][>][^][v][top][bottom][index][help] */
142 {
143 _del((SymbolConjunctPtrSplayNode*)(seek(key)));
144 }
145
146 // added by Cengiz Alaettinoglu
147 inline void SymbolConjunctPtrSplayBag::del_this(Pix i)
/* [<][>][^][v][top][bottom][index][help] */
148 {
149 _del((SymbolConjunctPtrSplayNode*)i);
150 }
151
152 #endif