Open Babel  3.0
Public Member Functions | List of all members
OBMolAtomDFSIter Class Reference

#include <openbabel/obiter.h>

Public Member Functions

 OBMolAtomDFSIter ()
 
 OBMolAtomDFSIter (OBMol *mol, int StartIndex=1)
 
 OBMolAtomDFSIter (OBMol &mol, int StartIndex=1)
 
 OBMolAtomDFSIter (const OBMolAtomDFSIter &ai)
 
 ~OBMolAtomDFSIter ()
 
OBMolAtomDFSIteroperator= (const OBMolAtomDFSIter &ai)
 
 operator bool () const
 
OBMolAtomDFSIteroperator++ ()
 
OBMolAtomDFSIter operator++ (int)
 
OBAtomoperator-> () const
 
OBAtomoperator* () const
 
OBAtomnext ()
 

Detailed Description

Iterate over all atoms in an OBMol in a depth-first search (DFS)

Since
version 2.1

To facilitate iteration through all atoms in a molecule, without resorting to atom indexes (which will change in the future), a variety of iterator methods are provided.

This class provides a depth-first search ordering of atoms. When one connected component is exhausted, the iterator will start at another until all atoms are visited. No guarantee is made as to the ordering of iteration through connected components.

The iterator maintains an internal stack and list of visited atoms. As such it may not be appropriate for memory-constrained situations when iterating through large molecules.

Use of this iterator has been made significantly easier by a series of macros in the obiter.h header file:

\#define FOR_DFS_OF_MOL(a,m) for( OBMolAtomDFSIter a(m); a; ++a )

Here is an example:

#include <openbabel/mol.h>
{
// The variable a behaves like OBAtom* when used with -> and * but
// but needs to be explicitly converted when appearing as a parameter
// in a function call - use &*a
}

Constructor & Destructor Documentation

◆ OBMolAtomDFSIter() [1/4]

OBMolAtomDFSIter ( )
inline

◆ OBMolAtomDFSIter() [2/4]

OBMolAtomDFSIter ( OBMol mol,
int  StartIndex = 1 
)

◆ OBMolAtomDFSIter() [3/4]

OBMolAtomDFSIter ( OBMol mol,
int  StartIndex = 1 
)

◆ OBMolAtomDFSIter() [4/4]

◆ ~OBMolAtomDFSIter()

~OBMolAtomDFSIter ( )
inline

Member Function Documentation

◆ operator=()

OBMolAtomDFSIter & operator= ( const OBMolAtomDFSIter ai)

◆ operator bool()

operator bool ( ) const
inline
Returns
Whether the iterator can still advance (i.e., visit more atoms)

◆ operator++() [1/2]

OBMolAtomDFSIter & operator++ ( )

Preincrement – advance to the next atom in the DFS list and return.

Referenced by OBMolAtomDFSIter::operator++().

◆ operator++() [2/2]

OBMolAtomDFSIter operator++ ( int  )

Postincrement – return the current atom and advance to the next atom.

◆ operator->()

OBAtom* operator-> ( ) const
inline
Returns
a pointer to the current atom

◆ operator*()

OBAtom& operator* ( ) const
inline
Returns
a reference to the current atom

◆ next()

OBAtom* next ( )
inline
Returns
NULL if at the last atom in a fragment, else the next atom

Referenced by OBMolAtomDFSIter::operator++().


The documentation for this class was generated from the following files: