// 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::thing() { 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& th ) { list_.add( th, *this ); } template inline void Cursor::insert( const T& th ) { list_.insert( th, *this ); } template inline 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 ); } template inline Cursor Cursor::operator ++( int ) { Cursor r (*this); assert( pointer_ ); pointer_ = pointer_->next(); return r; } template inline Cursor Cursor::operator --( int ) { Cursor r (*this); assert( pointer_ ); pointer_ = pointer_->previous(); return r; } #endif