#include <BALL/CONCEPT/baseIterator.h>
Public Types | |
Typedefs. | |
The names of these typedefs deviate from the usual BALL class names due to restrictions imposed by STL compliance. | |
typedef DataType | value_type |
typedef Position | difference_type |
typedef const DataType * | pointer |
typedef const DataType & | reference |
typedef std::input_iterator_tag | iterator_category |
Public Member Functions | |
Constructors and Destructors | |
BALL_INLINE | BaseIterator () |
Default constructor. | |
BALL_INLINE | BaseIterator (const BaseIterator &iterator) |
Copy constructor. | |
BALL_INLINE | ~BaseIterator () |
Destructor. | |
Assignment | |
BALL_INLINE BaseIterator & | operator= (const BaseIterator &iterator) |
BALL_INLINE void | swap (BaseIterator &iterator) |
Swap two iterators. | |
Accessors | |
BALL_INLINE void | invalidate () |
Invalidate the iterator. | |
BALL_INLINE void | setTraits (const Traits &traits) |
Set the traits. | |
BALL_INLINE const Traits & | getTraits () const |
Get a constant reference to the traits of this iterator. | |
BALL_INLINE Traits & | getTraits () |
Get a constant reference to the traits of this iterator. | |
BALL_INLINE const Container * | getContainer () const |
Get a constant pointer to the container of this iterator. | |
Converters | |
BALL_INLINE | operator const Position & () const |
BALL_INLINE reference | operator* () const |
Convert an iterator to its Datatype by returning a reference to the current data. | |
BALL_INLINE pointer | operator-> () const |
Return a pointer to the current data. | |
Predicates | |
BALL_INLINE bool | operator== (const BaseIterator &iterator) const |
Equality operator. | |
BALL_INLINE bool | operator!= (const BaseIterator &iterator) const |
Inequality operator. | |
BALL_INLINE bool | isSingular () const |
BALL_INLINE bool | isValid () const |
BALL_INLINE bool | operator+ () const |
Validity predicate. | |
BALL_INLINE bool | operator- () const |
Invalidity perdicate. | |
Protected Member Functions | |
BALL_INLINE | BaseIterator (const Container &container) |
Private Attributes | |
Traits | traits_ |
The instance of the iterator's traits. |
Generic Iterator Class. This template class implements the basic behaviour of an iterator. Iterators are basically STL-like iterators. They provide the full STL iterator interface, but also offer additional features.
BaseIterator itself is a base class to the other iterator classes only and should not be used by itself.
An important difference exists for the iterators of the kernel objects. For most kernel objects, multiple iterators exist. Therefore, we could not simply use begin()
and end()
like in STL, but we introduced specialized methods like AtomContainer::beginAtom and AtomContainer::endAtom . For similar reasons, the iterators for kernel classes are not implemented as nested classes of the respective kernel classes, but as independent classes to avoid code replication. An exception is Atom::BondIterator , which is relevant to Atom alone.
Each BALL iterator can be bound to a container, so once the iteration has started, it "knows" about the end() of the container. Therefore, BALL iterators additionally implement the unary plus operator to check for the validity of the iterator. this allows the convenient implementation of for loops, e.g. as follows:
AtomIterator atom_it = system.beginAtom(); for (; +atom_it; ++atom_it) { .... }
typedef Position BALL::BaseIterator< Container, DataType, Position, Traits >::difference_type |
typedef std::input_iterator_tag BALL::BaseIterator< Container, DataType, Position, Traits >::iterator_category |
Reimplemented in BALL::ConstBidirectionalIterator< Container, DataType, Position, Traits >, BALL::ConstForwardIterator< Container, DataType, Position, Traits >, BALL::ConstRandomAccessIterator< Container, DataType, Position, Traits >, BALL::ConstBidirectionalIterator< Container, DataType, Position, Traits >, BALL::ConstBidirectionalIterator< Composite, Composite, Composite *, CompositeIteratorTraits >, BALL::ConstForwardIterator< Container, DataType, Position, Traits >, BALL::ConstForwardIterator< Composite, Composite, Composite *, CompositeIteratorTraits >, and BALL::ConstRandomAccessIterator< Container, DataType, Position, Traits >.
typedef const DataType* BALL::BaseIterator< Container, DataType, Position, Traits >::pointer |
Reimplemented in BALL::BidirectionalIterator< Container, DataType, Position, Traits >, BALL::ForwardIterator< Container, DataType, Position, Traits >, BALL::RandomAccessIterator< Container, DataType, Position, Traits >, and BALL::BidirectionalIterator< Composite, Composite, Composite *, CompositeIteratorTraits >.
typedef const DataType& BALL::BaseIterator< Container, DataType, Position, Traits >::reference |
Reimplemented in BALL::BidirectionalIterator< Container, DataType, Position, Traits >, BALL::ForwardIterator< Container, DataType, Position, Traits >, BALL::RandomAccessIterator< Container, DataType, Position, Traits >, and BALL::BidirectionalIterator< Composite, Composite, Composite *, CompositeIteratorTraits >.
typedef DataType BALL::BaseIterator< Container, DataType, Position, Traits >::value_type |
BALL_INLINE BALL::BaseIterator< Container, DataType, Position, Traits >::BaseIterator | ( | ) | [inline] |
Default constructor.
BALL_INLINE BALL::BaseIterator< Container, DataType, Position, Traits >::BaseIterator | ( | const BaseIterator< Container, DataType, Position, Traits > & | iterator | ) | [inline] |
Copy constructor.
BALL_INLINE BALL::BaseIterator< Container, DataType, Position, Traits >::~BaseIterator | ( | ) | [inline] |
Destructor.
BALL_INLINE BALL::BaseIterator< Container, DataType, Position, Traits >::BaseIterator | ( | const Container & | container | ) | [inline, protected] |
Constructor. Protected to allow instantiation and use in derived classes only.
BALL_INLINE const Container* BALL::BaseIterator< Container, DataType, Position, Traits >::getContainer | ( | ) | const [inline] |
Get a constant pointer to the container of this iterator.
BALL_INLINE Traits& BALL::BaseIterator< Container, DataType, Position, Traits >::getTraits | ( | ) | [inline] |
Get a constant reference to the traits of this iterator.
BALL_INLINE const Traits& BALL::BaseIterator< Container, DataType, Position, Traits >::getTraits | ( | ) | const [inline] |
Get a constant reference to the traits of this iterator.
Referenced by BALL::HashSet< Key >::find(), BALL::Composite::getNext(), BALL::Composite::getPrevious(), BALL::HashSet< Key >::insert(), BALL::ForwardIterator< Container, DataType, Position, Traits >::swap(), and BALL::ConstForwardIterator< Composite, Composite, Composite *, CompositeIteratorTraits >::swap().
BALL_INLINE void BALL::BaseIterator< Container, DataType, Position, Traits >::invalidate | ( | ) | [inline] |
Invalidate the iterator.
Referenced by BALL::CompositeIteratorTraits::invalidate().
BALL_INLINE bool BALL::BaseIterator< Container, DataType, Position, Traits >::isSingular | ( | ) | const [inline] |
Singularity predicate. This method returns true if the iterator is singular, i.e., not associated with a container.
BALL_INLINE bool BALL::BaseIterator< Container, DataType, Position, Traits >::isValid | ( | ) | const [inline] |
Validity predicate
Referenced by BALL::Composite::getNext().
BALL_INLINE BALL::BaseIterator< Container, DataType, Position, Traits >::operator const Position & | ( | ) | const [inline] |
Convert an iterator to Position. This method returns the position of the iterator. Note that Position is a template within this context and not the BALL datatype.
BALL_INLINE bool BALL::BaseIterator< Container, DataType, Position, Traits >::operator!= | ( | const BaseIterator< Container, DataType, Position, Traits > & | iterator | ) | const [inline] |
Inequality operator.
BALL_INLINE reference BALL::BaseIterator< Container, DataType, Position, Traits >::operator* | ( | ) | const [inline] |
Convert an iterator to its Datatype by returning a reference to the current data.
Reimplemented in BALL::BidirectionalIterator< Container, DataType, Position, Traits >, BALL::ForwardIterator< Container, DataType, Position, Traits >, BALL::RandomAccessIterator< Container, DataType, Position, Traits >, and BALL::BidirectionalIterator< Composite, Composite, Composite *, CompositeIteratorTraits >.
BALL_INLINE bool BALL::BaseIterator< Container, DataType, Position, Traits >::operator+ | ( | ) | const [inline] |
Validity predicate.
Reimplemented in BALL::ConstRandomAccessIterator< Container, DataType, Position, Traits >, and BALL::ConstRandomAccessIterator< Container, DataType, Position, Traits >.
BALL_INLINE bool BALL::BaseIterator< Container, DataType, Position, Traits >::operator- | ( | ) | const [inline] |
Invalidity perdicate.
Reimplemented in BALL::ConstRandomAccessIterator< Container, DataType, Position, Traits >, and BALL::ConstRandomAccessIterator< Container, DataType, Position, Traits >.
BALL_INLINE pointer BALL::BaseIterator< Container, DataType, Position, Traits >::operator-> | ( | ) | const [inline] |
Return a pointer to the current data.
Reimplemented in BALL::BidirectionalIterator< Container, DataType, Position, Traits >, BALL::ForwardIterator< Container, DataType, Position, Traits >, BALL::RandomAccessIterator< Container, DataType, Position, Traits >, and BALL::BidirectionalIterator< Composite, Composite, Composite *, CompositeIteratorTraits >.
BALL_INLINE BaseIterator& BALL::BaseIterator< Container, DataType, Position, Traits >::operator= | ( | const BaseIterator< Container, DataType, Position, Traits > & | iterator | ) | [inline] |
Assignment operator. Assigns the contents of an iterator to another iterator.
iterator | the iterator to be copied |
BALL_INLINE bool BALL::BaseIterator< Container, DataType, Position, Traits >::operator== | ( | const BaseIterator< Container, DataType, Position, Traits > & | iterator | ) | const [inline] |
Equality operator.
BALL_INLINE void BALL::BaseIterator< Container, DataType, Position, Traits >::setTraits | ( | const Traits & | traits | ) | [inline] |
Set the traits.
BALL_INLINE void BALL::BaseIterator< Container, DataType, Position, Traits >::swap | ( | BaseIterator< Container, DataType, Position, Traits > & | iterator | ) | [inline] |
Swap two iterators.
Referenced by BALL::BaseIterator< Composite, Composite, Composite *, CompositeIteratorTraits >::swap().
Traits BALL::BaseIterator< Container, DataType, Position, Traits >::traits_ [private] |
The instance of the iterator's traits.
Referenced by BALL::BaseIterator< Composite, Composite, Composite *, CompositeIteratorTraits >::getContainer(), BALL::BaseIterator< Composite, Composite, Composite *, CompositeIteratorTraits >::getTraits(), BALL::BaseIterator< Composite, Composite, Composite *, CompositeIteratorTraits >::invalidate(), BALL::BaseIterator< Composite, Composite, Composite *, CompositeIteratorTraits >::isSingular(), BALL::BaseIterator< Composite, Composite, Composite *, CompositeIteratorTraits >::isValid(), BALL::BaseIterator< Container, DataType, Position, Traits >::operator const Position &(), BALL::BaseIterator< Composite, Composite, Composite *, CompositeIteratorTraits >::operator!=(), BALL::BaseIterator< Composite, Composite, Composite *, CompositeIteratorTraits >::operator*(), BALL::BaseIterator< Composite, Composite, Composite *, CompositeIteratorTraits >::operator+(), BALL::BaseIterator< Composite, Composite, Composite *, CompositeIteratorTraits >::operator-(), BALL::BaseIterator< Composite, Composite, Composite *, CompositeIteratorTraits >::operator->(), BALL::BaseIterator< Composite, Composite, Composite *, CompositeIteratorTraits >::operator=(), BALL::BaseIterator< Composite, Composite, Composite *, CompositeIteratorTraits >::operator==(), BALL::BaseIterator< Composite, Composite, Composite *, CompositeIteratorTraits >::setTraits(), and BALL::BaseIterator< Composite, Composite, Composite *, CompositeIteratorTraits >::swap().