1 Star 0 Fork 2

codecooko/DesignPattern

forked from gibili/DesignPattern 
Create your Gitee Account
Explore and code with more than 14 million developers,Free private repositories !:)
Sign up
文件
Clone or Download
BigCharFactory.h 633 Bytes
Copy Edit Raw Blame History
涛哥威威 authored 2018-10-09 08:52 +08:00 . classify
#include "BigChar.h"
#include <unordered_map>
class BigCharFactory
{
public:
~BigCharFactory()
{
for (auto i : m_map)
{
delete i.second;
}
m_map.clear();
}
BigChar *getBigChar(int order)
{
BigChar *b = nullptr;
int tOrder = order % 11;
auto it = m_map.find(tOrder);
if (it == m_map.end())
{
b = new BigChar(tOrder);
m_map.insert({ tOrder, b });
return b;
}
else
{
return it->second;
}
}
private:
std::unordered_map<int, BigChar *> m_map;
};
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/codecooko/DesignPattern.git
git@gitee.com:codecooko/DesignPattern.git
codecooko
DesignPattern
DesignPattern
master

Search