Elm  2
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
SLList.h
1 /*
2  * $Id$
3  * Copyright (c) 2004, IRIT-UPS.
4  *
5  * elm/inhstruct/SLList.h -- SLList class interface.
6  */
7 #ifndef ELM_INHSTRUCT_SLLIST_H
8 #define ELM_INHSTRUCT_SLLIST_H
9 
10 namespace elm { namespace inhstruct {
11 
12 // Defined classes
13 class SLNode;
14 class SLList;
15 
16 // SLNode class
17 class SLNode {
18  SLNode *nxt;
19  friend class SLList;
20 public:
21  inline SLNode(void);
22  inline SLNode *next(void) const;
23  inline void insertAfter(SLNode *node);
24  inline void removeNext(void);
25 };
26 
27 // SLList class
28 class SLList {
29  SLNode *fst;
30 public:
31  inline SLList(void);
32  inline SLNode *first(void) const;
33  SLNode *last(void) const;
34  int count(void) const;
35  inline bool isEmpty(void) const;
36 
37  inline void addFirst(SLNode *node);
38  void addLast(SLNode *node);
39  inline void removeFirst(void);
40  void removeLast(void);
41 };
42 
43 // SLNode inlines
44 inline SLNode::SLNode(void): nxt(0) {
45 }
46 inline SLNode *SLNode::next(void) const {
47  return nxt;
48 }
49 inline void SLNode::insertAfter(SLNode *node) {
50  node->nxt = nxt;
51  nxt = node;
52 }
53 inline void SLNode::removeNext(void) {
54  nxt = nxt->nxt;
55 }
56 
57 // SLList inlines
58 inline SLList::SLList(void): fst(0) {
59 }
60 inline SLNode *SLList::first(void) const {
61  return fst;
62 }
63 inline void SLList::addFirst(SLNode *node) {
64  node->nxt = fst;
65  fst = node;
66 }
67 inline void SLList::removeFirst(void) {
68  fst = fst->next();
69 }
70 inline bool SLList::isEmpty(void) const {
71  return !fst;
72 }
73 
74 } } // elm::inhstruct
75 
76 #endif // ELM_INHSTRUCT_SLLIST_H
elm::inhstruct::SLNode::SLNode
SLNode(void)
Definition: SLList.h:44
elm::inhstruct::SLList::removeLast
void removeLast(void)
Definition: inhstruct_SLList.cpp:102
elm::inhstruct::SLNode
Definition: SLList.h:17
elm::inhstruct::SLList::count
int count(void) const
Definition: inhstruct_SLList.cpp:74
elm::inhstruct::SLNode::removeNext
void removeNext(void)
Definition: SLList.h:53
elm::inhstruct::SLList::first
SLNode * first(void) const
Definition: SLList.h:60
elm::inhstruct::SLList::addLast
void addLast(SLNode *node)
Definition: inhstruct_SLList.cpp:90
elm::inhstruct::SLList
Definition: SLList.h:28
elm::inhstruct::SLList::addFirst
void addFirst(SLNode *node)
Definition: SLList.h:63
elm::inhstruct::SLList::removeFirst
void removeFirst(void)
Definition: SLList.h:67
elm::inhstruct::SLNode::next
SLNode * next(void) const
Definition: SLList.h:46
elm
Definition: adapter.h:26
elm::inhstruct::SLList::last
SLNode * last(void) const
Definition: inhstruct_SLList.cpp:59
elm::inhstruct::SLList::isEmpty
bool isEmpty(void) const
Definition: SLList.h:70
elm::inhstruct::SLNode::insertAfter
void insertAfter(SLNode *node)
Definition: SLList.h:49
elm::inhstruct::SLList::SLList
SLList(void)
Definition: SLList.h:58