#ifndef BBDLstIt_HH #define BBDLstIt_HH ////////////////////////////////////////////////////////////// //! file="amma/Contain/DList/BBDLIter.hh" //! lib=Mlist //! userlevel=Develop //! author="Radek Marik" //! docentry="Containers.Lists.DList" //! date="06/08/95" //! rcsid="$Id: BBDLIter.hh,v 1.13 2000/12/13 12:01:14 ees1cg Exp $" // Based on the list structure by G. Matas // and by R. Sara (K320870@edvz.uni-linz.ac.at) #include "amma/Boolean.hh" #include "amma/StdTypeA.hh" // without error propagation #include "amma/BCDLstIt.hh" #include "amma/BoDList.hh" class DChainC; // ---------------------------------------------------------------------- // ************ BaseBodyDLIterC ********************************** // ---------------------------------------------------------------------- //: Double-linked circular list iterator // The class 'BaseBodyDLIterC' is a representation of iterator on // a double-linked list. Iterator is connected with a list. If the // list is empty, the iterator points to the head of the list. The result // of positioning of an iterator need not to be a proper element. // To avoid pointing to the head of the list the head skipping // moving operators NextCrc() and/or PrevCrc() must be used. template class BaseBodyDLIterC: public BaseBodyConstDLIterC { public: // ------------ Access to the element data ---------------------- inline DataC & Data(); // Access to the object contained in the list element. inline DataC &operator*(); // Access to the object contained in the list element. inline DataC *operator->(); // Access to the object contained in the list element. inline const DataC & Data() const ; // Access to the object contained in the list element. inline const DataC &operator*() const; // Access to the object contained in the list element. inline const DataC *operator->() const; // Access to the object contained in the list element. // ----------- Positioning the iterator ----------------------------- inline BaseBodyDLIterC & First(); // Sets the iterator to point to the first element of the list. inline BaseBodyDLIterC & Last(); // Sets the iterator to point to the last element of the list. inline BaseBodyDLIterC & Next(); // Moves the iterator to the successor of the element. inline void operator++(int); // Moves the iterator to the successor of the element. inline BaseBodyDLIterC & Prev(); // Moves the iterator to the predecessor of the element. inline void operator--(int); // Moves the iterator to the predecessor of the element. inline BaseBodyDLIterC & NextCrc(); // Moves the iterator to the successor of the element. If the result // element is not a proper element of the list the iterator is moved // to the first element. inline BaseBodyDLIterC & PrevCrc(); // Moves the iterator to the predecessor of the element. If the result // element is not a proper element of the list the iterator is moved // to the last element. inline BaseBodyDLIterC & Nth(LongIntT n); // Sets to the n-th element of the list. The index 'n' can be // negative. The first element of the list has the index 0, // the last element has the index -1. It does not skip the head // of the list. inline BaseBodyDLIterC & RelNth(LongIntT n); // Moves to the n-th element from the current element. // The index 'n' can be positive, zero, or negative. // Particularly, the n = 0 means no move, // n = 1 means the move to the next element, // and n = -1 means the move to the previous element. // Modification of the list item // ----------------------------- inline const BaseBodyDLIterC & InsBef(const DataC & data); // Inserts the new element containing 'data' before the element // pointed to by this iterator. This iterator is returned. inline const BaseBodyDLIterC & InsAft(const DataC & data); // Inserts the new element containing 'data' after the element // pointed to by this iterator. This iterator is returned. inline const BaseBodyDLIterC & MoveBef(BaseBodyDLIterC & iter); // The element pointed to by 'iter' is moved before the element // pointed to by this iterator. This iterator will point to the same // element as before, the iterator 'iter' will point to the previous // element in the original list. inline const BaseBodyDLIterC & MoveAft(BaseBodyDLIterC & iter); // The element pointed to by 'iter' is moved after the element // pointed to by this iterator. This iterator will point to the same // element as before, the iterator 'iter' will point to the previous // element in the original list. const BaseBodyDLIterC & MoveBef(BodyDListC & list); // All elements of the 'list' are moved before the element // pointed to by this iterator. The 'list' will be empty after // this operation. const BaseBodyDLIterC & MoveAft(BodyDListC & list); // All elements of the 'list' are moved before the element // pointed to by this iterator. The 'list' will be empty after // this operation. inline const BaseBodyDLIterC & DelMoveNext(); // Deletes the element pointed to by this iterator and moves // iterator to the next element. inline const BaseBodyDLIterC & Del(); // Deletes the element pointed to by this iterator and moves // iterator to the previous element. protected: // ------------ Constructor / Destructor / Assigment ------------ inline BaseBodyDLIterC(); // Default constructor. This constructor is provided because // of trouble with an array of iterators. The present ANSI C++ // does not enable to pass any constructor of array elements // different from a defaut constructor. The extension of GNU g++ // compiler is not supported by other compiler. The constructor // should be used only for such purposes. If this limitation of C++ // is removed, the constructor will be obsolete. inline BaseBodyDLIterC(const BodyDListC & list); // Creates an iterator operating on the 'list'. The iterator // will point to the first element if there is any, otherwise // to the head of the list. inline BaseBodyDLIterC(const BaseBodyDLIterC & iter); // Copy constructor. inline BaseBodyDLIterC Copy() const; // Copy constructor. inline const BaseBodyDLIterC & operator=(const BaseBodyDLIterC & it); // Assingment. This iterator will point to the same list element as // the iterator 'it'. inline const BaseBodyDLIterC & DLIter() const; // Self-identification. The function returns this object. protected: inline BooleanT IsValid() const; // Returns TRUE if the iterator was not constructed by the default // constructor. }; // ---------------------------------------------------------------------- // ************ BaseBodyDLIterC **************************************** // ---------------------------------------------------------------------- template inline DataC & BaseBodyDLIterC::Data() { return const_cast(BaseBodyConstDLIterC::Data()); } template inline DataC *BaseBodyDLIterC::operator->() { return &const_cast(BaseBodyConstDLIterC::Data()); } template inline DataC &BaseBodyDLIterC::operator*() { return const_cast(BaseBodyConstDLIterC::Data()); } template inline const DataC & BaseBodyDLIterC::Data() const { return BaseBodyConstDLIterC::Data(); } template inline const DataC *BaseBodyDLIterC::operator->() const { return &BaseBodyConstDLIterC::Data(); } template inline const DataC &BaseBodyDLIterC::operator*() const { return BaseBodyConstDLIterC::Data(); } template inline BooleanT BaseBodyDLIterC::IsValid() const //===================================== { return BaseBodyConstDLIterC::IsValid(); } template inline BaseBodyDLIterC::BaseBodyDLIterC() //======================================= : BaseBodyConstDLIterC() {} template inline BaseBodyDLIterC::BaseBodyDLIterC(const BaseBodyDLIterC & iter) //========================================================================== : BaseBodyConstDLIterC(iter) {} template inline BaseBodyDLIterC BaseBodyDLIterC::Copy() const //================================== { return(BaseBodyDLIterC(*this)); } template inline const BaseBodyDLIterC & BaseBodyDLIterC::operator=(const BaseBodyDLIterC & iter) //==================================================================== { BaseBodyConstDLIterC::operator=(iter); return(*this); } template inline BaseBodyDLIterC:: BaseBodyDLIterC(const BodyDListC & list) //============================================ : BaseBodyConstDLIterC(list) {} template inline const BaseBodyDLIterC & BaseBodyDLIterC::DLIter() const //==================================== { return(*this); } template inline BaseBodyDLIterC & BaseBodyDLIterC::First() //============================= { BaseBodyConstDLIterC::First(); return(*this); } template inline BaseBodyDLIterC & BaseBodyDLIterC::Last() //============================ { BaseBodyConstDLIterC::Last(); return(*this); } template inline BaseBodyDLIterC & BaseBodyDLIterC::Next() //============================ { BaseBodyConstDLIterC::Next(); return(*this); } template inline void BaseBodyDLIterC::operator++(int) { BaseBodyConstDLIterC::Next(); } template inline BaseBodyDLIterC & BaseBodyDLIterC::Prev() //============================ { BaseBodyConstDLIterC::Prev(); return(*this); } template inline void BaseBodyDLIterC::operator--(int) { BaseBodyConstDLIterC::Prev(); } template inline BaseBodyDLIterC & BaseBodyDLIterC::NextCrc() //=============================== { BaseBodyConstDLIterC::NextCrc(); return (*this); } template inline BaseBodyDLIterC & BaseBodyDLIterC::PrevCrc() //=============================== { BaseBodyConstDLIterC::PrevCrc(); return (*this); } template inline BaseBodyDLIterC & BaseBodyDLIterC::Nth(LongIntT n) //===================================== { BaseBodyConstDLIterC::Nth(n); return(*this); } template inline BaseBodyDLIterC & BaseBodyDLIterC::RelNth(LongIntT n) //======================================== { BaseBodyConstDLIterC::RelNth(n); return(*this); } //------- Insert / Unlink ------- template inline const BaseBodyDLIterC & BaseBodyDLIterC::InsBef(const DataC & data) //================================================ { BaseBodyConstDLIterC::InsBef(data); return(*this); } template inline const BaseBodyDLIterC & BaseBodyDLIterC::InsAft(const DataC & data) //================================================ { BaseBodyConstDLIterC::InsAft(data); return(*this); } template inline const BaseBodyDLIterC & BaseBodyDLIterC::MoveBef(BaseBodyDLIterC & iter) //============================================================ { BaseBodyConstDLIterC::MoveBef(iter); return *this; } template inline const BaseBodyDLIterC & BaseBodyDLIterC::MoveAft(BaseBodyDLIterC & iter) //============================================================ { BaseBodyConstDLIterC::MoveAft(iter); return *this; } template inline const BaseBodyDLIterC & BaseBodyDLIterC::MoveBef(BodyDListC & list) { BaseBodyConstDLIterC::MoveBef(list); return *this; } template inline const BaseBodyDLIterC & BaseBodyDLIterC::MoveAft(BodyDListC & list) { BaseBodyConstDLIterC::MoveAft(list); return *this; } template inline const BaseBodyDLIterC & BaseBodyDLIterC::DelMoveNext() //=================================== { BaseBodyConstDLIterC::DelMoveNext(); return(*this); } template inline const BaseBodyDLIterC & BaseBodyDLIterC::Del() //=========================== { BaseBodyConstDLIterC::Del(); return(*this); } #endif // IAPS - Image analysis program system. // End of include file BBDLIter.hh