xref: /onnv-gate/usr/src/cmd/man/src/util/nsgmls.src/include/IListBase.h (revision 0:68f95e015346)
1 // Copyright (c) 1994 James Clark
2 // See the file COPYING for copying permission.
3 #pragma ident	"%Z%%M%	%I%	%E% SMI"
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
IListBase()33 IListBase::IListBase() : head_(0)
34 {
35 }
36 
37 inline
IListBase(Link * head)38 IListBase::IListBase(Link *head) : head_(head)
39 {
40 }
41 
42 inline
insert(Link * p)43 void IListBase::insert(Link *p)
44 {
45   p->next_ = head_;
46   head_ = p;
47 }
48 
49 inline
head()50 Link *IListBase::head() const
51 {
52   return head_;
53 }
54 
55 inline
empty()56 Boolean IListBase::empty() const
57 {
58   return head_ == 0;
59 }
60 
61 inline
get()62 Link *IListBase::get()
63 {
64   Link *tem = head_;
65   head_ = head_->next_;
66   return tem;
67 }
68 
69 inline
swap(IListBase & list)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 */
82