Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:16:30

0001 // Tell emacs that this is a C++ source
0002 //  -*- C++ -*-.
0003 #ifndef GLOBALVERTEX_SVTXVERTEXMAPV1_H
0004 #define GLOBALVERTEX_SVTXVERTEXMAPV1_H
0005 
0006 #include "SvtxVertex.h"
0007 #include "SvtxVertexMap.h"
0008 
0009 #include <cstddef>  // for size_t
0010 #include <iostream>
0011 #include <map>
0012 
0013 class PHObject;
0014 
0015 class SvtxVertexMap_v1 : public SvtxVertexMap
0016 {
0017  public:
0018   SvtxVertexMap_v1() = default;
0019   SvtxVertexMap_v1(const SvtxVertexMap_v1& vertexmap);
0020   SvtxVertexMap_v1& operator=(const SvtxVertexMap_v1& vertexmap);
0021   ~SvtxVertexMap_v1() override;
0022 
0023   void identify(std::ostream& os = std::cout) const override;
0024   // cppcheck-suppress virtualCallInConstructor
0025   void Reset() override;
0026   int isValid() const override { return 1; }
0027   PHObject* CloneMe() const override { return new SvtxVertexMap_v1(*this); }
0028 
0029   bool empty() const override { return _map.empty(); }
0030   size_t size() const override { return _map.size(); }
0031   size_t count(unsigned int idkey) const override { return _map.count(idkey); }
0032   void clear() override { Reset(); }
0033 
0034   const SvtxVertex* get(unsigned int idkey) const override;
0035   SvtxVertex* get(unsigned int idkey) override;
0036 
0037   //! Add vertex to container. Note the container takes ownership
0038   SvtxVertex* insert(SvtxVertex* vertex) override;
0039   //! legacy interface. Add vertex to container. Note the container does not take ownership
0040   SvtxVertex* insert_clone(const SvtxVertex* vertex) override;
0041   size_t erase(unsigned int idkey) override
0042   {
0043     delete _map[idkey];
0044     return _map.erase(idkey);
0045   }
0046 
0047   ConstIter begin() const override { return _map.begin(); }
0048   ConstIter find(unsigned int idkey) const override { return _map.find(idkey); }
0049   ConstIter end() const override { return _map.end(); }
0050 
0051   Iter begin() override { return _map.begin(); }
0052   Iter find(unsigned int idkey) override { return _map.find(idkey); }
0053   Iter end() override { return _map.end(); }
0054 
0055  private:
0056   std::map<unsigned int, SvtxVertex*> _map;
0057 
0058   ClassDefOverride(SvtxVertexMap_v1, 1);
0059 };
0060 
0061 #endif  // __SVTXVERTEXMAP_V1_H__