X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fmisc.h;h=52595fb906bdd448472332de91e6e63f515c0482;hb=c17a657b045d4dc720c8c36558fe649a1c3f4a05;hp=69d470c22f8a0098273781739411372d98771ad3;hpb=38a80c0b47397dbdd9167ec1476dfd3c033020d6;p=stockfish diff --git a/src/misc.h b/src/misc.h index 69d470c2..52595fb9 100644 --- a/src/misc.h +++ b/src/misc.h @@ -21,12 +21,10 @@ #include #include -#include -#include -#include +#include #include - -#include "types.h" +#include +#include #define stringify2(x) #x #define stringify(x) stringify2(x) @@ -55,14 +53,6 @@ inline TimePoint now() { (std::chrono::steady_clock::now().time_since_epoch()).count(); } -template -struct HashTable { - Entry* operator[](Key key) { return &table[(uint32_t)key & (Size - 1)]; } - -private: - std::vector table = std::vector(Size); // Allocate on the heap -}; - enum SyncCout { IO_LOCK, IO_UNLOCK }; std::ostream& operator<<(std::ostream&, SyncCout); @@ -97,6 +87,7 @@ public: void push_back(const T& value) { values_[size_++] = value; } const T* begin() const { return values_; } const T* end() const { return values_ + size_; } + const T& operator[](int index) const { return values_[index]; } private: T values_[MaxSize]; @@ -143,13 +134,13 @@ public: inline uint64_t mul_hi64(uint64_t a, uint64_t b) { #if defined(__GNUC__) && defined(IS_64BIT) __extension__ using uint128 = unsigned __int128; - return ((uint128)a * (uint128)b) >> 64; + return (uint128(a) * uint128(b)) >> 64; #else - uint64_t aL = (uint32_t)a, aH = a >> 32; - uint64_t bL = (uint32_t)b, bH = b >> 32; + uint64_t aL = uint32_t(a), aH = a >> 32; + uint64_t bL = uint32_t(b), bH = b >> 32; uint64_t c1 = (aL * bL) >> 32; uint64_t c2 = aH * bL + c1; - uint64_t c3 = aL * bH + (uint32_t)c2; + uint64_t c3 = aL * bH + uint32_t(c2); return aH * bH + (c2 >> 32) + (c3 >> 32); #endif }