|
有点不太明白这是为什么...
- struct char_cmp
- {
- bool operator()(const char* a, const char* b)const
- {
- return strcmp(a, b) == 0;
- }
- };
- struct Hash_map
- {
- int operator()(const char* str)const
- {
- int seed = 131;
- int hash = 0;
- while (*str)
- {
- hash = (hash * seed) + (*str);
- str++;
- }
- return hash & (0x7FFFFFFF);
- }
- };
- class ScriptManager {
- public:
- void GetAbsolutePath(LPCSTR szFile, char* szPath, int nSize) {
- //相对路径
- GetCurrentDirectory(nSize, szPath);
- strcat(szPath, "\");
- strcat(szPath, szFile);
- strupr(szPath);
- }
- void RegisterSink(LPCSTR szFile) {
- char szPath[MAX_PATH] = { 0 };
- GetAbsolutePath(szFile, szPath, MAX_PATH);
- m_ScriptTable.emplace(szPath, (char*)"00000");
- m_hst.emplace(szPath, (char*)"00000");
- }
- unordered_map<const char*, char*, Hash_map, char_cmp> m_ScriptTable;
- map<char*, char*> m_st;
- hash_map<char*, char*> m_hst;
- };
- int main()
- {
- char szPath[MAX_PATH] = { 0 };
- int nSize = 260;
- LPCSTR szFile = "abcde.fg";
-
- ScriptManager scriptManager;
- scriptManager.GetAbsolutePath(szFile, szPath, nSize);
-
- scriptManager.RegisterSink(szFile);
- auto it = scriptManager.m_ScriptTable.find(szPath);
- GetCurrentDirectory(nSize, szPath);
- }
复制代码 |
上一篇: 结构体数组与指针下一篇: 不知道A和D应该选哪个,求助一下蟹蟹
|