Commit | Line | Data |
---|---|---|
936f52d6 C |
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 GNU CC. | |
7 | ||
8 | GNU CC is distributed in the hope that it will be useful, | |
9 | but WITHOUT ANY WARRANTY. No author or distributor | |
10 | accepts responsibility to anyone for the consequences of using it | |
11 | or for whether it serves any particular purpose or works at all, | |
12 | unless he says so in writing. Refer to the GNU CC General Public | |
13 | License for full details. | |
14 | ||
15 | Everyone is granted permission to copy, modify and redistribute | |
16 | GNU CC, but only under the conditions described in the | |
17 | GNU CC General Public License. A copy of this license is | |
18 | supposed to have been given to you along with GNU CC so you | |
19 | can know your rights and responsibilities. It should be in a | |
20 | file named COPYING. Among other things, the copyright notice | |
21 | and this notice must be preserved on all copies. | |
22 | */ | |
23 | ||
24 | ||
25 | #ifndef _<T>OSLBag_h | |
26 | #ifdef __GNUG__ | |
27 | #pragma once | |
28 | #pragma interface | |
29 | #endif | |
30 | #define _<T>OSLBag_h 1 | |
31 | ||
32 | #include "<T>.Bag.h" | |
33 | #include "<T>.SLList.h" | |
34 | ||
35 | class <T>OSLBag : public <T>Bag | |
36 | { | |
37 | protected: | |
38 | <T>SLList p; | |
39 | ||
40 | public: | |
41 | <T>OSLBag(); | |
42 | <T>OSLBag(const <T>OSLBag&); | |
43 | ||
44 | Pix add(<T&> item); | |
45 | void del(<T&> item); | |
46 | void remove(<T&>item); | |
47 | ||
48 | int contains(<T&> item); | |
49 | int nof(<T&> item); | |
50 | ||
51 | void clear(); | |
52 | ||
53 | Pix first(); | |
54 | void next(Pix& i); | |
55 | <T>& operator () (Pix i); | |
56 | int owns(Pix i); | |
57 | Pix seek(<T&> item, Pix from = 0); | |
58 | ||
59 | int OK(); | |
60 | }; | |
61 | ||
62 | #if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) | |
63 | ||
64 | inline <T>OSLBag::<T>OSLBag() : p() { count = 0; } | |
65 | ||
66 | inline <T>OSLBag::<T>OSLBag(const <T>OSLBag& s) : p(s.p) { count = s.count; } | |
67 | ||
68 | inline Pix <T>OSLBag::first() | |
69 | { | |
70 | return p.first(); | |
71 | } | |
72 | ||
73 | inline void <T>OSLBag::next(Pix & idx) | |
74 | { | |
75 | p.next(idx); | |
76 | } | |
77 | ||
78 | inline <T>& <T>OSLBag::operator ()(Pix idx) | |
79 | { | |
80 | return p(idx); | |
81 | } | |
82 | ||
83 | inline void <T>OSLBag::clear() | |
84 | { | |
85 | count = 0; p.clear(); | |
86 | } | |
87 | ||
88 | inline int <T>OSLBag::owns (Pix idx) | |
89 | { | |
90 | return p.owns(idx); | |
91 | } | |
92 | ||
93 | inline int <T>OSLBag::contains(<T&> item) | |
94 | { | |
95 | return seek(item) != 0; | |
96 | } | |
97 | ||
98 | ||
99 | #endif | |
100 | #endif |