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