1 //////////////////////////////////////////////////////////////////////////////
4 // ADLib, Prop and their related set of tools and documentation are in the
5 // public domain. The author(s) of this software reserve no copyrights on
6 // the source code and any code generated using the tools. You are encouraged
7 // to use ADLib and Prop to develop software, in both academic and commercial
8 // settings, and are free to incorporate any part of ADLib and Prop into
11 // Although you are under no obligation to do so, we strongly recommend that
12 // you give away all software developed using our tools.
14 // We also ask that credit be given to us when ADLib and/or Prop are used in
15 // your programs, and that this notice be preserved intact in all the source
18 // This software is still under development and we welcome any suggestions
19 // and help from the users.
23 //////////////////////////////////////////////////////////////////////////////
25 #ifndef singly_linked_list_h
26 #define singly_linked_list_h
28 #include <AD/generic/generic.h>
29 #include <AD/contain/slink.h>
33 int len
; // current length of list
34 SLink
* front
; // front of the list
36 SList(const SList
&); // no copy constructor
37 void operator = (const SList
&); // no assignment
41 ///////////////////////////////////////////////////////////////
42 // Constructors and destructor
43 ///////////////////////////////////////////////////////////////
44 SList() : len(0), front(0) {}
47 ///////////////////////////////////////////////////////////////
49 ///////////////////////////////////////////////////////////////
50 int length() const { return len
; }
51 int capacity() const { return len
; }
52 Bool
is_empty() const { return len
== 0; }
53 Bool
is_full() const { return false; }
55 ///////////////////////////////////////////////////////////////
57 ///////////////////////////////////////////////////////////////
59 void insert_head(SLink
*);
60 SLink
* delete_head();
61 void insert_after(SLink
*, SLink
*);
63 ///////////////////////////////////////////////////////////////
65 ///////////////////////////////////////////////////////////////
66 SLink
* first() const { return front
; }
67 SLink
* next(SLink
* l
) const { return l
->next
; }
68 SLink
* circ_next(SLink
* l
) const { return l
->next
? l
->next
: front
; }