Loading...
Searching...
No Matches
AtomIterators.h
Go to the documentation of this file.
//
// Copyright (C) 2002-2006 Greg Landrum and Rational Discovery LLC
//
// @@ All Rights Reserved @@
// This file is part of the RDKit.
// The contents are covered by the terms of the BSD license
// which is included in the file license.txt, found at the root
// of the RDKit source tree.
//
/*! \file AtomIterators.h
\brief various tools for iterating over a molecule's Atoms.
<b>WARNING:</b> If you go changing the molecule underneath one of
these iterators you will be sad...
*/
#include <RDGeneral/export.h>
#ifndef __RD_ATOM_ITERATORS_H__
#define __RD_ATOM_ITERATORS_H__
#ifdef _MSC_VER
#pragma warning(disable : 4661) // no suitable definition provided for explicit
// template instantiation request
#endif
namespace RDKit {
class QueryAtom;
//! A general random access iterator
template <class Atom_, class Mol_>
class RDKIT_GRAPHMOL_EXPORT AtomIterator_ {
public:
typedef AtomIterator_<Atom_, Mol_> ThisType;
AtomIterator_() : _mol(nullptr) {}
AtomIterator_(Mol_ *mol);
AtomIterator_(Mol_ *mol, int pos);
AtomIterator_(const ThisType &other);
AtomIterator_ &operator=(const ThisType &other);
AtomIterator_ &operator+=(int val);
AtomIterator_ &operator-=(int val);
AtomIterator_ operator+(int val) const;
AtomIterator_ operator-(int val) const;
// iterator subtraction
int operator-(ThisType &other) const;
// dereference
Atom_ *operator*() const;
// random access
Atom_ *operator[](const int which) const;
bool operator==(const ThisType &other) const;
bool operator!=(const ThisType &other) const;
bool operator<(const ThisType &other) const;
bool operator<=(const ThisType &other) const;
bool operator>(const ThisType &other) const;
bool operator>=(const ThisType &other) const;
// pre-increment
ThisType &operator++();
ThisType operator++(int);
// pre-decrement
ThisType &operator--();
ThisType operator--(int);
private:
int _pos{-1};
int _max{-1};
Mol_ *_mol;
};
//! Iterate over heteroatoms, this is bidirectional
template <class Atom_, class Mol_>
class RDKIT_GRAPHMOL_EXPORT HeteroatomIterator_ {
public:
typedef HeteroatomIterator_<Atom_, Mol_> ThisType;
HeteroatomIterator_() : _mol(nullptr) {}
HeteroatomIterator_(Mol_ *mol);
HeteroatomIterator_(Mol_ *mol, int pos);
~HeteroatomIterator_();
HeteroatomIterator_(const ThisType &other);
HeteroatomIterator_ &operator=(const ThisType &other);
bool operator==(const ThisType &other) const;
bool operator!=(const ThisType &other) const;
Atom_ *operator*() const;
// pre-increment
ThisType &operator++();
ThisType operator++(int);
// pre-decrement
ThisType &operator--();
ThisType operator--(int);
private:
int _end{-1};
int _pos{-1};
Mol_ *_mol;
// FIX: somehow changing the following to a pointer make the regression test
// pass
// QueryAtom _qA;
QueryAtom *_qA;
int _findNext(int from);
int _findPrev(int from);
};
//! Iterate over aromatic atoms, this is bidirectional
template <class Atom_, class Mol_>
class RDKIT_GRAPHMOL_EXPORT AromaticAtomIterator_ {
public:
typedef AromaticAtomIterator_<Atom_, Mol_> ThisType;
AromaticAtomIterator_() : _mol(nullptr) {}
AromaticAtomIterator_(Mol_ *mol);
AromaticAtomIterator_(Mol_ *mol, int pos);
~AromaticAtomIterator_();
AromaticAtomIterator_(const ThisType &other);
AromaticAtomIterator_ &operator=(const ThisType &other);
bool operator==(const ThisType &other) const;
bool operator!=(const ThisType &other) const;
Atom_ *operator*() const;
// pre-increment
ThisType &operator++();
ThisType operator++(int);
// pre-decrement
ThisType &operator--();
ThisType operator--(int);
private:
int _end{-1};
int _pos{-1};
Mol_ *_mol;
int _findNext(int from);
int _findPrev(int from);
};
//! Iterate over atoms matching a query. This is bidirectional.
template <class Atom_, class Mol_>
class RDKIT_GRAPHMOL_EXPORT QueryAtomIterator_ {
public:
typedef QueryAtomIterator_<Atom_, Mol_> ThisType;
QueryAtomIterator_() : _mol(nullptr) {}
QueryAtomIterator_(Mol_ *mol, QueryAtom const *what);
QueryAtomIterator_(Mol_ *mol, int pos);
~QueryAtomIterator_();
QueryAtomIterator_(const ThisType &other);
QueryAtomIterator_ &operator=(const ThisType &other);
bool operator==(const ThisType &other) const;
bool operator!=(const ThisType &other) const;
Atom_ *operator*() const;
// pre-increment
ThisType &operator++();
ThisType operator++(int);
// pre-decrement
ThisType &operator--();
ThisType operator--(int);
private:
int _end{-1};
int _pos{-1};
Mol_ *_mol;
QueryAtom *_qA{nullptr};
int _findNext(int from);
int _findPrev(int from);
};
//! Iterate over atoms matching a query function. This is bidirectional.
template <class Atom_, class Mol_>
class RDKIT_GRAPHMOL_EXPORT MatchingAtomIterator_ {
public:
typedef MatchingAtomIterator_<Atom_, Mol_> ThisType;
MatchingAtomIterator_() : _mol(nullptr), _qF(nullptr) {}
MatchingAtomIterator_(Mol_ *mol, bool (*fn)(Atom_ *));
MatchingAtomIterator_(Mol_ *mol, int pos);
~MatchingAtomIterator_();
MatchingAtomIterator_(const ThisType &other);
MatchingAtomIterator_ &operator=(const ThisType &other);
bool operator==(const ThisType &other) const;
bool operator!=(const ThisType &other) const;
Atom_ *operator*() const;
// pre-increment
ThisType &operator++();
ThisType operator++(int);
// pre-decrement
ThisType &operator--();
ThisType operator--(int);
private:
int _end{-1};
int _pos{-1};
Mol_ *_mol;
bool (*_qF)(Atom_ *);
int _findNext(int from);
int _findPrev(int from);
};
} // namespace RDKit
#endif
RDKit::AromaticAtomIterator_
Iterate over aromatic atoms, this is bidirectional.
Definition AtomIterators.h:111
RDKit::AromaticAtomIterator_::operator!=
bool operator!=(const ThisType &other) const
RDKit::AromaticAtomIterator_::operator=
AromaticAtomIterator_ & operator=(const ThisType &other)
RDKit::AromaticAtomIterator_::ThisType
AromaticAtomIterator_< Atom_, Mol_ > ThisType
Definition AtomIterators.h:113
RDKit::AromaticAtomIterator_::operator--
ThisType & operator--()
RDKit::AromaticAtomIterator_::operator*
Atom_ * operator*() const
RDKit::AromaticAtomIterator_::operator++
ThisType operator++(int)
RDKit::AromaticAtomIterator_::AromaticAtomIterator_
AromaticAtomIterator_(const ThisType &other)
RDKit::AromaticAtomIterator_::operator==
bool operator==(const ThisType &other) const
RDKit::AromaticAtomIterator_::operator++
ThisType & operator++()
RDKit::AromaticAtomIterator_::AromaticAtomIterator_
AromaticAtomIterator_(Mol_ *mol)
RDKit::AromaticAtomIterator_::AromaticAtomIterator_
AromaticAtomIterator_(Mol_ *mol, int pos)
RDKit::AromaticAtomIterator_::AromaticAtomIterator_
AromaticAtomIterator_()
Definition AtomIterators.h:114
RDKit::AromaticAtomIterator_::~AromaticAtomIterator_
~AromaticAtomIterator_()
RDKit::AromaticAtomIterator_::operator--
ThisType operator--(int)
RDKit::AtomIterator_
A general random access iterator.
Definition AtomIterators.h:31
RDKit::AtomIterator_::operator-
AtomIterator_ operator-(int val) const
RDKit::AtomIterator_::operator+
AtomIterator_ operator+(int val) const
RDKit::AtomIterator_::operator-
int operator-(ThisType &other) const
RDKit::AtomIterator_::ThisType
AtomIterator_< Atom_, Mol_ > ThisType
Definition AtomIterators.h:33
RDKit::AtomIterator_::operator<=
bool operator<=(const ThisType &other) const
RDKit::AtomIterator_::operator-=
AtomIterator_ & operator-=(int val)
RDKit::AtomIterator_::operator!=
bool operator!=(const ThisType &other) const
RDKit::AtomIterator_::operator--
ThisType operator--(int)
RDKit::AtomIterator_::operator==
bool operator==(const ThisType &other) const
RDKit::AtomIterator_::operator>
bool operator>(const ThisType &other) const
RDKit::AtomIterator_::AtomIterator_
AtomIterator_(const ThisType &other)
RDKit::AtomIterator_::operator*
Atom_ * operator*() const
RDKit::AtomIterator_::AtomIterator_
AtomIterator_(Mol_ *mol, int pos)
RDKit::AtomIterator_::operator++
ThisType operator++(int)
RDKit::AtomIterator_::AtomIterator_
AtomIterator_()
Definition AtomIterators.h:34
RDKit::AtomIterator_::operator+=
AtomIterator_ & operator+=(int val)
RDKit::AtomIterator_::AtomIterator_
AtomIterator_(Mol_ *mol)
RDKit::AtomIterator_::operator<
bool operator<(const ThisType &other) const
RDKit::AtomIterator_::operator=
AtomIterator_ & operator=(const ThisType &other)
RDKit::AtomIterator_::operator[]
Atom_ * operator[](const int which) const
RDKit::AtomIterator_::operator++
ThisType & operator++()
RDKit::AtomIterator_::operator>=
bool operator>=(const ThisType &other) const
RDKit::AtomIterator_::operator--
ThisType & operator--()
RDKit::HeteroatomIterator_
Iterate over heteroatoms, this is bidirectional.
Definition AtomIterators.h:74
RDKit::HeteroatomIterator_::operator--
ThisType & operator--()
RDKit::HeteroatomIterator_::HeteroatomIterator_
HeteroatomIterator_(Mol_ *mol)
RDKit::HeteroatomIterator_::operator=
HeteroatomIterator_ & operator=(const ThisType &other)
RDKit::HeteroatomIterator_::HeteroatomIterator_
HeteroatomIterator_(Mol_ *mol, int pos)
RDKit::HeteroatomIterator_::operator++
ThisType & operator++()
RDKit::HeteroatomIterator_::ThisType
HeteroatomIterator_< Atom_, Mol_ > ThisType
Definition AtomIterators.h:76
RDKit::HeteroatomIterator_::operator!=
bool operator!=(const ThisType &other) const
RDKit::HeteroatomIterator_::operator--
ThisType operator--(int)
RDKit::HeteroatomIterator_::operator++
ThisType operator++(int)
RDKit::HeteroatomIterator_::HeteroatomIterator_
HeteroatomIterator_(const ThisType &other)
RDKit::HeteroatomIterator_::~HeteroatomIterator_
~HeteroatomIterator_()
RDKit::HeteroatomIterator_::HeteroatomIterator_
HeteroatomIterator_()
Definition AtomIterators.h:77
RDKit::HeteroatomIterator_::operator*
Atom_ * operator*() const
RDKit::HeteroatomIterator_::operator==
bool operator==(const ThisType &other) const
RDKit::MatchingAtomIterator_
Iterate over atoms matching a query function. This is bidirectional.
Definition AtomIterators.h:178
RDKit::MatchingAtomIterator_::operator++
ThisType operator++(int)
RDKit::MatchingAtomIterator_::operator--
ThisType & operator--()
RDKit::MatchingAtomIterator_::operator--
ThisType operator--(int)
RDKit::MatchingAtomIterator_::ThisType
MatchingAtomIterator_< Atom_, Mol_ > ThisType
Definition AtomIterators.h:180
RDKit::MatchingAtomIterator_::MatchingAtomIterator_
MatchingAtomIterator_(Mol_ *mol, bool(*fn)(Atom_ *))
RDKit::MatchingAtomIterator_::operator==
bool operator==(const ThisType &other) const
RDKit::MatchingAtomIterator_::~MatchingAtomIterator_
~MatchingAtomIterator_()
RDKit::MatchingAtomIterator_::operator*
Atom_ * operator*() const
RDKit::MatchingAtomIterator_::operator++
ThisType & operator++()
RDKit::MatchingAtomIterator_::operator=
MatchingAtomIterator_ & operator=(const ThisType &other)
RDKit::MatchingAtomIterator_::MatchingAtomIterator_
MatchingAtomIterator_(Mol_ *mol, int pos)
RDKit::MatchingAtomIterator_::MatchingAtomIterator_
MatchingAtomIterator_()
Definition AtomIterators.h:181
RDKit::MatchingAtomIterator_::operator!=
bool operator!=(const ThisType &other) const
RDKit::MatchingAtomIterator_::MatchingAtomIterator_
MatchingAtomIterator_(const ThisType &other)
RDKit::QueryAtomIterator_
Iterate over atoms matching a query. This is bidirectional.
Definition AtomIterators.h:144
RDKit::QueryAtomIterator_::operator=
QueryAtomIterator_ & operator=(const ThisType &other)
RDKit::QueryAtomIterator_::~QueryAtomIterator_
~QueryAtomIterator_()
RDKit::QueryAtomIterator_::operator!=
bool operator!=(const ThisType &other) const
RDKit::QueryAtomIterator_::operator--
ThisType operator--(int)
RDKit::QueryAtomIterator_::operator==
bool operator==(const ThisType &other) const
RDKit::QueryAtomIterator_::QueryAtomIterator_
QueryAtomIterator_(Mol_ *mol, QueryAtom const *what)
RDKit::QueryAtomIterator_::QueryAtomIterator_
QueryAtomIterator_(Mol_ *mol, int pos)
RDKit::QueryAtomIterator_::operator*
Atom_ * operator*() const
RDKit::QueryAtomIterator_::operator--
ThisType & operator--()
RDKit::QueryAtomIterator_::operator++
ThisType operator++(int)
RDKit::QueryAtomIterator_::ThisType
QueryAtomIterator_< Atom_, Mol_ > ThisType
Definition AtomIterators.h:146
RDKit::QueryAtomIterator_::operator++
ThisType & operator++()
RDKit::QueryAtomIterator_::QueryAtomIterator_
QueryAtomIterator_()
Definition AtomIterators.h:147
RDKit::QueryAtomIterator_::QueryAtomIterator_
QueryAtomIterator_(const ThisType &other)
RDKit::QueryAtom
Class for storing atomic queries.
Definition QueryAtom.h:28
export.h
RDKIT_GRAPHMOL_EXPORT
#define RDKIT_GRAPHMOL_EXPORT
Definition export.h:233
RDKit
Std stuff.
Definition Abbreviations.h:19