OBMolPairIter Class Reference

Iterate over all pairs of atoms (>1-4) in an OBMol. More...

#include <openbabel/obiter.h>

List of all members.

Public Member Functions

 OBMolPairIter ()
 OBMolPairIter (OBMol *mol)
 OBMolPairIter (OBMol &mol)
 OBMolPairIter (const OBMolPairIter &ai)
 ~OBMolPairIter ()
OBMolPairIteroperator= (const OBMolPairIter &ai)
 operator bool () const
OBMolPairIteroperator++ ()
std::vector< unsigned int > operator * () const


Detailed Description

Iterate over all pairs of atoms (>1-4) in an OBMol.

Since:
version 2.1.
To facilitate iteration through all pairs of atoms in a molecule, without resorting to bond indexes (which may change in the future), a variety of iterators are provided. These pairs of atoms are separated by 4 atoms or more (i.e., these are non-bonded interactions).

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

      \#define FOR_PAIRS_OF_MOL(p,m)     for( OBMolPairIter     p(m); p; p++ )

Here is an example:

      #include <openbabel/obiter.h>
      #include <openbabel/mol.h>

      OBMol mol;
      OBAtom *a, *b;
      double rab;

      FOR_PAIRS_OF_MOL(p, mol)
      {
         // The variable b behaves like OBBond* when used with -> and * but
         // but needs to be explicitly converted when appearing as a parameter
         // in a function call - use &*p

         a = mol.GetAtom(p->first);
         b = mol.GetAtom(p->second);
         rab = a->GetDistance(b);
      }


Constructor & Destructor Documentation

OBMolPairIter (  )  [inline]

OBMolPairIter ( OBMol mol  ) 

OBMolPairIter ( OBMol mol  ) 

OBMolPairIter ( const OBMolPairIter ai  ) 

~OBMolPairIter (  )  [inline]


Member Function Documentation

OBMolPairIter & operator= ( const OBMolPairIter ai  ) 

operator bool (  )  const [inline]

Returns:
Whether the iterator can still advance (i.e., visit more 1-4 atom pairs)

OBMolPairIter & operator++ (  ) 

Preincrement -- advance to the next 1-4 atom pair and return.

std::vector<unsigned int> operator * (  )  const [inline]

Returns:
A vector of two atom indexes specifying the 1-4 atom pair
See also:
OBAtom::GetIdx()


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