//---------------------------------------------------------------- // File and Version Information: // $Id: AstSTLMap.hh,v 1.1.1.1 2005/03/29 16:49:05 steinke Exp $ // // Description: // one-directional association map ofbetween two data types. // the operator [] returns a std::vector // of the second data type. // // usage: // T1* t1; T2* t2; // IfrMap map; // // // appends the asociation (t1, t2) // map[t1].append(t2); // // // returns a vector of objects associated to t1 // std::vector v1 = map[t1]; // // // checks for the asociation (t1, t2) // bool associated map[t1].contains(t2); // // // Author List: // Luca Lista 26 Mar 97 // // Bertram Kopf (RUB) migrated to PandaRoot //--------------------------------------------------------------- #ifndef ASTSTLMAP_HH #define ASTSTLMAP_HH //------------- // C Headers -- //------------- //--------------- // C++ Headers -- //--------------- #include #include #include //---------------------- // Base Class Headers -- //---------------------- #include "AstAbsSTLMap.h" //------------------------------- // Collaborating Class Headers -- //------------------------------- //------------------------------------ // Collaborating Class Declarations -- //------------------------------------ // --------------------- // -- Class Interface -- // --------------------- template class AstSTLMap : public AstAbsSTLMap, public std::map > { public: AstSTLMap(size_t buckets=50); AstSTLMap(unsigned (*)(T1 *const &), size_t buckets=50); virtual ~AstSTLMap(); // Return a list of all T2 const std::vector & allType2() const; // Given a set of T1*, return all associated T2. No check is made on the // returned vector - if of non-zero length, items are simply appended. // Returns false if no matches are found bool findIntersectionSet(const std::set &, std::vector &returned) const; // As above but copies the intersection of the given HashSet and the known // table into the final argument. bool findIntersectionSet(const std::set &, std::vector &returned, std::set &returnedSet) const; // As above but saves user having to think about hash functions. Slower, as // it has to copy the vector into a hash set first. bool findIntersectionSet(const std::vector &, std::vector &returned) const; // Given a set of T1*, return all T2 for which no T1 in the given set exists. No check is made on the // returned vector - if of non-zero length, items are simply appended. // Returns false if no matches are found bool findDifferenceSet(const std::set &, std::vector &returned) const; // As above but copies the intersection of the given HashSet and the known // table into the final argument. bool findDifferenceSet(const std::set &, std::vector &returned, std::set &) const; // As above but saves user having to think about hash functions. Slower, as // it has to copy the vector into a hash set first. bool findDifferenceSet(const std::vector &, std::vector &returned) const; // Compute the union with another map, modifying & returning self. // Note that this is a union with the T1 type ONLY. No comparison // is made with the associated (vector of) T2. Maybe one day I'll get // around to writing one of those. AstSTLMap &unionMap(const AstSTLMap &); // Compute the union with another map, modifying & returningself. AstSTLMap &intersectionMap(const AstSTLMap &); protected: void appendToMap(T1* const&, T2* const&); private: std::vector *_allT2; std::set *_hashSetT1; }; //-------------------- // Member functions -- //-------------------- //--------------- // Constructor -- //--------------- #include "AstSTLMap.cxx" #endif