mirror of
https://github.com/SerenityOS/serenity
synced 2024-07-21 18:15:58 +00:00
AK: Add String::hash()
This commit is contained in:
parent
39546303da
commit
ab9e6166e8
15
AK/String.h
15
AK/String.h
|
@ -181,6 +181,13 @@ public:
|
|||
return *this;
|
||||
}
|
||||
|
||||
u32 hash() const
|
||||
{
|
||||
if (!m_impl)
|
||||
return 0;
|
||||
return m_impl->hash();
|
||||
}
|
||||
|
||||
ByteBuffer to_byte_buffer() const;
|
||||
|
||||
template<typename BufferType>
|
||||
|
@ -205,7 +212,10 @@ public:
|
|||
}
|
||||
#endif
|
||||
|
||||
StringView view() const { return { characters(), length() }; }
|
||||
StringView view() const
|
||||
{
|
||||
return { characters(), length() };
|
||||
}
|
||||
|
||||
private:
|
||||
bool match_helper(const StringView& mask) const;
|
||||
|
@ -234,7 +244,6 @@ struct Traits<String> : public GenericTraits<String> {
|
|||
struct CaseInsensitiveStringTraits : public AK::Traits<String> {
|
||||
static unsigned hash(const String& s) { return s.impl() ? s.to_lowercase().impl()->hash() : 0; }
|
||||
static bool equals(const String& a, const String& b) { return a.to_lowercase() == b.to_lowercase(); }
|
||||
|
||||
};
|
||||
|
||||
inline bool operator<(const char* characters, const String& string)
|
||||
|
@ -271,5 +280,5 @@ inline bool operator<=(const char* characters, const String& string)
|
|||
|
||||
}
|
||||
|
||||
using AK::String;
|
||||
using AK::CaseInsensitiveStringTraits;
|
||||
using AK::String;
|
||||
|
|
Loading…
Reference in a new issue