blob: a4e03492b536bb6b8e7a5dbbf334800762de1489 (
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
// cursor.inl -*-c++-*-
#ifndef CURSOR_INL
#define CURSOR_INL
#include <assert.h>
//#include "list.hh"
template<class T>
inline
Cursor<T>::Cursor( List<T>& list, Link<T>* pointer ) :
list_( list )
{
if ( list.size() )
pointer_ = pointer ? pointer : list.top_;
//list.top().pointer_; // ARGH! recursion.
else
pointer_ = pointer;
}
template<class T>
inline
Cursor<T>::Cursor( const Cursor<T>& cursor ) :
list_( cursor.list_ )
{
pointer_ = cursor.pointer_;
}
template<class T>
inline T&
Cursor<T>::operator *()
{
assert( pointer_ );
return pointer_->thing();
}
template<class T>
Cursor<T>
Cursor<T>::operator =( const Cursor<T>& c )
{
assert( &list_ == &c.list_ );
pointer_ = c.pointer_;
return *this;
}
template<class T>
inline void
Cursor<T>::add( const T& thing )
{
list_.add( thing, *this );
}
template<class T>
inline void
Cursor<T>::insert( const T& thing )
{
list_.insert( thing, *this );
}
template<class T>
inline void
Cursor<T>::backspace()
{
Cursor<T> c(*this);
c--;
list_.remove( *this );
}
template<class T>
inline void
Cursor<T>::del()
{
Cursor<T> c(*this);
c++;
list_.remove( *this );
*this = c;
}
template<class T>
inline const List<T>&
Cursor<T>::list() const
{
return list_;
}
template<class T>
inline Link<T>*
Cursor<T>::pointer()
{
return pointer_;
}
template<class T>
inline bool
Cursor<T>::backward()
{
return ( pointer_ != 0 );
}
template<class T>
inline bool
Cursor<T>::forward()
{
return ( pointer_ != 0 );
}
template<class T>
inline bool
Cursor<T>::ok()
{
return ( pointer_ != 0 );
}
#endif
|