Added hash functions for strings.

This commit is contained in:
jwellbelove 2016-11-16 13:06:16 +00:00
parent 1171d7e555
commit ae2e4609b2
4 changed files with 68 additions and 0 deletions

View File

@ -33,6 +33,7 @@ SOFTWARE.
#include "platform.h"
#include "basic_string.h"
#include "hash.h"
#if defined(ETL_COMPILER_MICROSOFT)
#undef min
@ -180,6 +181,22 @@ namespace etl
value_type buffer[MAX_SIZE + 1];
};
//***************************************************************************
/// Specialisation for string.
///\ingroup hash
//***************************************************************************
template <>
struct hash <string>
{
size_t operator ()(const string& s) const
{
uint8_t* p_begin = &s[0];
uint8_t* p_end = &s[s.size()];
return etl::__private_hash__::generic_hash(p_begin, p_end);
}
};
}
#if defined(ETL_COMPILER_MICROSOFT)

View File

@ -33,6 +33,7 @@ SOFTWARE.
#include "platform.h"
#include "basic_string.h"
#include "hash.h"
#if defined(ETL_COMPILER_MICROSOFT)
#undef min
@ -180,6 +181,22 @@ namespace etl
value_type buffer[MAX_SIZE + 1];
};
//***************************************************************************
/// Specialisation for u16string.
///\ingroup hash
//***************************************************************************
template <>
struct hash <u16string>
{
size_t operator ()(const u16string& s) const
{
uint8_t* p_begin = &s[0];
uint8_t* p_end = &s[s.size()];
return etl::__private_hash__::generic_hash(p_begin, p_end);
}
};
}
#if defined(ETL_COMPILER_MICROSOFT)

View File

@ -33,6 +33,7 @@ SOFTWARE.
#include "platform.h"
#include "basic_string.h"
#include "hash.h"
#if defined(ETL_COMPILER_MICROSOFT)
#undef min
@ -180,6 +181,22 @@ namespace etl
value_type buffer[MAX_SIZE + 1];
};
//***************************************************************************
/// Specialisation for u32string.
///\ingroup hash
//***************************************************************************
template <>
struct hash <u32string>
{
size_t operator ()(const u32string& s) const
{
uint8_t* p_begin = &s[0];
uint8_t* p_end = &s[s.size()];
return etl::__private_hash__::generic_hash(p_begin, p_end);
}
};
}
#if defined(ETL_COMPILER_MICROSOFT)

View File

@ -33,6 +33,7 @@ SOFTWARE.
#include "platform.h"
#include "basic_string.h"
#include "hash.h"
#if defined(ETL_COMPILER_MICROSOFT)
#undef min
@ -181,6 +182,22 @@ namespace etl
value_type buffer[MAX_SIZE + 1];
};
//***************************************************************************
/// Specialisation for wstring.
///\ingroup hash
//***************************************************************************
template <>
struct hash <wstring>
{
size_t operator ()(const wstring& s) const
{
uint8_t* p_begin = &s[0];
uint8_t* p_end = &s[s.size()];
return etl::__private_hash__::generic_hash(p_begin, p_end);
}
};
}
#if defined(ETL_COMPILER_MICROSOFT)