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