3#include <Foundation/Algorithm/HashingUtils.h>
9#if PL_ENABLED(PL_HASHED_STRING_REF_COUNTING)
12 m_Data.
Value().m_iRefCount.Increment();
22#if PL_ENABLED(PL_HASHED_STRING_REF_COUNTING)
23inline plHashedString::~plHashedString()
29 m_Data.
Value().m_iRefCount.Decrement();
39#if PL_ENABLED(PL_HASHED_STRING_REF_COUNTING)
40 tmp.
Value().m_iRefCount.Increment();
42 m_Data.
Value().m_iRefCount.Decrement();
50#if PL_ENABLED(PL_HASHED_STRING_REF_COUNTING)
51 m_Data.
Value().m_iRefCount.Decrement();
61#if PL_ENABLED(PL_HASHED_STRING_REF_COUNTING)
62 HashedType tmp = m_Data;
67#if PL_ENABLED(PL_HASHED_STRING_REF_COUNTING)
68 tmp.Value().m_iRefCount.Decrement();
74#if PL_ENABLED(PL_HASHED_STRING_REF_COUNTING)
80#if PL_ENABLED(PL_HASHED_STRING_REF_COUNTING)
81 tmp.
Value().m_iRefCount.Decrement();
87 return m_Data == rhs.m_Data;
92 return m_Data.
Key() == rhs.m_uiHash;
97 return m_Data.
Key() < rhs.m_Data.
Key();
102 return m_Data.
Key() < rhs.m_uiHash;
107 return m_Data.
Value().m_sString;
112 return m_Data.
Value().m_sString.GetData();
121PL_FORCE_INLINE
plHashedString plMakeHashedString(
const char (&
string)[N])
130PL_ALWAYS_INLINE plTempHashedString::plTempHashedString()
133 m_uiHash = uiEmptyHash;
137PL_ALWAYS_INLINE plTempHashedString::plTempHashedString(
const char (&
string)[N])
142PL_ALWAYS_INLINE plTempHashedString::plTempHashedString(
plStringView sString)
149 m_uiHash = rhs.m_uiHash;
152PL_ALWAYS_INLINE plTempHashedString::plTempHashedString(
const plHashedString& rhs)
157PL_ALWAYS_INLINE plTempHashedString::plTempHashedString(plUInt64 uiHash)
175 m_uiHash = rhs.m_uiHash;
185 return m_uiHash == rhs.m_uiHash;
190 return m_uiHash < rhs.m_uiHash;
196 return m_uiHash == uiEmptyHash;
214 PL_ALWAYS_INLINE
static plUInt32 Hash(
const plHashedString& value)
This class is optimized to take nearly no memory (sizeof(void*)) and to allow very fast checks whethe...
Definition HashedString.h:25
void Assign(const char(&string)[N])
Assigning a new string from a string constant is a slow operation, but the hash computation can happe...
const plString & GetString() const
Gives access to the actual string data, so you can do all the typical (read-only) string operations o...
Definition HashedString_inl.h:105
bool operator==(const plHashedString &rhs) const
Comparing whether two hashed strings are identical is just a pointer comparison. This operation is wh...
Definition HashedString_inl.h:85
plHashedString()
Initializes this string to the empty string.
Definition HashedString.cpp:104
const char * GetData() const
Gives access to the actual string data, so you can do all the typical (read-only) string operations o...
Definition HashedString_inl.h:110
bool operator<(const plHashedString &rhs) const
This operator allows sorting objects by hash value, not by alphabetical order.
Definition HashedString_inl.h:95
void operator=(const plHashedString &rhs)
Copies the given plHashedString.
Definition HashedString_inl.h:34
plUInt64 GetHash() const
Returns the hash of the stored string.
Definition HashedString_inl.h:115
static constexpr plUInt32 StringHashTo32(plUInt64 uiHash)
Truncates a 64 bit string hash to 32 bit.
Definition HashingUtils_inl.h:138
static constexpr plUInt64 StringHash(const char(&str)[N], plUInt64 uiSeed=0)
Calculates the hash of the given string literal at compile time.
plStringView represent a read-only sub-string of a larger string, as it can store a dedicated string ...
Definition StringView.h:34
A class to use together with plHashedString for quick comparisons with temporary strings that need no...
Definition HashedString.h:151
bool IsEmpty() const
Checks whether the plTempHashedString represents the empty string.
Definition HashedString_inl.h:193
bool operator==(const plTempHashedString &rhs) const
Compares the two objects by their hash value. Might report incorrect equality, if two strings have th...
Definition HashedString_inl.h:183
void Clear()
Resets the string to the empty string.
Definition HashedString_inl.h:199
bool operator<(const plTempHashedString &rhs) const
This operator allows soring objects by hash value, not by alphabetical order.
Definition HashedString_inl.h:188
plUInt64 GetHash() const
Returns the hash of the stored string.
Definition HashedString_inl.h:204
void operator=(const char(&string)[N])
The hash of the given string can be computed at compile time.
Helper struct to calculate the Hash of different types.
Definition HashingUtils.h:75
PL_ALWAYS_INLINE bool IsValid() const
Checks whether this iterator points to a valid element.
Definition Map.h:27
PL_FORCE_INLINE const KeyType & Key() const
Returns the 'key' of the element that this iterator points to.
Definition Map.h:34
Forward Iterator to iterate over all elements in sorted order.
Definition Map.h:103
PL_FORCE_INLINE ValueType & Value()
Returns the 'value' of the element that this iterator points to.
Definition Map.h:119