Introduction of BSDArchitecture
[oweals/cde.git] / cde / programs / nsgmls / IListBase.h
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these librararies and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23 /* $XConsortium: IListBase.h /main/1 1996/07/29 16:53:26 cde-hp $ */
24 // Copyright (c) 1994 James Clark
25 // See the file COPYING for copying permission.
26
27 #ifndef IListBase_INCLUDED
28 #define IListBase_INCLUDED 1
29
30 #include "Link.h"
31 #include "Boolean.h"
32
33 #ifdef SP_NAMESPACE
34 namespace SP_NAMESPACE {
35 #endif
36
37 class SP_API IListBase {
38 public:
39   IListBase();
40   IListBase(Link *);
41   void  append(Link *);
42   void insert(Link *);
43   Link *head() const;
44   Boolean empty() const;
45   Link *get();
46   void remove(Link *);
47   void swap(IListBase &);
48   void clear();
49 private:
50   Link *head_;
51 friend class IListIterBase;
52 };
53
54 inline
55 IListBase::IListBase() : head_(0)
56 {
57 }
58
59 inline
60 IListBase::IListBase(Link *head) : head_(head)
61 {
62 }
63
64 inline
65 void IListBase::insert(Link *p)
66 {
67   p->next_ = head_;
68   head_ = p;
69 }
70
71 inline
72 Link *IListBase::head() const
73 {
74   return head_;
75 }
76
77 inline
78 Boolean IListBase::empty() const
79 {
80   return head_ == 0;
81 }
82
83 inline
84 Link *IListBase::get()
85 {
86   Link *tem = head_;
87   head_ = head_->next_;
88   return tem;
89 }
90
91 inline
92 void IListBase::swap(IListBase &list)
93 {
94   Link *tem = head_;
95   head_ = list.head_;
96   list.head_ = tem;
97 }
98
99 #ifdef SP_NAMESPACE
100 }
101 #endif
102
103 #endif /* not IListBase_INCLUDED */