-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
89 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#include "pch.h" | ||
#include "Name.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
#pragma once | ||
|
||
namespace CM | ||
{ | ||
class Name | ||
{ | ||
friend struct std::hash<Name>; | ||
public: | ||
inline static std::unordered_map<std::string, size_t> sNamePool; | ||
|
||
inline Name(const std::string& InString, size_t InNumber = 0); | ||
inline bool operator==(const Name& Other) const; | ||
|
||
inline std::string_view ToString() const; | ||
|
||
private: | ||
inline static size_t FindOrAddName(const std::string& inName); | ||
|
||
private: | ||
std::string_view m_string; | ||
|
||
size_t m_nameID; | ||
size_t m_additionalNumber; | ||
}; | ||
} | ||
|
||
namespace std | ||
{ | ||
template <> | ||
struct hash<CM::Name> | ||
{ | ||
size_t operator()(const CM::Name& inItem) const | ||
{ | ||
size_t hashValue = std::hash<size_t>()(inItem.m_nameID); | ||
hashValue ^= std::hash<size_t>()(inItem.m_additionalNumber) + 0x9e3779b9 + (hashValue << 6) + (hashValue >> 2); | ||
return hashValue; | ||
} | ||
}; | ||
} | ||
|
||
inline CM::Name::Name(const std::string& inString, size_t inAdditionalNumber) | ||
{ | ||
m_nameID = FindOrAddName(inString); | ||
m_additionalNumber = inAdditionalNumber; | ||
m_string = inString; | ||
} | ||
|
||
inline bool CM::Name::operator==(const Name& Other) const | ||
{ | ||
return m_nameID == Other.m_nameID && m_additionalNumber == Other.m_additionalNumber; | ||
} | ||
|
||
inline std::string_view CM::Name::ToString() const | ||
{ | ||
return m_string; | ||
} | ||
|
||
inline size_t CM::Name::FindOrAddName(const std::string& Name) | ||
{ | ||
for (const auto& pair : sNamePool) | ||
{ | ||
if (pair.first == Name) | ||
{ | ||
return pair.second; | ||
} | ||
} | ||
std::string nameCopy(Name); | ||
size_t newIndex = sNamePool.size(); | ||
sNamePool[nameCopy] = newIndex; | ||
return newIndex; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
-3.29 KB
(95%)
MyD3DFramework/x64/Debug/MyD3DFramework.tlog/CL.command.1.tlog
Binary file not shown.
Binary file not shown.
Binary file modified
BIN
+2.06 KB
(100%)
MyD3DFramework/x64/Debug/MyD3DFramework.tlog/CL.write.1.tlog
Binary file not shown.
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.