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.
73 /// remove and cleanup Link // HWN: backspace or del?
76 /// access the list this came from
77 const List<T>& list() const ;
87 add and insert extend the list
88 items are always stored as copies in List, but:
89 List<String> : copies of String stored
90 List<String*> : copies of String* stored!
92 the operations add and insert actually delegate the work to List class.
97 /// cursor which feels like a pointer
99 struct PCursor : public Cursor<T> {
101 /// make cursor with #no# items back
102 PCursor<T> operator -( int no) const {
103 return PCursor<T> (Cursor<T>::operator-(no));
106 /// make cursor with #no# items further
107 PCursor<T> operator +( int no) const {
108 return PCursor<T> (Cursor<T>::operator+(no));
110 PCursor(List<T> & l) : Cursor<T> (l) {}
112 PCursor( const Cursor<T>& cursor ) : Cursor<T>(cursor) { }
113 T operator ->() { return *(*this); }
117 HWN: I'd like an operator->(), so here it is.
119 Cursor to go with pointer list.
123 #include "cursor.inl"
125 #endif // __CURSOR_HH //