File indexing completed on 2025-08-06 08:18:08
0001
0002
0003
0004
0005
0006
0007 #include "CMFlashDifferenceContainerv1.h"
0008 #include "CMFlashDifference.h"
0009 #include "CMFlashDifferencev1.h"
0010
0011 #include <cstdlib>
0012
0013 void CMFlashDifferenceContainerv1::Reset()
0014 {
0015 while (m_map.begin() != m_map.end())
0016 {
0017 delete m_map.begin()->second;
0018 m_map.erase(m_map.begin());
0019 }
0020 return;
0021 }
0022
0023 void CMFlashDifferenceContainerv1::identify(std::ostream& os) const
0024 {
0025 os << "-----CMFlashDifferenceContainerv1-----" << std::endl;
0026 ConstIterator iter;
0027 os << "Number of differences: " << size() << std::endl;
0028 for (iter = m_map.begin(); iter != m_map.end(); ++iter)
0029 {
0030 os << "key " << iter->first << std::endl;
0031 (iter->second)->identify();
0032 }
0033 os << "------------------------------" << std::endl;
0034 return;
0035 }
0036
0037 void CMFlashDifferenceContainerv1::addDifferenceSpecifyKey(const unsigned int key, CMFlashDifference* newclus)
0038 {
0039 auto ret = m_map.insert(std::make_pair(key, newclus));
0040 if (!ret.second)
0041 {
0042 std::cout << "CMFlashDifferenceContainerv1::AddDifferenceSpecifyKey: duplicate key: " << key << " exiting now" << std::endl;
0043 exit(1);
0044 }
0045 }
0046
0047 void CMFlashDifferenceContainerv1::removeDifference(unsigned int key)
0048 {
0049 auto diff = findDifference(key);
0050 delete diff;
0051 m_map.erase(key);
0052 }
0053
0054 CMFlashDifferenceContainer::ConstRange
0055 CMFlashDifferenceContainerv1::getDifferences() const
0056 {
0057 return std::make_pair(m_map.cbegin(), m_map.cend());
0058 }
0059
0060 CMFlashDifference*
0061 CMFlashDifferenceContainerv1::findDifference(unsigned int key) const
0062 {
0063 auto it = m_map.find(key);
0064 return it == m_map.end() ? nullptr : it->second;
0065 }
0066
0067 unsigned int CMFlashDifferenceContainerv1::size() const
0068 {
0069 return m_map.size();
0070 }