blob: 782b3da86eb77b3276f395d8777e714a1ab1defe (
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
|
#ifndef LIST_CC
#define LIST_CC
#include "list.hh"
template<class T>
void
List<T>::OK() const
{
int i = size_;
Link<T> *lp = top_;
while (i--) {
assert(lp);
lp->OK();
lp = lp->next();
}
assert(!lp);
i = size_;
lp = bottom_;
while (i--) {
assert(lp);
lp->OK();
lp = lp->previous();
}
assert(!lp);
}
template<class T>
Cursor<T>
List<T>::top()
{
// ?? waarvoor is deze if ?
if ( top_ ) // equivalent: if ( size_ )
{
Link<T>* t = top_->previous();
assert( t != top_ ); // silly link
while ( t )
{
assert(false); // this is even more silly.
top_ = t;
t = top_->previous();
}
}
// list empty: Cursor not ok()
return Cursor<T>( *this, top_ );
}
template<class T>
Cursor<T>
List<T>::bottom()
{
/* wat is dit voor zooi? kan dit niet weg?
(invarianten!)
*/
if ( bottom_ ) // equivalent: if ( size_ )
{
Link<T>* b = bottom_->next();
assert( b != bottom_ ); // silly link
while ( b )
{
bottom_ = b;
b = bottom_->next();
}
}
// list empty: Cursor not ok()
return Cursor<T>( *this, bottom_ );
}
// not inlined since it assumes knowledge of destructor.
template<class T>
inline void
PointerList<T>::remove( Cursor<T> me )
{
if ( me.ok() )
{
delete *me;
List<T>::remove( me );
}
}
#endif
|