Loading...
Searching...
No Matches
OBMolAtomBFSIter Class Reference

`#include <openbabel/obiter.h>`

## Public Member Functions

| OBMolAtomBFSIter ()
| OBMolAtomBFSIter (OBMol *mol, int StartIndex=1)
| OBMolAtomBFSIter (OBMol &mol, int StartIndex=1)
| OBMolAtomBFSIter (const OBMolAtomBFSIter &ai)
| ~OBMolAtomBFSIter ()
OBMolAtomBFSIter & | operator= (const OBMolAtomBFSIter &ai)
| operator bool () const
OBMolAtomBFSIter & | operator++ ()
OBMolAtomBFSIter | operator++ (int)
OBAtom * | operator-> () const
OBAtom & | operator* () const
int | CurrentDepth () const

## Detailed Description

Iterate over all atoms in an OBMol in a breadth-first search (BFS).

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 breadth-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 queue 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_BFS_OF_MOL(a,m) for( OBMolAtomBFSIter a(m); a; ++a )
OpenBabel::OBMolAtomBFSIter::OBMolAtomBFSIter
OBMolAtomBFSIter()
Definition obiter.h:110
FOR_BFS_OF_MOL
#define FOR_BFS_OF_MOL(a, m)
Definition obiter.h:405

Here is an example:

#include <openbabel/obiter.h>
#include <openbabel/mol.h>
OpenBabel::OBMol mol;
FOR_BFS_OF_MOL(a, mol)
{
// 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
}
OpenBabel::OBMol
Molecule Class.
Definition mol.h:121
mol.h
Handle molecules. Declarations of OBMol, OBAtom, OBBond, OBResidue. (the main header for Open Babel).
obiter.h
STL-style iterators for Open Babel.

## Constructor & Destructor Documentation

## OBMolAtomBFSIter() [1/4]

OBMolAtomBFSIter | ( |  | ) |

inline

Referenced by OBMolAtomBFSIter(), operator++(), operator++(), and operator=().

## OBMolAtomBFSIter() [2/4]

OBMolAtomBFSIter | ( | OBMol * | mol,
|  | int | StartIndex = 1 )

## OBMolAtomBFSIter() [3/4]

OBMolAtomBFSIter | ( | OBMol & | mol,
|  | int | StartIndex = 1 )

## OBMolAtomBFSIter() [4/4]

OBMolAtomBFSIter | ( | const OBMolAtomBFSIter & | ai | ) |

## ~OBMolAtomBFSIter()

~OBMolAtomBFSIter | ( |  | ) |

inline

## Member Function Documentation

## operator=()

OBMolAtomBFSIter & operator= | ( | const OBMolAtomBFSIter & | ai | ) |

## operator bool()

operator bool | ( |  | ) | const

inline

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

## operator++() [1/2]

OBMolAtomBFSIter & operator++ | ( |  | ) |

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

Referenced by operator++().

## operator++() [2/2]

OBMolAtomBFSIter 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

## CurrentDepth()

int CurrentDepth | ( |  | ) | const

Returns
  the current depth of the iterator

Since
  version 2.2

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

- obiter.h
- obiter.cpp