From 6cbc3929a54d37bd23cb5efa8e3320ba02f78b2f Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Fri, 31 May 2019 17:20:37 -0400 Subject: Use slang- prefix on slang compiler and core source (#973) * Prefixing source files in source/slang with slang- * Prefix source in source/slang with slang- prefix. * Rename core source files with slang- prefix. * Update project files. * Fix problems from automatic merge. --- source/core/hash.h | 153 ----------------------------------------------------- 1 file changed, 153 deletions(-) delete mode 100644 source/core/hash.h (limited to 'source/core/hash.h') diff --git a/source/core/hash.h b/source/core/hash.h deleted file mode 100644 index 83e99179b..000000000 --- a/source/core/hash.h +++ /dev/null @@ -1,153 +0,0 @@ -#ifndef CORELIB_HASH_H -#define CORELIB_HASH_H - -#include "slang-math.h" -#include -#include - -namespace Slang -{ - typedef int HashCode; - - inline int GetHashCode(double key) - { - return FloatAsInt((float)key); - } - inline int GetHashCode(float key) - { - return FloatAsInt(key); - } - inline int GetHashCode(const char * buffer) - { - if (!buffer) - return 0; - int hash = 0; - int c; - auto str = buffer; - c = *str++; - while (c) - { - hash = c + (hash << 6) + (hash << 16) - hash; - c = *str++; - } - return hash; - } - inline int GetHashCode(char * buffer) - { - return GetHashCode(const_cast(buffer)); - } - inline int GetHashCode(const char * buffer, size_t numChars) - { - int hash = 0; - for (size_t i = 0; i < numChars; ++i) - { - hash = int(buffer[i]) + (hash << 6) + (hash << 16) - hash; - } - return hash; - } - - inline uint64_t GetHashCode64(const char * buffer, size_t numChars) - { - // Use uints because hash requires wrap around behavior and int is undefined on over/underflows - uint64_t hash = 0; - for (size_t i = 0; i < numChars; ++i) - { - hash = uint64_t(int64_t(buffer[i])) + (hash << 6) + (hash << 16) - hash; - } - return hash; - } - - template - class Hash - { - public: - }; - template<> - class Hash<1> - { - public: - template - static int GetHashCode(TKey & key) - { - return (int)key; - } - }; - template<> - class Hash<0> - { - public: - template - static int GetHashCode(TKey & key) - { - return int(key.GetHashCode()); - } - }; - template - class PointerHash - {}; - template<> - class PointerHash<1> - { - public: - template - static int GetHashCode(TKey const& key) - { - return (int)((PtrInt)key) / 16; // sizeof(typename std::remove_pointer::type); - } - }; - template<> - class PointerHash<0> - { - public: - template - static int GetHashCode(TKey & key) - { - return Hash::value || std::is_enum::value>::GetHashCode(key); - } - }; - - template - int GetHashCode(const TKey & key) - { - return PointerHash::value>::GetHashCode(key); - } - - template - int GetHashCode(TKey & key) - { - return PointerHash::value>::GetHashCode(key); - } - - inline int combineHash(int left, int right) - { - return (left * 16777619) ^ right; - } - - struct Hasher - { - public: - Hasher() {} - - template - void hashValue(T const& value) - { - m_hashCode = combineHash(m_hashCode, GetHashCode(value)); - } - - template - void hashObject(T const& object) - { - m_hashCode = combineHash(m_hashCode, object->GetHashCode()); - } - - HashCode getResult() const - { - return m_hashCode; - } - - private: - HashCode m_hashCode = 0; - }; -} - -#endif -- cgit v1.2.3