/* * Project: MoleCuilder * Description: creates and alters molecular systems * Copyright (C) 2016 Frederik Heber. All rights reserved. * * * This file is part of MoleCuilder. * * MoleCuilder is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * MoleCuilder is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with MoleCuilder. If not, see . */ /* * AtomFragmentsMap.cpp * * Created on: Mar 7, 2016 * Author: heber */ // include config.h #ifdef HAVE_CONFIG_H #include #endif #include "CodePatterns/MemDebug.hpp" #include "CodePatterns/Log.hpp" #include "AtomFragmentsMap.hpp" #include "AtomIdSet.hpp" #include "Fragmentation/Graph.hpp" #include "Fragmentation/KeySet.hpp" AtomFragmentsMap::AtomFragmentsMap( const Graph &_graph, size_t _MaxOrder) { /// create a map of atom to keyset (below equal MaxOrder) LOG(1, "INFO: Placing all atoms and their keysets into a map."); for (Graph::const_iterator keysetiter = _graph.begin(); keysetiter != _graph.end(); ++keysetiter) { const KeySet &keyset = keysetiter->first; LOG(2, "DEBUG: Current keyset is " << keyset); if ((keyset.size() > _MaxOrder) || (keyset.empty())) continue; for (KeySet::const_iterator keyiter = keyset.begin(); keyiter != keyset.end(); ++keyiter) { // either create new list ... std::pair inserter = atommap.insert( std::make_pair(*keyiter, keysets_t(1, keyset) )); // ... or push to end if (inserter.second) { LOG(3, "DEBUG: Created new entry in map."); } else { LOG(3, "DEBUG: Added keyset to present entry."); inserter.first->second.push_back(keyset); } } } LOG(2, "DEBUG: There are " << atommap.size() << " entries in lookup."); }