source: src/AtomIdSet.hpp@ 4464ef

Action_Thermostats Add_AtomRandomPerturbation Add_RotateAroundBondAction Add_SelectAtomByNameAction Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_StructOpt_integration_tests Automaking_mpqc_open AutomationFragmentation_failures Candidate_v1.6.0 Candidate_v1.6.1 ChangeBugEmailaddress ChangingTestPorts ChemicalSpaceEvaluator Combining_Subpackages Debian_Package_split Debian_package_split_molecuildergui_only Disabling_MemDebug Docu_Python_wait EmpiricalPotential_contain_HomologyGraph_documentation Enable_parallel_make_install Enhance_userguide Enhanced_StructuralOptimization Enhanced_StructuralOptimization_continued Example_ManyWaysToTranslateAtom Exclude_Hydrogens_annealWithBondGraph FitPartialCharges_GlobalError Fix_ChronosMutex Fix_StatusMsg Fix_StepWorldTime_single_argument Fix_Verbose_Codepatterns ForceAnnealing_goodresults ForceAnnealing_oldresults ForceAnnealing_tocheck ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_continued ForceAnnealing_with_BondGraph_continued_betteresults ForceAnnealing_with_BondGraph_contraction-expansion GeometryObjects Gui_displays_atomic_force_velocity IndependentFragmentGrids_IntegrationTest JobMarket_RobustOnKillsSegFaults JobMarket_StableWorkerPool JobMarket_unresolvable_hostname_fix ODR_violation_mpqc_open PartialCharges_OrthogonalSummation PythonUI_with_named_parameters QtGui_reactivate_TimeChanged_changes Recreated_GuiChecks RotateToPrincipalAxisSystem_UndoRedo StoppableMakroAction Subpackage_levmar Subpackage_vmg ThirdParty_MPQC_rebuilt_buildsystem TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps Ubuntu_1604_changes stable
Last change on this file since 4464ef was f01769, checked in by Frederik Heber <heber@…>, 9 years ago

Replaced World::getAtom() wherever possible by const version.

  • some AtomSet member functions now have const atom ptr instead of atom ptr.
  • molecule can return const and non-const AtomSet.
  • added FromIdToConstAtom to allow iterate through atoms in molecule (which are stored by id, not by ptr) in const fashion.
  • in molecule::isInMolecule() is now const, ::CopyMolecule..() is non-const (because copying involves father atom who is stored non-const).
  • Property mode set to 100644
File size: 2.0 KB
Line 
1/*
2 * AtomIdSet.hpp
3 *
4 * Created on: Feb 21, 2012
5 * Author: heber
6 */
7
8#ifndef ATOMIDSET_HPP_
9#define ATOMIDSET_HPP_
10
11
12// include config.h
13#ifdef HAVE_CONFIG_H
14#include <config.h>
15#endif
16
17#include <boost/iterator/transform_iterator.hpp>
18
19#include <set>
20#include <vector>
21
22#include "types.hpp"
23
24class KeySet;
25
26class atom;
27struct FromIdToAtom :
28 public std::unary_function<atom *, atomId_t>
29{
30 atom * operator()(atomId_t id) const;
31};
32
33struct FromIdToConstAtom :
34 public std::unary_function<const atom *, atomId_t>
35{
36 const atom * operator()(atomId_t id) const;
37};
38
39/** AtomIdSet is a set of atomic ids that however behave as a set of atoms.
40 *
41 * This class represents an iterable set of atoms that is however only stored as
42 * ids internally.
43 */
44class AtomIdSet
45{
46public:
47 typedef std::set<atomId_t> atomIdSet;
48 typedef boost::transform_iterator<FromIdToAtom, atomIdSet::iterator, atom *, atomId_t> iterator;
49 typedef boost::transform_iterator<FromIdToConstAtom, atomIdSet::const_iterator, const atom *, atomId_t const &> const_iterator;
50
51 AtomIdSet(const atomIdSet &_atoms);
52 AtomIdSet(const KeySet &_keysets);
53 AtomIdSet(const std::vector<atom *> &_atoms);
54 AtomIdSet();
55 ~AtomIdSet();
56
57 iterator begin();
58 const_iterator begin() const;
59 iterator end();
60 const_iterator end() const;
61 bool empty() const;
62 size_t size() const;
63 bool contains(const atom * const key) const;
64 bool contains(const atomId_t &id) const;
65 const_iterator find(const atom * const key) const;
66 const_iterator find(const atomId_t &id) const;
67 std::pair<iterator, bool> insert(const atom * const key);
68 std::pair<iterator, bool> insert(const atomId_t &id);
69 const_iterator erase(const_iterator &loc);
70 const_iterator erase(const atom * const key);
71 const_iterator erase(const atomId_t &id);
72
73 /** Getter for internal set of atoms.
74 *
75 * @return set of atomic ids
76 */
77 const atomIdSet & getAtomIds() const {
78 return atoms;
79 }
80
81private:
82 //!> internal atoms stored by their ids
83 atomIdSet atoms;
84};
85
86
87#endif /* ATOMIDSET_HPP_ */
Note: See TracBrowser for help on using the repository browser.