Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:17:50

0001 #include "BbcVertexMapv1.h"
0002 
0003 #include "BbcVertex.h"
0004 #include "BbcVertexMap.h"
0005 
0006 #include <iterator>  // for reverse_iterator
0007 #include <utility>   // for pair, make_pair
0008 
0009 BbcVertexMapv1::~BbcVertexMapv1()
0010 {
0011   BbcVertexMapv1::clear();
0012 }
0013 
0014 void BbcVertexMapv1::identify(std::ostream& os) const
0015 {
0016   os << "BbcVertexMapv1: size = " << _map.size() << std::endl;
0017   return;
0018 }
0019 
0020 void BbcVertexMapv1::clear()
0021 {
0022   for (auto& iter : _map)
0023   {
0024     delete iter.second;
0025   }
0026   _map.clear();
0027   return;
0028 }
0029 
0030 const BbcVertex* BbcVertexMapv1::get(unsigned int id) const
0031 {
0032   ConstIter iter = _map.find(id);
0033   if (iter == _map.end())
0034   {
0035     return nullptr;
0036   }
0037   return iter->second;
0038 }
0039 
0040 BbcVertex* BbcVertexMapv1::get(unsigned int id)
0041 {
0042   Iter iter = _map.find(id);
0043   if (iter == _map.end())
0044   {
0045     return nullptr;
0046   }
0047   return iter->second;
0048 }
0049 
0050 BbcVertex* BbcVertexMapv1::insert(BbcVertex* vertex)
0051 {
0052   unsigned int index = 0;
0053   if (!_map.empty())
0054   {
0055     index = _map.rbegin()->first + 1;
0056   }
0057   _map.insert(std::make_pair(index, vertex));
0058   _map[index]->set_id(index);
0059   return _map[index];
0060 }