Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-08-28 08:27:08

0001 // Licensed to the Apache Software Foundation (ASF) under one
0002 // or more contributor license agreements.  See the NOTICE file
0003 // distributed with this work for additional information
0004 // regarding copyright ownership.  The ASF licenses this file
0005 // to you under the Apache License, Version 2.0 (the
0006 // "License"); you may not use this file except in compliance
0007 // with the License.  You may obtain a copy of the License at
0008 //
0009 //   http://www.apache.org/licenses/LICENSE-2.0
0010 //
0011 // Unless required by applicable law or agreed to in writing,
0012 // software distributed under the License is distributed on an
0013 // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
0014 // KIND, either express or implied.  See the License for the
0015 // specific language governing permissions and limitations
0016 // under the License.
0017 
0018 #pragma once
0019 
0020 namespace arrow {
0021 namespace internal {
0022 
0023 // ----------------------------------------------------------------------
0024 // BEGIN Hash utilities from Boost
0025 
0026 namespace detail {
0027 
0028 #if defined(_MSC_VER)
0029 #  define ARROW_HASH_ROTL32(x, r) _rotl(x, r)
0030 #else
0031 #  define ARROW_HASH_ROTL32(x, r) (x << r) | (x >> (32 - r))
0032 #endif
0033 
0034 template <typename SizeT>
0035 inline void hash_combine_impl(SizeT& seed, SizeT value) {
0036   seed ^= value + 0x9e3779b9 + (seed << 6) + (seed >> 2);
0037 }
0038 
0039 inline void hash_combine_impl(uint32_t& h1, uint32_t k1) {
0040   const uint32_t c1 = 0xcc9e2d51;
0041   const uint32_t c2 = 0x1b873593;
0042 
0043   k1 *= c1;
0044   k1 = ARROW_HASH_ROTL32(k1, 15);
0045   k1 *= c2;
0046 
0047   h1 ^= k1;
0048   h1 = ARROW_HASH_ROTL32(h1, 13);
0049   h1 = h1 * 5 + 0xe6546b64;
0050 }
0051 
0052 #undef ARROW_HASH_ROTL32
0053 
0054 }  // namespace detail
0055 
0056 template <class T>
0057 inline void hash_combine(std::size_t& seed, T const& v) {
0058   std::hash<T> hasher;
0059   return ::arrow::internal::detail::hash_combine_impl(seed, hasher(v));
0060 }
0061 
0062 // END Hash utilities from Boost
0063 // ----------------------------------------------------------------------
0064 
0065 }  // namespace internal
0066 }  // namespace arrow