blob: 1516e16642561cd9b384d57c370232ee86f87fd3 (
about) (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
// list.hh
#ifndef __LIST_HH
#define __LIST_HH
class ostream;
template<class T> class Cursor;
template<class T> class Link;
/// all purpose list
template<class T>
class List
{
public:
List(List const&src);
/// construct empty list
List();
/// construct list from first item.
List( const T& thing );
virtual ~List();
Cursor<T> bottom();
int size() const;
Cursor<T> top();
void OK() const;
protected:
friend class Cursor<T>;
friend class Link<T>;
/// make *this empty
void set_empty();
/**
WARNING: contents lost, and not deleted.
*/
/// add after after_me
void add( const T& thing, Cursor<T> after_me );
/// put thing before #before_me#
void insert( const T& thing, Cursor<T> before_me );
virtual void remove( Cursor<T> me );
/**
Remove link pointed to by me.
POST
none; WARNING: do not use #me#.
*/
int size_;
Link<T>* top_;
Link<T>* bottom_;
};
/**
a doubly linked list;
List can be seen as all items written down on paper,
from top to bottom
class Cursor is used to extend List
items are always stored as copies in List, but:
#List<String># : copies of #String# stored
#List<String*># : copies of #String*# stored!
(do not use, use \Ref{PointerList} #<String*># instead.)
{\bf note:}
retrieving "invalid" cursors, i.e.
#top()/bottom()# from empty list, #find()# without success,
results in a nonvalid Cursor ( #!ok()# )
INVARIANTEN!
*/
#include "list.inl"
#include "cursor.hh"
// instantiate a template: explicit instantiation.
#define L_instantiate(a) template class List<a>; template class Cursor<a>; \
template class Link<a>
#endif // __LIST_HH //
|