/* * AdjacencyList.hpp * * Created on: Mar 3, 2011 * Author: heber */ #ifndef ADJACENCYLIST_HPP_ #define ADJACENCYLIST_HPP_ // include config.h #ifdef HAVE_CONFIG_H #include #endif #include #include #include #include "types.hpp" #include "World.hpp" class atom; /** This class contains the adjacency structure inside an internal map of atoms. * * The adjacency structure is either from a file or from a given set of atoms. * * We may compare a subset of atoms against this internal bond structure. It is * true it is a true subset of the bond structure. */ class AdjacencyList { //!> Unit test is granted access to internal data friend class AdjacencyListTest; public: typedef std::vector atomids_t; /** Default constructor for class AdjacencyList. * * We simply have an empty adjacency list here. */ AdjacencyList() {} AdjacencyList(std::istream &File); AdjacencyList(const atomids_t &atoms); ~AdjacencyList(); bool operator<(const AdjacencyList &other) const; /** Comparison operator whether this adjacency list is a subset of \a other. * * @return true - is subset, false - is not subset */ bool operator>(const AdjacencyList &other) const { return other < *this; } /** Equality operator, determines whether both adjacencies are the same. * * @return true - both are the same, false - at least one is not a subset of the other */ bool operator==(const AdjacencyList &other) const { return (other < *this) && (*this < other); } /** Inquality operator, determines whether both adjacencies are not equal. * * @return true - both are not equal, false - both are the subset of one another */ bool operator!=(const AdjacencyList &other) const { return !(*this == other); } /** Stores the adjacency contained in this instance to file. * * @param File stream to write to * @return true - File is good, false - else */ bool StoreToFile(std::ostream &File) const; private: typedef std::set KeysSet; typedef std::set ValuesSet; typedef std::pair AtomBondPair; typedef std::multimap< atomId_t, atomId_t > AtomBondMap; typedef std::pair AtomBondRange; AtomBondMap atombondmap; KeysSet getKeys(const AtomBondRange &_range) const; ValuesSet getValues(const AtomBondRange&_range) const; void CreateMap(atomids_t atoms); bool ParseFromFile(std::istream &File); }; #endif /* ADJACENCYLIST_HPP_ */