7 template<class T> class List;
14 Cursor( List<T>& list, Link<T>* pointer = 0 );
15 Cursor( const Cursor<T>& cursor );
19 operator T() { return *(*this); }
20 Cursor<T> operator =( const Cursor<T>& c );
22 /// make cursor with #no# items back
23 Cursor<T> operator -( int no) const;
25 /// make cursor with #no# items further
26 Cursor<T> operator +( int no) const;
28 Cursor<T> operator -=(int);
29 Cursor<T> operator +=(int);
31 /// return current and move one down
32 Cursor<T> operator ++( int );
34 /// return current and move one up
35 Cursor<T> operator --( int );
46 /// put (copy) after me in List
47 void add( const T& thing );
49 analogously to editor. ok() interpreted as at end
52 PRE: !ok, POST: added to bottom()
54 PRE: ok, POST: added after me
56 cursor points to same object, cursor.next() is newly added
60 /// put (copy) before me in List
61 void insert( const T& thing );
63 analogously to editor. ok() interpreted as at begin of
66 PRE: !ok, POST: add to top()
68 PRE: ok, POST: add before me
70 cursor points to same object, cursor.previous()
71 is newly inserted object.
80 /// access the list this came from
81 const List<T>& list() const ;
91 add and insert extend the list
92 items are always stored as copies in List, but:
93 List<String> : copies of String stored
94 List<String*> : copies of String* stored!
96 the operations add and insert actually delegate the work to List class.
101 /// cursor which feels like a pointer
103 struct PCursor : public Cursor<T> {
105 /// make cursor with #no# items back
106 PCursor<T> operator -( int no) const {
107 return PCursor<T> (Cursor<T>::operator-(no));
110 /// make cursor with #no# items further
111 PCursor<T> operator +( int no) const {
112 return PCursor<T> (Cursor<T>::operator+(no));
114 PCursor(List<T> & l) : Cursor<T> (l) {}
116 PCursor( const Cursor<T>& cursor ) : Cursor<T>(cursor) { }
117 T operator ->() { return *(*this); }
121 HWN: I'd like an operator->(), so here it is.
123 Cursor to go with pointer list.
127 #include "cursor.inl"
129 #endif // __CURSOR_HH //