Initial import of the CDE 2.1.30 sources from the Open Group.
[oweals/cde.git] / cde / programs / nsgmls / IListBase.h
1 /* $XConsortium: IListBase.h /main/1 1996/07/29 16:53:26 cde-hp $ */
2 // Copyright (c) 1994 James Clark
3 // See the file COPYING for copying permission.
4
5 #ifndef IListBase_INCLUDED
6 #define IListBase_INCLUDED 1
7
8 #include "Link.h"
9 #include "Boolean.h"
10
11 #ifdef SP_NAMESPACE
12 namespace SP_NAMESPACE {
13 #endif
14
15 class SP_API IListBase {
16 public:
17   IListBase();
18   IListBase(Link *);
19   void  append(Link *);
20   void insert(Link *);
21   Link *head() const;
22   Boolean empty() const;
23   Link *get();
24   void remove(Link *);
25   void swap(IListBase &);
26   void clear();
27 private:
28   Link *head_;
29 friend class IListIterBase;
30 };
31
32 inline
33 IListBase::IListBase() : head_(0)
34 {
35 }
36
37 inline
38 IListBase::IListBase(Link *head) : head_(head)
39 {
40 }
41
42 inline
43 void IListBase::insert(Link *p)
44 {
45   p->next_ = head_;
46   head_ = p;
47 }
48
49 inline
50 Link *IListBase::head() const
51 {
52   return head_;
53 }
54
55 inline
56 Boolean IListBase::empty() const
57 {
58   return head_ == 0;
59 }
60
61 inline
62 Link *IListBase::get()
63 {
64   Link *tem = head_;
65   head_ = head_->next_;
66   return tem;
67 }
68
69 inline
70 void IListBase::swap(IListBase &list)
71 {
72   Link *tem = head_;
73   head_ = list.head_;
74   list.head_ = tem;
75 }
76
77 #ifdef SP_NAMESPACE
78 }
79 #endif
80
81 #endif /* not IListBase_INCLUDED */