// cursor.inl #ifndef CURSOR_INL #define CURSOR_INL #include //#include "list.hh" template inline Cursor::Cursor( List& list, Link* pointer ) : list_( list ) { if ( list.size() ) pointer_ = pointer ? pointer : list.top().pointer_; else pointer_ = pointer; } template inline Cursor::Cursor( const Cursor& cursor ) : list_( cursor.list_ ) { pointer_ = cursor.pointer_; } template inline T& Cursor::operator *() { assert( pointer_ ); return pointer_->thing(); } template Cursor Cursor::operator =( const Cursor& c ) { assert( &list_ == &c.list_ ); pointer_ = c.pointer_; return *this; } template inline void Cursor::add( const T& thing ) { list_.add( thing, *this ); } template inline void Cursor::insert( const T& thing ) { list_.insert( thing, *this ); } template inline void Cursor::remove() { assert( pointer_ ); list_.remove( *this ); } template inline const List& Cursor::list() const { return list_; } template inline Link* Cursor::pointer() { return pointer_; } template inline bool Cursor::backward() { return ( pointer_ != 0 ); } template inline bool Cursor::forward() { return ( pointer_ != 0 ); } template inline bool Cursor::ok() { return ( pointer_ != 0 ); } #endif