Implements assignment binding
This commit is contained in:
24
src/Utilities/HashedString.hpp
Normal file
24
src/Utilities/HashedString.hpp
Normal file
@@ -0,0 +1,24 @@
|
||||
|
||||
#ifndef PORYGONLANG_HASHEDSTRING_HPP
|
||||
#define PORYGONLANG_HASHEDSTRING_HPP
|
||||
|
||||
#include <string>
|
||||
|
||||
class HashedString{
|
||||
int _hash;
|
||||
static unsigned constexpr const_hash(char const *input) {
|
||||
return *input ?
|
||||
static_cast<unsigned int>(*input) + 33 * const_hash(input + 1) :
|
||||
5381;
|
||||
}
|
||||
public:
|
||||
explicit HashedString(std::string s){
|
||||
_hash = const_hash(s.c_str());
|
||||
}
|
||||
|
||||
const int GetHash(){
|
||||
return _hash;
|
||||
}
|
||||
};
|
||||
|
||||
#endif //PORYGONLANG_HASHEDSTRING_HPP
|
||||
Reference in New Issue
Block a user