Elm  1.0
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
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
void removeFirst(void)
Definition: SLList.h:67
SLNode * next(void) const
Definition: SLList.h:46
SLNode * last(void) const
Definition: inhstruct_SLList.cpp:59
SLList(void)
Definition: SLList.h:58
SLNode(void)
Definition: SLList.h:44
int count(void) const
Definition: inhstruct_SLList.cpp:74
void addFirst(SLNode *node)
Definition: SLList.h:63
SLNode * first(void) const
Definition: SLList.h:60
void removeLast(void)
Definition: inhstruct_SLList.cpp:102
Definition: SLList.h:17
Definition: SLList.h:28
void addLast(SLNode *node)
Definition: inhstruct_SLList.cpp:90
void removeNext(void)
Definition: SLList.h:53
void insertAfter(SLNode *node)
Definition: SLList.h:49
bool isEmpty(void) const
Definition: SLList.h:70