#include <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
|
|
BaseIterator () | |
Default constructor. |
|
BaseIterator (const BaseIterator &iterator) | |
Copy constructor. |
|
~BaseIterator () | |
Destructor. |
|
Assignment
|
|
BaseIterator & | operator= (const BaseIterator &iterator) |
Assignment operator. |
|
void | swap (BaseIterator &iterator) |
Swap two iterators. |
|
Accessors
|
|
void | invalidate () |
Invalidate the iterator. |
|
void | setTraits (const Traits &traits) |
Set the traits. |
|
const Traits & | getTraits () const |
Get a constant reference to the
traits of this iterator. |
|
Traits & | getTraits () |
Get a constant reference to the
traits of this iterator. |
|
const Container * | getContainer () const |
Get a constant pointer to the
container of this iterator. |
|
Converters
|
|
operator const Position & () const | |
Convert an iterator to Position.
|
|
reference | operator* () const |
Convert an iterator to its Datatype
by returning a reference to the current data. |
|
pointer | operator-> () const |
Return a pointer to the current
data. |
|
Predicates
|
|
bool | operator== (const BaseIterator &iterator) const |
Equality operator. |
|
bool | operator!= (const BaseIterator &iterator) const |
Inequality operator. |
|
bool | isSingular () const |
Singularity predicate. |
|
bool | isValid () const |
Validity predicate. |
|
bool | operator+ () const |
Validity predicate. |
|
bool | operator- () const |
Invalidity perdicate. |
|
Protected Member Functions |
|
BaseIterator (const Container &container) | |
Constructor. |
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.
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.
AtomIterator atom_it = system.beginAtom();
for (; +atom_it; ++atom_it)
{
....
}
BALL::BaseIterator< Container, DataType, Position, Traits >::BaseIterator | ( | const Container & | container | ) | [protected] |
Constructor.
Protected to allow instantiation and use in derived classes only.
bool BALL::BaseIterator< Container, DataType, Position, Traits >::isSingular | ( | ) | const |
Singularity predicate.
This method returns true if the iterator is singular, i.e., not associated with a container.
bool BALL::BaseIterator< Container, DataType, Position, Traits >::isValid | ( | ) | const |
Validity predicate.
Referenced by BALL::Composite::getNext().
BALL::BaseIterator< Container, DataType, Position, Traits >::operator const Position & | ( | ) | const |
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.
BaseIterator& BALL::BaseIterator< Container, DataType, Position, Traits >::operator= | ( | const BaseIterator< Container, DataType, Position, Traits > & | iterator | ) |
Assignment operator.
Assigns the contents of an iterator to another iterator.
iterator | the iterator to be copied |