// cursor.inl -*-c++-*- #ifndef CURSOR_INL #define CURSOR_INL #include //#include "list.hh" template inline Cursor::Cursor( const List& list, Link* pointer ) : list_((List&) list ) { if ( list.size() ) pointer_ = pointer ? pointer : list.top_; 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::backspace() { Cursor c(*this); c--; list_.remove( *this ); } template inline void Cursor::del() { Cursor c(*this); c++; list_.remove( *this ); *this = c; } 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